Skip to content

Commit

Permalink
Merge pull request #215 from jonathanforhan/master
Browse files Browse the repository at this point in the history
fix bug with multi-word cwd
  • Loading branch information
ethancedwards8 committed May 14, 2023
2 parents a787cd1 + 6fe8552 commit 85aa664
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions scripts/cwd.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
#!/usr/bin/env bash

# return current working directory of tmux pane
getPaneDir()
{
getPaneDir() {
nextone="false"
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
do
if [ "$nextone" == "true" ]; then
echo $i
return
fi
if [ "$i" == "1" ]; then
nextone="true"
fi
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
echo "${ret%?}"
}

main()
{
main() {
path=$(getPaneDir)

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

echo $cwd
echo "$cwd"
}

#run main driver program
Expand Down

0 comments on commit 85aa664

Please sign in to comment.