Related: Why is my bash prompt getting bugged when I browse the history?
History looks like:
1831 git remote -v
1832 gs
1833 gd
1834 gc -am 'moved apsum options etc to their own file
set routes to allow cors
changes to the apsum pull '
1835 git push
1836 reset
1837 history
1838 __git_ps1
1839 reset
1840 history
1841 Kill 99894
1842 history
g* are all aliases for git commands. When I scroll through history it's all fine, until I get to number 1833 (underscore denotes cursor position):
$ gd _
[ up arrow]
$ gds_
[up arrow]
$ gdit remote -v_
I figured it was because of non-printing characters in my PS1 but I've bracketed all those out:
PS1="\n\[$FCYN\]\$(date +%H:%M:%S) \w\[$IGreen\]\$(__git_ps1)\[$Black\] $ \[$DarkGray\]"
Did I miss something? Is this just something that happens when you have multiline commit messages?
edit: my final solution is too large to put into a comment:
export PS1="\\n\[\033[38;5;246m\]\u@\[$(tput sgr0)\]\[\033[38;5;245m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;28m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\[$(tput sgr0)\]\[\033[38;5;2m\]`__git_ps1`\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;90m\]\t\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;232m\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\n\[$(tput sgr0)\]\[\033[38;5;0m\]\\$\[$(tput sgr0)\] "
Which seems crazy but it produces a nice prompt with the git branch and colors that are easy to read on a light background (which you can't see here):
collumj@machineName ~ (dev) 17:35:42
$
Many thanks to http://bashrcgenerator.com/.