fish-style prompt for bash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,
I just finished writing a fancier prompt for bash, which showing directories in an abbreviated form just like the fish shell does.

function _prompt {
_dir_abbr=$(temp=$(echo "${PWD/$HOME/~}" |sed -r 's/(\/.)[^/]*/\1/g'); echo ${temp:0:$(( ${#temp} - 1 ))})
   _ps1="$(basename "${PWD/$HOME/~}")"
   if [ ${#_ps1} -gt 25 ]; then
       _ps1="${_ps1:0:7}...${_ps1: -7}"
   fi
   echo -n "$_dir_abbr$_ps1"
}

just quote the function in the $PS1 like this (e.g.):
PS1='$(_prompt)] '

enjoy!


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux