mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Added new variable POWERLEVEL9K_DIR_PATH_ABSOLUTE
If user sets POWERLEVEL9K_DIR_PATH_ABSOLUTE to true, uses absolute paths instead of home folder abbreviation, e.g. /Users/chris/... instead of ~/...
This commit is contained in:
parent
b723800b80
commit
ddcdad77a7
2 changed files with 16 additions and 3 deletions
|
@ -723,7 +723,10 @@ set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
|
||||||
set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
|
set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
|
||||||
set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false
|
set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false
|
||||||
prompt_dir() {
|
prompt_dir() {
|
||||||
local current_path="$(print -P '%~')"
|
# using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE
|
||||||
|
local current_path=$PWD # WAS: local current_path="$(print -P '%~')"
|
||||||
|
# check if the user wants to use absolute paths or "~" paths
|
||||||
|
[[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"}
|
||||||
# save this path so that we can use the pure path for STATE icons and colors later.
|
# save this path so that we can use the pure path for STATE icons and colors later.
|
||||||
local state_path=$current_path
|
local state_path=$current_path
|
||||||
# declare all local variables
|
# declare all local variables
|
||||||
|
@ -891,9 +894,9 @@ prompt_dir() {
|
||||||
local current_state="DEFAULT"
|
local current_state="DEFAULT"
|
||||||
if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
|
if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
|
||||||
current_state="NOT_WRITABLE"
|
current_state="NOT_WRITABLE"
|
||||||
elif [[ $state_path == '~' ]]; then
|
elif [[ $state_path == $HOME ]]; then # changed '~' to $HOME for compatibility with POWERLEVEL9K_DIR_PATH_ABSOLUTE
|
||||||
current_state="HOME"
|
current_state="HOME"
|
||||||
elif [[ $state_path == '~'* ]]; then
|
elif [[ $state_path == $HOME* ]]; then # changed '~'* to $HOME* for compatibility with POWERLEVEL9K_DIR_PATH_ABSOLUTE
|
||||||
current_state="HOME_SUBFOLDER"
|
current_state="HOME_SUBFOLDER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,16 @@ function tearDown() {
|
||||||
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testAbsolutePathWorks() {
|
||||||
|
POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)"
|
||||||
|
|
||||||
|
cd -
|
||||||
|
unset POWERLEVEL9K_DIR_PATH_ABSOLUTE
|
||||||
|
}
|
||||||
|
|
||||||
function testTruncateFoldersWorks() {
|
function testTruncateFoldersWorks() {
|
||||||
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||||
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
|
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
|
||||||
|
|
Loading…
Reference in a new issue