I use libtmux and libtmux uses subprocess.Popen() to invoke Tmux to control session, windows and panes. To set a pane titel Tmux requires to send an escape sequens. This works on command line as expected:
tmux send-keys -t 0 " printf '\033]2;%s\033\\' 'Pane Title'" C-m
When this command is issued by subprocess.Popen() or os.system() - may be others too, I've only tested these two - the escape squence does not make it to the shell. I logg the command sent to a file and the values in the log file are correct but when sent only this survives:
printf '2;%s' 'Pane Title'
I've tested this by executing this command:
echo "printf '\033]2;%s\033\\' 'Pane Title'" > /tmp/setname
The content of /tmp/setname is the above.
The methode finally used is tmux_cmd and I call it via send_keys like this:
p.send_keys("printf '\033]2;%s\033\\' '" + names[i] + "'")
where "p" is the pane object. See my post here .
My question is: How to issue shell commands with escape sequences in Python?
"raw prefixes" was what I've missed! Thanks Jean-François Fabre !
This works:
p.send_keys(r"printf '\033]2;%s\033\\' '" + names[i] + "'")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.