How to make Ubuntu have a nice bash shell like OpenSuSE

There are two features of OpenSuSE that I love when logging in to the command line, that do not exist in Ubuntu. Problem is, I’m renting web servers from Amazon, and those are Ubuntu. So I log in to them with ssh, and the bash completion features I want are not there. This post will be documentation of how to get back to the settings I want.

Apparently, theses used to be the settings that most Linux distributions came with. But someone somewhere decided they had a better (in my opinion: worse) plan, and the rest of the world didn’t push back. Well, except for OpenSuSE. Since I cut my teeth on SuSE, I grew to really like those features, and badly miss them when I’m on a Ubuntu box.

First up: change the editor to VIM

On these new boxes, the file ~/.bash_profile does not exist. That’s fine; Ubuntu will read it on login if it does exist.

vim ~/.bash_profile

Get into insert mode with <ins>

export EDITOR=vim

Because the presence of .bash_profile breaks .bashrc (used later), add this to .bash_profile:

[ -r $HOME/.bashrc ] && source $HOME/.bashrc

Save and exit VIM with <esc> : w q

Now, if you are looking at a file with “less” and you want to then edit it, you can hit the letter “v” and be editing the file.

I imagine that way back when, “v” was a way to think “VIM”; but once Ubuntu changed it’s default to the nano editor, that doesn’t really map any more. This changes it back.

Second up: alias the change directory command up-one-level to ..

vim ~/.bashrc

Find the list of alias commands, and move to the bottom line in the list of aliases, and do a “yank”, then a “paste” in VIM:

yy
p

Then get into edit mode by hitting the <ins> key, and modify the pasted command to be this:

alias ..='cd ..'

Get out of insert mode with <esc> and :wq to write the file and quit VIM

If you exit your ssh session, and log back in, the .. command should now take you up one level in the directory hierarchy. Much nicer than having to type cd ..

Third up: bash history search command

We will be editing /etc/inputrc

The tricky part here is that /etc/inputrc is a system file, and attempting to edit it warns that I won’t be able to write and quit. I don’t have permission to edit this file. The solution is to edit it with permissions:

sudo vim /etc/inputrc

Nicely enough, the commands I want are already there; they are merely commented out:

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

All I have to do is to delete the “#” character that declares \e[5~ and \e[6~ to be a comment. With VIM, this is the x key

Leave a Reply