Open davclark opened 9 years ago
@davclark upload your .rc file and show us screenshots, please!
:+1:
Sorry this has fallen so far to the wayside...
I had been keeping prompt customizations in .profile, but it turns out byobu wants such things in .bashrc
. Thanks for "prompting" that investigation.
The secret sauce is something like this:
# We separate this into two lines to make things easier to read
fish_style_dir_cmd='CurDir=`pwd|sed -e "s!$HOME!~!"|sed -Ee "s!([^/])[^/]+/!\1/!g"`'
export PROMPT_COMMAND="$fish_style_dir_cmd; $PROMPT_COMMAND"
Then you put $CurDir
instead of \w
for the prompt, like so:
if [ "$color_prompt" = yes ]; then
# PS1="${win_title}\u@\h \$CurDir$bold\$$plain "
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$CurDir\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:$CurDir\$ '
fi
unset color_prompt force_color_prompt
Be careful of Bash escaping rules :footprints: :gun:
In my OS X prompt, I have a much more interpretable looking thing like this:
bold="\[\e[1m\]"
plain="\[\e[0m\]"
win_title='\[\033]0;\u@\h: \w\007\]'
# The $ is escaped before CurDir because we want it evaluated for each prompt
PS1="${win_title}dav@$(networksetup -getcomputername) \$CurDir$bold\$$plain "
That's way easier to interpret, and would be a good style for BCE. However I simply don't feel like even thinking about the escaping above to clarify things. E.g., "does \[\033[01;34m\]
== $bold
? Looks like some extra 34
in there... Does that do anything? Oops, times up!"
I also have to say that the default oh-my-zsh / bash-it prompt may be better for our students as a prompt (but even less comprehensible). It uses unicode to make a very clear 2-line prompt in the modern theme. Here is a super-simple version inspired by that (using $plain
and $bold
from above):
PS1="┌─\u@\h:${bold}\w${plain}\n└─\$ "
This makes it easier to see what's being typed. Dav has an example - just ask him.