Posts tagged ‘bash’

Tip: Keep a command out of your history

terminal.png

If you want an easy way to keep commands out of your ~/.bash_history, do the following:

put this in your .bashrc:

export HISTCONTROL=ignorespace

then in a new bash session when you type in a command, if you put a space before it, it doesn’t appear in your history.

$echo hello #in history

$ echo hello #not in history

Fix Bash Keybindings for Home, End and other keys

terminal.png

Log into a linux box often and find that Home, End, Delete or Ctrl+Arrow keys don’t work?  Well here’s the fix.  Place the following in your ~/.inputrc file

“\e[7~”: beginning-of-line #home
“\e[8~”: end-of-line #end
“\e[3~”: delete-char #delete
“\eOd”: backward-word #ctl-leftarrow
“\eOc”: forward-word #ctl-rightarrow

And then exit bash and reopen a new bash session.

Secondly, if you’re on a machine with multiple (command-line) users, then it makes little sense for everyone to have to create the same “~/.inputrc” file. You need only create one file with those readline settings in it, I suggest “/usr/local/etc/inputrc“, and then point everyone to it by putting this line into “/etc/profile“:

export INPUTRC=’/usr/local/etc/inputrc’

Bash Color Escape Codes

terminal.png

Below is a quick rundown on how to color output of echo in bash.

Continue reading ‘Bash Color Escape Codes’ »

How to have a lightweight, beautiful, functional terminal

terminal.png

I’ve done a lot over the past few months to make my time spent on the command line a bit more enjoyable and easier to use.  Hopefully you’ll find these steps useful as well.

Continue reading ‘How to have a lightweight, beautiful, functional terminal’ »

Bash Completition on Gentoo

gentoo.gif

Here’s how to get a personalized and satisfactory completion on Gentoo installations..

First of all you need an use flag set widely in your system so that every software you are going to emerge (or re-emerge) if is capable will be added to your competition choices. To do so just open our magic make.conf with your favourite editor (I use vim, you can use emacs, nano, pico…i don’t really care about wars)

# vim /etc/make.conf

Continue reading ‘Bash Completition on Gentoo’ »

Bash tip: Instant Spelling Suggestions

terminal.png

Looking to reject the GUI life altogether and restrict yourself to the command line like a real Unix geek? Great! But as soon as you miss the OOo spellchecker, don’t fret: most Linux systems come with the look command built-in, which is a command-line spellchecker. To get started, type look followed by part of a word:

look separ

should show you matches like “separate”, “separately”, and so on, whereas entering:

look seper

will show nothing, because “seperate” is a mis-spelling.  Also, instead of simply entering the command you can use tab completion for look to display a list of possible options.

Bash tip: Selective Deletion

terminal.png

If you have a directory that contains ten subdirectories and you want to delete three of them, the slow way to do it would be like this:

rm -rf /home/tuxtraining/work
rm -rf /home/tuxtraining/projects
rm -rf /home/tuxtraining/sandbox

But that’s pretty darn slow and open to making mistakes – a much smarter way to is to let Bash perform multiple filename expansion by placing the options inside braces. For example, this would achieve the same as the three lines from above:

rm -rf /home/tuxtraining/{work,projects,sandbox}

Bash tip: Autocorrect typos with shopt

terminal.png

Typing on the command line isn’t easy. First, it takes a lot of time to learn how all the commands work, but then even after that you need to be very precise with your file and directory names, otherwise you’ll need to try and try again.

But there’s a way out: Bash has a built-in command called “shopt” that lets you set various command-line options. For example, running shopt -s cdspell enables automatic typo correction for directory names, so that typing cd /hom/hudzila will get you to the nearest match – /home/hudzilla.

You can also use shopt -s nocaseglob so that when you type part of a filename and press Tab to autocomplete, Bash does a case-insensitive search.

Bash Cheatsheet

terminal.png

Tip: Bash Shortcuts

terminal.png

Bash, which is the default shell in Linux contains a whole lot of key bindings which makes it really easy to use . The most commonly used shortcuts are listed below :

Continue reading ‘Tip: Bash Shortcuts’ »

Pages: 1 2 Next