Renaming a Konsole session from commandline after

2019-05-06 18:58发布

问题:

I use dcop to rename a Konsole session, such as

dcop $KONSOLE_DCOP_SESSION renameSession "whatever"

However, when I ssh to a server and from there, I issue this command, it does not work and gives error:

ERROR: Couldn't attach to DCOP server!

Is there a way using dcop or otherwise to rename the Konsole session, even though I have ssh'ed to another computer.

回答1:

The remote server appears not be running dcop and even if it were, that's not the instance you want to be communicating with (dcopserver on the remote host vs dcop on your local host).

You can use XTerm escape sequences to change the title via:

remotehost $ echo -ne "\033]0;Custom Window Title\007"

You can also change the individual tab title via:

remotehost $ echo -ne "\033]30;Custom Tab Title\007"

Another way would be to suspend your current ssh session so that you are back at the login you started.

e.g.

host1 $ ssh host2
host2 $ ~^Z [suspend ssh]

[1]+  Stopped                 ssh host2
host1 $ dcop $KONSOLE_DCOP_SESSION renameSession "whatever"
host1 $ fg
ssh host2
host2 $