Add cwd.sh to display the tmux pane's current working directory, updated README to reflect change

This commit is contained in:
jonathanforhan 2023-04-07 20:40:53 -04:00
parent b346d10306
commit 09c5750656
3 changed files with 37 additions and 0 deletions

View file

@ -31,6 +31,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
- Spotify playback (needs the tool spotify-tui installed)
- Current kubernetes context
- Current working directory of tmux pane
## Compatibility

30
scripts/cwd.sh Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# 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
}
main()
{
path=$(getPaneDir)
# change '/home/user' to '~'
cwd=$(echo $path | sed "s;$HOME;~;g")
echo $cwd
}
#run main driver program
main

View file

@ -128,6 +128,12 @@ main()
for plugin in "${plugins[@]}"; do
if [ $plugin = "cwd" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cwd-colors" "dark_gray white")
tmux set-option -g status-right-length 250
script="#($current_dir/cwd.sh)"
fi
if [ $plugin = "git" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray")
tmux set-option -g status-right-length 250