From 09c57506561b8a4b6d18ce03de9ad8a7cf062854 Mon Sep 17 00:00:00 2001 From: jonathanforhan Date: Fri, 7 Apr 2023 20:40:53 -0400 Subject: [PATCH] Add cwd.sh to display the tmux pane's current working directory, updated README to reflect change --- README.md | 1 + scripts/cwd.sh | 30 ++++++++++++++++++++++++++++++ scripts/dracula.sh | 6 ++++++ 3 files changed, 37 insertions(+) create mode 100755 scripts/cwd.sh diff --git a/README.md b/README.md index a6536d0..fb80867 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/cwd.sh b/scripts/cwd.sh new file mode 100755 index 0000000..cfae694 --- /dev/null +++ b/scripts/cwd.sh @@ -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 diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 3e1bc1b..1054563 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -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