xta / HalloweenBash

Custom Bash Profile Generator
http://xta.github.io/HalloweenBash/
333 stars 32 forks source link

Advise to start with ': ' first and end with '; ' -- helps cut-n-paste #17

Open nicowilliams opened 11 years ago

nicowilliams commented 11 years ago

If you start $PS1 with ': ' and end with '; ' then you cut-n-paste entire command lines more easily (no need to grab from the end of the prompt).

Bonus: single-quote the rest of the PS1 to avoid glob injection.

Bonus: set PS2= to further help the cut-n-paste of long command-lines.

Bonus: add number of files dirty (modified/added/deleted in git workspace or index but not committed).

Bonus: add support for other VCSes.

I have support for Fossil, Mercurial, and git, in my shell startup. I've a set of functions for this. I like to format my prompt like this:

: vcs:project[branch]:TOP/.../basename-of-PWD[number-of-dirty-files:number-of-history-commands]%;

plus colors. See my .kshaliases. I then set PS1='$(vcs_ps1)'.

https://github.com/nicowilliams/env/blob/master/.kshaliases

Yes, ksh, I know. Not too hard to port to bash. See https://github.com/jakobi/script-archive/blob/master/cli.shell.functions/dir.shell/cd.nico_cd_for_bash_and_ksh.func for some help with writing ksh/bash compat code (also, those functions are awesome).

xta commented 11 years ago

Hi @nicowilliams

Thanks for your suggestion. For this issue, if I understand correctly, you want to have an option to wrap PS1 strings with : and ;. I don't see this as a common use case, but would be interested to see if others want this.