metanohi/site/writings/bash-prompt.org

44 lines
1.0 KiB
Org Mode
Raw Normal View History

#+title: My BASH prompt (outdated)
2011-08-01 22:39:41 +02:00
#&summary
2012-11-07 22:49:11 +01:00
What my prompt used to do and what it looked like.
2011-08-01 22:39:41 +02:00
#&
2013-02-08 16:47:53 +01:00
#+license: wtfpl
2011-08-01 22:39:41 +02:00
2012-11-07 22:49:11 +01:00
* My old BASH prompt
2011-08-01 22:39:41 +02:00
2012-11-07 22:49:11 +01:00
I had a strange bash prompt. To use it, first, copy this into your ~.bashrc~:
2011-08-01 22:39:41 +02:00
#+BEGIN_SRC sh
2011-08-10 23:35:57 +02:00
function ps1lr {
if [ $1 == 0 ]; then
echo -ne "\033[42m\033[01;30m"
else
echo -ne "\033[41m\033[01;34m"
fi
length-extra-prepend $1 3
}
function ps1sp {
pwdw=$(($COLUMNS-20))
if (( $pwdw < 40 )); then
pwdw=40
fi
length-too-much-shorten "$(pwd | sed s%$HOME%~%)" $pwdw
}
#PROMPT_COMMAND=""
PS1='\[\033[00m\]$(ps1lr $?)\[\033[45m\] \[\033[44m\]\[\033[01;37m\]\
$(date +%H:%M)\[\033[45m\] \[\033[46m\]\[\033[01;33m\]\
$(ps1sp)\[\033[00m\]\n\[\033[45m\]\[\033[01;33m\]\u\[\033[01;32m\]@\
\[\033[01;36m\]\h\[\033[43m\]\[\033[01;30m\]:\[\033[40m\]\
\[\033[01;33m\]\$\[\033[00m\] '
2011-08-01 22:39:41 +02:00
#+END_SRC
Second, download [[bash-prompt-extras.tar.gz]] and put the included programs
somewhere in =$PATH=&sh.
2012-11-07 22:49:11 +01:00
* Not anymore
I didn't actually need all the features.