First, you have something contradictory in your question. You said, "it started to show user@hostname: ~/currentdir
in its title, changing it whenever I cd
to another directory", but the image attached said something else. I am almost sure that if you've selected "Replace initial title" setting in gnome-terminal's preferences and if you use this ~/.bashrc file as you said, your terminal should look like in the following image:
Second, you're totally wrong with: "vim, for example, sets current filename as a title". To do this, you must to heve a file named .vimrc
in your home directory with the following code inside:
let &titlestring = $USER . "@" . hostname() . ": vim " . expand("%:t")
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
And one more thing: I don't understand yet exactly for what do you using that if
from the 11th line until 40th line in your .bashrc
file, but setting up TERM="gnome-256color"
at the line 33 may be a problem in this case. So, I suggest you to comment that line, or to remove all the code between lines 11 and 40.
After all of this done, when you will use vim
, your terminal should look like:
[ for gnome-terminal ]
use stty
tool, good for visualzing what bash
keyboard shortcuts are binded.
see your current bash keyboard shortcuts (my system output):
stty -a
my output:
speed 38400 baud; rows 41; columns 76; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon
-ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
werase
is responsbile for deleting an entire word.
running this will set ctrl
+ backspace
to erase a word when pressed.
stty werase \^H
!note: this will set this option only
to your current terminal/bash session. in order to apply this permanently
you need to add previous command to .bashrc
file at the end of it.
settings from .bashrc will be loaded every time you open gnome-terminal.
after this you are ready to go. enjoy.
Best Answer
You were well advised not to change your startup scripts, specially
~/.bashrc
. Any "terminal detection" using current$TERM
or$COLORTERM
in~/.profile
is merely a guess, and may, as you said, cause trouble when using other terminals (say, Putty or xterm). The terminal emulator is supposed to set$TERM
, and this should not be changed from within the shell.Gnome terminal, AFAIK, does not offer a configuration to change its
TERM
, but it does allow you to change your startup command, and that's all you need. Here is the trick:Then use the following command:
Just replace
/bin/bash
with your preferred shell if it's different. And no, you can't use"$SHELL"
in that line for shell auto-detection ;) You have to hard-code it