Skip to content

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

@nicowilliams

Description

@nicowilliams

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions