/ scripts / cwd.sh
cwd.sh
 1  #!/usr/bin/env bash
 2  
 3  # return current working directory of tmux pane
 4  getPaneDir() {
 5    nextone="false"
 6    ret=""
 7    for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do
 8      [ "$i" == "1" ] && nextone="true" && continue
 9      [ "$i" == "0" ] && nextone="false"
10      [ "$nextone" == "true" ] && ret+="$i "
11    done
12    echo "${ret%?}"
13  }
14  
15  main() {
16    path=$(getPaneDir)
17  
18    # change '/home/user' to '~'
19    cwd="${path/"$HOME"/'~'}"
20  
21    echo "$cwd"
22  }
23  
24  #run main driver program
25  main