Added promptpwd().

This commit is contained in:
Achim D. Brucker 2017-07-02 23:06:36 +01:00
parent e73b0eb486
commit 226b81abb8
1 changed files with 22 additions and 1 deletions

23
themes/logicalhacking.zsh-theme Normal file → Executable file
View File

@ -1,4 +1,4 @@
# vim:ft=zsh ts=2 sw=2 sts=2
# vim:ft=zsh ts=4 sw=2 sts=2
# Copyright (C) 2017 Achim D. Brucker, https://www.brucker.ch
#
# LogicalHacking Theme
@ -11,3 +11,24 @@
# Make sure you have a recent version: the code points that Powerline
# uses changed in 2012, and older versions will display incorrectly,
# in confusing ways.
# Generic function for formatting the working directory - in particular,
# it allows zpresto-style shortening of the full path.
promptpwd() {
setopt localoptions extendedglob
local current_pwd="${PWD/#$HOME/~}"
local ret_directory
if [[ "$current_pwd" == (#m)[/~] ]]; then
ret_directory="$MATCH"
unset MATCH
elif zstyle -m ':lh:module:prompt' pwd-length 'full'; then
ret_directory=${PWD}
elif zstyle -m ':lh:module:prompt' pwd-length 'long'; then
ret_directory=${current_pwd}
else
ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}"
fi
print "$ret_directory"
}