Affichage des articles dont le libellé est bash. Afficher tous les articles
Affichage des articles dont le libellé est bash. Afficher tous les articles

jeudi 29 octobre 2009

visually identify ssh session console tabs

add this to the server user's .bashrc :

if [ "x$SSH_CONNECTION" != "x" ]; then
export PS1="\[\033[01;35m\][ssh]\[\033[00m\]$PS1"
fi


It will prepend your server prompt with [ssh] allowing you to visually identify when you're on a shell session on it. of course you could just color the hostname or something else, but you get the idea. sometimes a visual cue is better than having the hostname in the prompt.

mardi 27 octobre 2009

annoying ^C (control C) echoed in bash shell

Starting with bash 4.0*, hitting ^C (control+c) in the Konsole prints out ^C and potentially overwrites command history. For those of you, dear readers, that think that this is really annoying and lame, there is a workaround.

add

stty -echoctl

in your ~/.bashrc.
That's it.

Other control chars such as ^Z will not be displayed anymore, but i hate that much less than i hated ^C.

samedi 22 mars 2008

Konsole & Repertoires de travail

j'ai récemment trouvé pénible que la Konsole ne mémorise pas le répertoire courant lors de l'ouverture d'un nouvel onglet.

Il se trouve que la solution est très simple, et a l'avantage de marcher même après un reboot.
Etant donné que le .bash_profile est lu à chaque ouverture d'onglets, il suffit d'y placer les commandes suivantes :

cherchez PROMPT_COMMAND et éditez le de la sorte :

PROMPT_COMMAND='echo `pwd` > ~/.oldpwd ; history -a'

puis,
à la fin du .bash_profile ajoutez :

#Reset workdir to last one used
cd `cat ~/.oldpwd`

Les choses se passent. Les nouveaux onglets auront le dernier repertoire cd'ifié comme répertoire de départ. L'info étant écrite sur disque, la première Konsole après redémarrage s'ouvrira avec le dernier répertoire cd'ifié avant l'arrêt de l'ordinateur.