tmux-kanagawa/scripts/cwd.sh

26 lines
484 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# return current working directory of tmux pane
2023-05-12 19:35:49 +02:00
getPaneDir() {
nextone="false"
2023-05-12 19:35:49 +02:00
ret=""
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do
[ "$i" == "1" ] && nextone="true" && continue
[ "$i" == "0" ] && nextone="false"
[ "$nextone" == "true" ] && ret+="$i "
done
2023-05-12 19:35:49 +02:00
echo "${ret%?}"
}
2023-05-12 19:35:49 +02:00
main() {
path=$(getPaneDir)
# change '/home/user' to '~'
2023-05-12 19:35:49 +02:00
cwd="${path/"$HOME"/'~'}"
2023-05-12 19:35:49 +02:00
echo "$cwd"
}
#run main driver program
main