I am using the default <#{pane_current_path}> to display the current working directory for the current pane used. However the result is a lengthy full directory path taking lot of space in the status bar.
What I wanted is to use a shell script or ruby script to cut it short and display a short path like starting from home directory or just the last two sub directories.
I am stuck with find a way to let the shell script to take #{pane_current_path} as a varible, see below:
set -g status-left "#[fg=blue][#S] #I:#P #(cm_tmux_status_pwd.rb #{pane_current_path})"
I tested this, obviously it's not working.
There are other ways to achieve this but it's buggy, like to setenv then showenv in external script, see below, it just can't sync very well.
tmux showenv -g TMUX_PWD_$(tmux display -p "#D" | tr -d %) | sed 's/^.*=//'
So, please can you suggest if what I am expecting is doable or not, anyway to manipulate #{pane_current_path} ?
Instead of passing an argument to a script, why not fetch what you need from the script itself?
You can use this:
tmux display-message -p -F "#{pane_current_path}"
That will get pane current path in the script or from outside tmux.
If you're going to use bash for the script, here's how you assign the pane current path value to a variable (btw. double quotes inside double quotes are okay):
local current_path="$(tmux display-message -p -F "#{pane_current_path}")"