Kaynağa Gözat

Shortening path via built in bash variable.

tags/original
Bryan Miller 6 yıl önce
ebeveyn
işleme
0e51d8a053
1 değiştirilmiş dosya ile 14 ekleme ve 9 silme
  1. +14
    -9
      ps1.rc.sh

+ 14
- 9
ps1.rc.sh Dosyayı Görüntüle

@@ -145,18 +145,22 @@ section_tty () {
}


short_PWD ()
{
local PRE= NAME="$1" LENGTH="$2";
[[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
echo "$PRE$NAME"
}
# NOTE: Removed this as it does not handle paths with spaces well.
#short_PWD ()
#{
# local PRE= NAME="$1" LENGTH="$2";
# [[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
# PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
# ((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
# echo "$PRE$NAME"
#}


set_prompt() {
local lec="$?"
if [ -z "$PROMPT_DIRTRIM" ]; then
PROMPT_DIRTRIM=2
fi
local color=$GREEN
local bg=$BG_LBLUE
local smilie=" ${symbols[smilie]} "
@@ -172,7 +176,8 @@ set_prompt() {
section $smilie $color $BG_BLACK 1 true
section_tty $BLACK $BG_LBLUE $RED $BG_YELLOW
section " \u@\h " $BLUE $BG_LCYAN
section " $(short_PWD $PWD 20) " $LCYAN $BG_BLUE
section " \w " $LCYAN $BG_BLUE
#section " $(short_PWD $PWD 20) " $LCYAN $BG_BLUE
section_git_status $YELLOW $BG_LBLUE
section "\n" $DEFAULT $BG_GREY
section_separator

Yükleniyor…
İptal
Kaydet