mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-16 09:50:06 +00:00
Merge branch 'dritter/improve_shorten_dir_length' of github.com:dritter/powerlevel9k into dritter/improve_shorten_dir_length
This commit is contained in:
commit
9efe519dc5
2 changed files with 25 additions and 2 deletions
12
README.md
12
README.md
|
@ -277,6 +277,18 @@ to a certain length:
|
|||
# Limit to the last two folders
|
||||
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
|
||||
To change the way how the current working directory is truncated, just set:
|
||||
|
||||
# truncate whole directories
|
||||
POWERLEVEL9K_SHORTEN_STRATEGY="complete_directories"
|
||||
# truncate from right, leaving the first X characters untouched
|
||||
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right"
|
||||
# default behaviour is to truncate the middle part of the directory
|
||||
|
||||
In each case you have to specify the length you want to shorten the directory
|
||||
to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in
|
||||
others whole directories.
|
||||
|
||||
#### The 'time' segment
|
||||
|
||||
By default the time is show in 'H:M:S' format. If you want to change it,
|
||||
|
|
|
@ -482,8 +482,19 @@ prompt_context() {
|
|||
prompt_dir() {
|
||||
local current_path='%~'
|
||||
if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" ]]; then
|
||||
# shorten path to $POWERLEVEL9K_SHORTEN_DIR_LENGTH
|
||||
current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
|
||||
|
||||
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
|
||||
complete_directories)
|
||||
current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
|
||||
;;
|
||||
truncate_from_right)
|
||||
current_path=$(pwd | sed -e "s,^$HOME,~," | sed -E "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1..\//g")
|
||||
;;
|
||||
*)
|
||||
current_path=$(pwd | sed -e "s,^$HOME,~," | sed -E "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1\.\.\2\//g")
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
$1_prompt_segment "$0" "blue" "$DEFAULT_COLOR" "$current_path"
|
||||
|
|
Loading…
Reference in a new issue