Change konsole session name

Various KDE 1.-4. Improvements

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

4
4 .8
Description:

This little script on your ~/.bashrc will change the konsole session name on the fly. Also will put the remote host name if you connect it with ssh wraper kssh.

This can serve you to make more interesting things.

The screenshot is the original 5 minutes script.
Last changelog:

16 years ago

0.21:
-Bug fix: now "really" works for root

0.2:
-No magic in konsole detection: use of KONSOLE_DCOP_SESSION enviroment variable
-Only change konsole name only when needed
-Implemented the wintermte's idea as a internal function. Called kssh

0.1:
-Initial release.

4

marycstewart

1 year ago

4 4 soso

Report

bk12

16 years ago

Looks similar to this one:

http://kde-look.org/content/show.php?content=6976

Report

Traktopel

16 years ago

When I su.. I get "bash: touch_konsole: command not found" upon running _any_ command with root.

Any ideas?

Report

C

mrthc

16 years ago

you must put the code in root's bashrc.

Report

romvinot

16 years ago

I like this little script and it has already been added to my bashrc.

Could it be possible to get only the last 3 directories instead of the whole path (from $HOME) ?

Report

C

mrthc

16 years ago

Can you explain better? write here or mail me thc{at}wanadoo{dot}es.

Thanks

Report

pdreker

16 years ago

I am not the original poster, but I think what he means is that only the last 3 components of the path should be used to rename the konsole session.

I have a rather deep directory structure here and using your script would sometimes rename my konsole session to e.g. "~/Desktop/Development/Debian/Packages/somepackage-1.2.3/debian" which is a little bit too long to be really useful (the tabs become really wide)...

Using only the last 2 or 3 components the session would be renamed to "Packages/somepackage-1.2.3/debian" or "somepackage-1.2.3/debian". Still rather long but better than the aforementioned name ;-)

One usually knwos where approximately one is in one's own dir structure, so one only needs a short reminder which session is where. The complete path is uneccessary IMO...

Report

wintermte

16 years ago

I have a possible enhancement for this that can rename the Konsole session when you ssh to another host to the remote host name.

Try this in the .bashrc (mostly the same):
# Look if the parent is konsole
dcop konsole-$PPID &> /dev/null
if [ $? -eq 0 ]; then
#OK we are on konsole
PROMPT_COMMAND=touch_konsole
export INKONSOLE=$PPID
else
export INKONSOLE=0
fi#!/bin/sh
# Look if the parent is konsole
echo $INKONSOLE
if [ $INKONSOLE -gt 0 ]; then
#OK we are on konsole
CURRENT_SESSION=`dcop konsole-$INKONSOLE konsole currentSession`
dcop konsole-$INKONSOLE $CURRENT_SESSION renameSession "$1"
fi

/usr/bin/ssh -X $1 # the -X is optional

alias ssh="~/bin/ssh"


Create a script in ~/bin/ called ssh which contains:

#!/bin/sh
# Look if the parent is konsole
echo $INKONSOLE
if [ $INKONSOLE -gt 0 ]; then
#OK we are on konsole
CURRENT_SESSION=`dcop konsole-$INKONSOLE konsole currentSession`
dcop konsole-$INKONSOLE $CURRENT_SESSION renameSession "$1"
fi

/usr/bin/ssh -X $1

Report

aplsin

16 years ago

Very nice script, really like it!
Btw, do you know if theres any way to make this work when you su to root too?

Report

C

mrthc

16 years ago

use "su -m" or put an alias in your .bashrc

alias su="su -m"

like I have

Report

aplsin

16 years ago

thaht didn't work.. :/

Report

16 years ago

0.21:
-Bug fix: now "really" works for root

0.2:
-No magic in konsole detection: use of KONSOLE_DCOP_SESSION enviroment variable
-Only change konsole name only when needed
-Implemented the wintermte's idea as a internal function. Called kssh

0.1:
-Initial release.

12345678910
1
product-maker marycstewart Nov 27 2019 4 soso
4 soso
Be the first to comment
donnarflores
Mar 17 2020
jennifergsmedley
Mar 13 2020
marycstewart
Nov 27 2019
parcox
Feb 17 2013
File (click to download) Version Description PackagetypeArchitecture Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
updated Mar 24 2004
added Mar 22 2004
downloads 24h
0
mediaviews 24h 0
pageviews 24h 1