diff options
| author | 2025-01-21 14:33:39 -0800 | |
|---|---|---|
| committer | 2025-01-21 14:35:56 -0800 | |
| commit | 66e4188bd7caf58f43c0270e16bfc6e8d7807b8b (patch) | |
| tree | 02a28c530040bb549d1622b7aa30b27ecb10d33b /oni/home/config/zsh | |
| parent | b78aeefec1ba3cdfc4cfb76e5f505ef06a4c3a0a (diff) | |
| download | new-dotfiles-66e4188bd7caf58f43c0270e16bfc6e8d7807b8b.tar.gz new-dotfiles-66e4188bd7caf58f43c0270e16bfc6e8d7807b8b.zip | |
Add zsh configuration
Diffstat (limited to 'oni/home/config/zsh')
| -rw-r--r-- | oni/home/config/zsh/spwd.zsh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/oni/home/config/zsh/spwd.zsh b/oni/home/config/zsh/spwd.zsh new file mode 100644 index 0000000..76de8d9 --- /dev/null +++ b/oni/home/config/zsh/spwd.zsh @@ -0,0 +1,27 @@ +function spwd() { + # From https://stackoverflow.com/a/45336078 + paths=(${(s:/:)PWD}) + + cur_path='/' + cur_short_path='/' + for directory in ${paths[@]} + do + cur_dir='' + for (( i=0; i<${#directory}; i++ )); do + cur_dir+="${directory:$i:1}" + matching=("$cur_path"/"$cur_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + cur_short_path+="$cur_dir/" + cur_path+="$directory/" + + if [[ $cur_path == $HOME/ ]]; + then cur_short_path='~/' + fi + done + + printf %b "${cur_short_path: : -1}" + echo +} |
