sandric
sandric

Reputation: 2470

How to rename tmux window with current running fish command?

I wish to rename current tmux window to current running process in current pane with running fish. Here's my command I enter:

tmux rename-window $_

But instead of fish, I getting tmux. The problem, as I understand it - is because tmux itself is a process and $_ outputs it, where I need $_ to output process before using $_ as an argument. The same behavior here:

echo $_

Outputs echo- because of that behavior I can not even see whats the current process is, all I can see is echo. So my question is I think is how to get $_ "before current command", is there some way I can do that?

Solution:

Solution what I found is using that:

run-shell "tmux rename-window \"#{pane_current_command}\""

Strangely, you can not use rename-window outside of run-shell, because rename-window not interpolating tmux variables if runned inside tmux.conf.

Upvotes: 0

Views: 846

Answers (1)

Kurtis Rader
Kurtis Rader

Reputation: 7469

Create functions that are run when the fish_preexec and fish_postexec event is fired. See http://fishshell.com/docs/current/commands.html#function

Also, to get the most recently run command use history -n1.

Upvotes: 1

Related Questions