mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
superficial changes
This commit is contained in:
parent
8d701cf804
commit
14df797f62
1 changed files with 12 additions and 4 deletions
16
bash/prompt
16
bash/prompt
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
# truncates a string on the left
|
||||
# $1: string to truncate
|
||||
# $2: maximum length
|
||||
# $3: truncation string replacement (optional)
|
||||
# $4: separator symbol (optional, prevents truncation of rightmost item)
|
||||
__truncate_left() {
|
||||
local str="$1"
|
||||
local maxlen="$2"
|
||||
|
|
@ -23,14 +29,16 @@ __truncate_left() {
|
|||
echo "$str"
|
||||
}
|
||||
|
||||
__truncate_dir() {
|
||||
# truncates a path
|
||||
__truncate_path() {
|
||||
#gain some place with '~'
|
||||
dir=${1/#$HOME/\~}
|
||||
__truncate_left "$dir" 25 '…' '/'
|
||||
local path=${1/#$HOME/\~}
|
||||
__truncate_left "$path" 25 '…' '/'
|
||||
}
|
||||
|
||||
# truncates CWD
|
||||
__tpwd() {
|
||||
__truncate_dir "$PWD"
|
||||
__truncate_path "$PWD"
|
||||
}
|
||||
|
||||
#__print_rprompt() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue