summaryrefslogtreecommitdiff
path: root/tw/home/files
diff options
context:
space:
mode:
authorTimo Wilken2023-01-19 00:28:36 +0100
committerTimo Wilken2023-01-19 00:28:36 +0100
commit4a0a4f55981287ec7e69e2c4ff779f88c8a8b3b1 (patch)
treea18b01e5c989cbb469b9880825785e70b270cde5 /tw/home/files
parent82a1ff70c1499ab3d8e1f13ec03ddc9e9f270888 (diff)
Improve shell prompt cwd abbreviation handling
Diffstat (limited to 'tw/home/files')
-rw-r--r--tw/home/files/prompt.zsh7
1 files changed, 5 insertions, 2 deletions
diff --git a/tw/home/files/prompt.zsh b/tw/home/files/prompt.zsh
index 15e2d49b..7cc7342b 100644
--- a/tw/home/files/prompt.zsh
+++ b/tw/home/files/prompt.zsh
@@ -59,8 +59,11 @@ prompt_fast_preexec () {
}
prompt_fast_pwd () {
- local fast_path="$(print -Pn '%~')"
- if (($#fast_path / $COLUMNS.0 * 100 > ${PROMPT_FAST_PATH_PERCENT:-33})); then
+ local fast_path=$(print -Pn '%~')
+ local components=${#fast_path//[^\/]} # this counts the initial /
+ # Only abbreviate as /1/…/2/3 if we have something to cut out between 1 and 2!
+ # /1/2/3 -> /1/…/2/3 makes no sense.
+ if ((components > 3 && $#fast_path > ${PROMPT_FAST_PATH_FRACTION:-0.33} * COLUMNS)); then
print -Pn '%-1~/…/%2/'
else
print "$fast_path"