Skip to content

Commit 85aa664

Browse files
Merge pull request #215 from jonathanforhan/master
fix bug with multi-word cwd
2 parents a787cd1 + 6fe8552 commit 85aa664

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

scripts/cwd.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
#!/usr/bin/env bash
22

33
# return current working directory of tmux pane
4-
getPaneDir()
5-
{
4+
getPaneDir() {
65
nextone="false"
7-
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
8-
do
9-
if [ "$nextone" == "true" ]; then
10-
echo $i
11-
return
12-
fi
13-
if [ "$i" == "1" ]; then
14-
nextone="true"
15-
fi
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 "
1611
done
12+
echo "${ret%?}"
1713
}
1814

19-
main()
20-
{
15+
main() {
2116
path=$(getPaneDir)
2217

2318
# change '/home/user' to '~'
24-
cwd=$(echo $path | sed "s;$HOME;~;g")
19+
cwd="${path/"$HOME"/'~'}"
2520

26-
echo $cwd
21+
echo "$cwd"
2722
}
2823

2924
#run main driver program

0 commit comments

Comments
 (0)