File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3+ current_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
4+ source " $current_dir /utils.sh"
5+
36# return current working directory of tmux pane
47getPaneDir () {
58 nextone=" false"
@@ -13,10 +16,34 @@ getPaneDir() {
1316}
1417
1518main () {
16- path=$( getPaneDir)
19+ path=" $( getPaneDir) "
20+
21+ if [[ " $path " == " $HOME " ]]; then
22+ echo " ~"
23+ exit 0
24+ fi
1725
1826 # change '/home/user' to '~'
19- cwd=" ${path/ " $HOME " / ' ~' } "
27+ cwd=" ${path/ " ${HOME} /" / ' ~/' } "
28+
29+ # check max number of subdirs to display. 0 means unlimited
30+ cwd_max_dirs=" $( get_tmux_option " @dracula-cwd-max-dirs" " 0" ) "
31+
32+ if [[ " $cwd_max_dirs " -gt 0 ]]; then
33+ base_to_erase=$cwd
34+ for (( i = 0 ; i < cwd_max_dirs ; i++ )) ; do
35+ base_to_erase=" ${base_to_erase%/* } "
36+ done
37+ # / would have #base_to_erase of 0 and ~/ has #base_to_erase of 1. we want to exclude both cases
38+ if [[ ${# base_to_erase} -gt 1 ]]; then
39+ cwd=" …/${cwd: ${# base_to_erase} +1} "
40+ fi
41+ fi
42+
43+ cwd_max_chars=" $( get_tmux_option " @dracula-cwd-max-chars" " 0" ) "
44+ if [[ " ${cwd_max_chars} " -gt 0 && " ${# cwd} " -gt " $cwd_max_chars " ]]; then
45+ cwd=" …/…${cwd: (- cwd_max_chars)} "
46+ fi
2047
2148 echo " $cwd "
2249}
You can’t perform that action at this time.
0 commit comments