HalloweenBash icon indicating copy to clipboard operation
HalloweenBash copied to clipboard

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

Open nicowilliams opened this issue 12 years ago • 1 comments

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).

nicowilliams avatar Aug 14 '13 03:08 nicowilliams

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.

xta avatar Aug 15 '13 03:08 xta