Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix displaying directories that have spaces #214

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions scripts/cwd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@
# return current working directory of tmux pane
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
done
nextone="false"
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()
{
path=$(getPaneDir)

# change '/home/user' to '~'
cwd=$(echo $path | sed "s;$HOME;~;g")
source "$HOME/.vim/buf"

echo $cwd
}
path="$vim_buf"
[ -z "$path" ] && path=$(getPaneDir)

#run main driver program
main
# change '/home/user' to '~'
echo "${path/"$HOME"/'~'}"
Loading