Merge pull request #215 from jonathanforhan/master
fix bug with multi-word cwd
This commit is contained in:
commit
85aa66402a
1 changed files with 10 additions and 15 deletions
|
@ -1,29 +1,24 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# return current working directory of tmux pane
|
# return current working directory of tmux pane
|
||||||
getPaneDir()
|
getPaneDir() {
|
||||||
{
|
|
||||||
nextone="false"
|
nextone="false"
|
||||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
|
ret=""
|
||||||
do
|
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do
|
||||||
if [ "$nextone" == "true" ]; then
|
[ "$i" == "1" ] && nextone="true" && continue
|
||||||
echo $i
|
[ "$i" == "0" ] && nextone="false"
|
||||||
return
|
[ "$nextone" == "true" ] && ret+="$i "
|
||||||
fi
|
|
||||||
if [ "$i" == "1" ]; then
|
|
||||||
nextone="true"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
echo "${ret%?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main() {
|
||||||
{
|
|
||||||
path=$(getPaneDir)
|
path=$(getPaneDir)
|
||||||
|
|
||||||
# change '/home/user' to '~'
|
# change '/home/user' to '~'
|
||||||
cwd=$(echo $path | sed "s;$HOME;~;g")
|
cwd="${path/"$HOME"/'~'}"
|
||||||
|
|
||||||
echo $cwd
|
echo "$cwd"
|
||||||
}
|
}
|
||||||
|
|
||||||
#run main driver program
|
#run main driver program
|
||||||
|
|
Loading…
Reference in a new issue