Merge pull request #198 from jonathanforhan/master

Add cwd.sh to display the tmux pane's current working directory
This commit is contained in:
Ethan Edwards 2023-04-08 08:45:24 -04:00 committed by GitHub
commit ff6bdb5edc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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