Shell Tweaks
Setting Alias :
Aliases are abbreviations for commands or sets of commands. Example :
alias h= 'history' now Entering h in shell will execute the history command.
alias ls ='ls -l'
you can set these in .bashrc so that every time you login these aliases will be set
to delete the previous alias definitions issue the commands:
unalias h
Defining Functions :
Functions can also be used to ensure that graphical commands always open in the background:
this can be defined in .bashrc
function gimp
{
command gimp "$@" &
}
Now every time you do gimp it will load it in backgroun automatically.
Searching history :
history n
this will print history of last n commands
for searching it CTRL + R can be user
Directory Name Typos
When changing directory small typos can be ignored by Bash
Enable this in .bashrc
shopt -s cdspell
Bash will cope with each component of the typed path having one missing character, one extra character, or a pair of characters transposed:
$ cd /vr/lgo/apaache
/var/log/apache
Directory Bookmarks
Some directories are changed to more frequently than others.
Can avoid typing their full paths if their parents are in $CDPATH
write this in .bashrc
CDPATH='.:..:../..:dir1:~:~/projects:/var/www/virtual_hosts'
now if dir2 is in projects directory then you can do
cd dir2
~/projects/dir2
It will go to dir2 due to CDPATH
env Lists all environment variable
Commands to be executed on opening shell should be written in .bashrc
Commands to be executed on logout should be written in .bash_logout
For changing the way prompt looks you can set variable PS1
Updated :
Enhancing the System Prompt change PS1 variable
More About Shell
CTRL + L will clear the screen
CTRL + T will interchange last two letter of a command
1 comment:
"More about shell" vala link sahi kar dena.
I guess the middle click would have pasted it twice :p
Post a Comment