How to query current tab name of tabbed GUI terminals (any)
1
vote
1
answer
284
views
Using tmux, I have implemented a work flow in which I set a virtual home-directory for each "window" I create in tmux. I can query the name of the current window with
I would like to do the same kind of "per tab home directory" in a GUI terminal. But I need to query the name of the current tab so I can look up the home-dir in my simple DB. I can't find a way to query tab names. I prefer xfce4-terminal, but I am open to others. Thanks! --Myles
display-message -p '#W'
. So I pretty easily implement my system as shown in the code below. You get the idea.
**QUESTION**I would like to do the same kind of "per tab home directory" in a GUI terminal. But I need to query the name of the current tab so I can look up the home-dir in my simple DB. I can't find a way to query tab names. I prefer xfce4-terminal, but I am open to others. Thanks! --Myles
alias cdh 'cd ~/bin/get_tmux_window_home_dir
'
% cat ~/bin/get_tmux_window_home_dir
#!/usr/bin/ruby
$VERBOSE = nil
window = tmux display-message -p '#W'
.chomp
if ! $?.success?
STDERR.puts "Error: tmux display-message -p '#W' failed."
print 'XXXXX'
exit 1
end
db_file = "/home/#{ENV['USER']}/.config/tmux_window_home_dir/tmux_window_home_dir.csv"
db = {}
if File.exists?(db_file)
File.readlines(db_file).each do |l|
s = l.split(',')
db[s] = s
end
end
if db[window]
print db[window]
else
STDERR.puts "Error: There is no home directory set for tmux window name '#{window}'"
print 'XXXXX'
end
Asked by Myles Prather
(53 rep)
Aug 10, 2021, 08:28 PM
Last activity: Jul 3, 2024, 02:59 PM
Last activity: Jul 3, 2024, 02:59 PM