Trueline ist eine schnelle und erweiterbare Eingabeaufforderung im Powerline-Stil. Von der Implementierung und den Funktionen wurde es von Pureline inspiriert und komplett in Bash geschrieben.
Funktionen:
RGB-Farbcode-Unterstützung
Symbole/Glyphen
Bestimmte Verzeichnisse werden als Symbol dargestellt (GitHub, GitLab, Python-Virtual-Environment, und mehr.
Alle Symbole, die unterstützt werden, einschließlich derer, die ich dem Skript noch hinzugefügt haben, sind weiter unten als Bild eingefügt. Genauso, wie die Erweiterung für die Unterverzeichnisse von /home, wie Bilder, Videos, usw.
Zur Darstellung verwende ich Droid Sans Mono mit der NerdFont-Erweiterung. Download
Erweiterung des Skript für Symbole in Home-Verzeichnis, wie Bilder, Videos, usw. oder /etc.
_trueline_working_dir_segment() {
local fg_color="$1"
local bg_color="$2"
local font_style="$3"
local segment="$(_trueline_separator)"
local wd_separator="${TRUELINE_SYMBOLS[working_dir_separator]}"
if [[ "$TRUELINE_WORKING_DIR_SPACE_BETWEEN_PATH_SEPARATOR" = true ]]; then
wd_separator=" $wd_separator "
fi
local dir=$PWD
if [[ "$dir" =~ "Bilder" ]]; then
local dir="Bilder"
fi
if [[ "$dir" =~ "Musik" ]]; then
local dir="Musik"
fi
if [[ "$dir" =~ "Dokumente" ]]; then
local dir="Dokumente"
fi
if [[ "$dir" =~ "Videos" ]]; then
local dir="Videos"
fi
if [[ "$dir" =~ "Downloads" ]]; then
local dir="Downloads"
fi
if [[ "$dir" =~ "Papierkorb" ]]; then
local dir="Papierkorb"
fi
if [[ "$dir" =~ "Schreibtisch" ]]; then
local dir="Schreibtisch"
fi
if [[ "$dir" =~ "etc" ]]; then
local dir="etc"
fi
case "$dir" in
Bilder)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[pictures]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Musik)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[music]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Dokumente)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[documents]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Videos)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[videos]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Downloads)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[downloads]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Papierkorb)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[trash]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
Schreibtisch)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]} ${TRUELINE_SYMBOLS[working_dir_separator]} ${TRUELINE_SYMBOLS[desktop]}} "
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 3 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+2]}"
elif [[ "$path_size" -eq 4 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[1m\]${arr[+3]}"
elif [[ "$path_size" -eq 5 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[22m\]${arr[+2]}$wd_separator\[\033[22m\]${arr[+3]}$wd_separator\[\033[1m\]${arr[+4]}"
else
if [[ "$path_size" -gt 5 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
*)
local p="${PWD/$HOME/${TRUELINE_SYMBOLS[working_dir_home]}}"
local arr=
IFS='/' read -r -a arr <<< "$p"
local path_size="${#arr[@]}"
if [[ "$path_size" -eq 1 ]]; then
local path_="\[\033[1m\]${arr[0]:=/}"
elif [[ "$path_size" -eq 2 ]]; then
local path_="${arr[0]:=/}$wd_separator\[\033[1m\]${arr[+1]}"
else
if [[ "$path_size" -gt 3 ]]; then
if [[ "$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS" = true ]]; then
p=$(echo "$p" | sed -r "s:([^/]{,$TRUELINE_WORKING_DIR_ABBREVIATE_PARENT_DIRS_LENGTH})[^/]*/:\1/:g")
else
p="${TRUELINE_SYMBOLS[working_dir_folder]}/"$(echo "$p" | rev | cut -d '/' -f-3 | rev)
fi
fi
local curr=$(basename "$p")
p=$(dirname "$p")
local path_="${p//\//$wd_separator}$wd_separator\[\033[1m\]$curr"
if [[ "${p:0:1}" = '/' ]]; then
path_="/$path_"
fi
fi
;;
esac
segment+="$(_trueline_content "$fg_color" "$bg_color" "$font_style" " $path_ ")"
PS1+="$segment"
_trueline_record_colors "$fg_color" "$bg_color" "$font_style"
}
Symbole
[documents]='' [pictures]='' [videos]='' [music]='' [downloads]='' [trash]='' [desktop]='' [etc]='' [aws_profile]='' [bg_jobs]='' [exit_status]='' [git_ahead]='' [git_behind]='' [git_bitbucket]='' [git_branch]='' [git_github]='' [git_gitlab]='' [git_modified]='' [newline]='' [newline_root]='' [ps2]='...' [read_only]='' [segment_separator]='' [ssh]='' [timer]='' [venv]='' [vimode_cmd]='N' [vimode_ins]='I' [working_dir_folder]='' [working_dir_home]='' [working_dir_separator]=''
*Symbole können teilweise etwas anders aussehen, da NerdFonts verschieden Icon-Quellen benutzt, die WordPress nicht unterstützt.
Letztes Update: Mo, 28. Aug. 2023
Ursprünglich veröffentlicht: Mi, 21. Jun. 2023