Posts Tagged ‘cli’
There are some settings that are very useful if you work on the terminal a lot. Many of the cool ones are not enabled by default – this is a small list of the configuration settings that I use to make my terminal usage more productive.
This is part 3 of the Customizing the Terminal series. Already published posts in this series are…
1. Case Correction
I like to title case my folders and files’ names. The folders in my home are ‘Scripts’, ‘Documents’, ‘Temp’ etc. The first character is in upper case. But when I work on the command line, I don’t always remember to uppercase the first character when trying to cd into a folder. Consequently, the tabbing will not work. Fortunately, there is an option that auto corrects the case for you. Just open a terminal and type in this command…
shopt -s nocaseglob
Other useful shopt option are…
- Corrects typos in your file/directory name.
- Makes sure that histories in multiple simultaneous shells don’t overwrite each other.
2. Select Which Commands to Store in History
By default, all commands you type in are stored in the history. You can pick and chose the commands you want to store by putting the option…
~/.bash_profile file. This will make sure that bash don’t store any command beginning with the space character. So if you want bash to forget that you typed in ‘ls’, just type in ‘ ls’(<space>ls).
3. Don’t Store Duplicate Commands in your History
As I said earlier, all commands you type are stored – even the duplicate ones. You can prevent this by putting this text in your
If you want to ignore spaced commands and want to prevent storing of duplicate commands, use the option…
4. Auto-complete Command from History
Picture this – you type in ‘ssh’ and press the ‘Page Up’ key – and bash automatically fetches the last command that starts with ssh – and completes the command for you. Well, its possible – add the following line in your ‘.bash_profile’ file…
Now, create a file called
.inputrc in your home and enter this into it…
#Page up/page down "\e[5~": history-search-backward "\e[6~": history-search-forward
Yes, I am aware of the up Ctrl+R trick – that comes in the next post.
5. Infinite History
You can increase or decrease the size of the history by adding this line in the
export HISTSIZE=500 export HISTFILESIZE=500
This will limit the commands to be stored in the history to 500. If you want to remove the limit use these lines…
unset HISTSIZE unset HISTFILESIZE
There is a good chance that this will make your history file quite huge – use with care.
Please share your configuration settings for bash in the comments.
Tags: bash, cli, command, Configuration, history, power, setting, user
Posted in Command Line, Configuration | 6 Comments »
This is part two of the ‘Customizing the Terminal’ series. Part one is ‘Customizing the Terminal: The Prompt‘. In this part, we’ll see how to create aliases to make working in the console easier.
How To Create an Alias
You can create a temporary alias using this command…
alias new_name='old command'
This will stop working when you exit the terminal. If you want to make the alias permanent, put the same command in your
There is another way to create an alias – create a executable file and place it in a folder in your path. This is not technically an alias – but it works the same way. I use this for alias that tend to change often. Its easier to find a file in a folder and edit it. YMMV.
This is a incomplete list of the aliases I use. Feel free to copy them to your .bashrc file.
Quick Directory Jumps
Create an alias to jump to folders you have to visit often. This is my list…
alias www='cd /var/www/html' alias e='cd /mnt/x'
The above jumps are absolute jumps – relative jumps are possible too…
alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..'
Some prefer this syntax…
alias ..='cd ..' alias ..2='cd ../..' alias ..3='cd ../../..' alias ..4='cd ../../../..'
Often Used Commands
If you use some commands a lot, create smaller alternative for it…
alias x='exit' alias q='exit' alias rmdir='rm â€“rf'
Many of my own scripts are also alias’ed this way…
alias bk='perl "/home/binnyva/Scripts/Perl/Maintenance/Rsync Backup/RsyncBackup.pl"' alias rbk='perl "/home/binnyva/Scripts/Perl/Maintenance/Rsync Backup/RsyncRemoteBackup.pl"' alias nbk='perl "/home/binnyva/Scripts/Perl/Maintenance/Rsync Backup/RsyncNetworkBackup.pl"' alias bdb='perl "/home/binnyva/Scripts/Perl/Maintenance/Database Backup/Dbbackup.pl"'
Create a short version of long and complex command using alias…
alias gitstat='git status | perl -pe "exit if(/Untracked files\:/)"' alias ra='ruby script/server' alias wikipedia='cd /mnt/x/Data/Wikipedia/mywiki; firefox "http://localhost:8001/"; python manage.py runserver 8001; ' alias sup='svn update'
When I came from Windows to Linux, I was used to the dos commands – but not to the linux’s mv,cp commands. So I used to have aliases for those(I don’t have these now)
alias move='mv' alias copy='cp' alias ren='mv' alias del='rm'
If you go from Red Hat/Fedora to Debian/Ubuntu(or vise versa), you can set up a few alias to make the change easier…
You can get a lot of ideas for more aliases by looking at others .bashrc files.
Now tell me you aliases…
Tags: alias, cli, command, customize, terminal
Posted in Command Line, Configuration | 15 Comments »
So far we looked at the GUI MP3 Players for linux – like Amarok, Exile, XMMS etc. Most linux users need only that – but there are some people who want a simpler system – command line players. The two top players in this area are mpg123 and mpg321.
mpg123 is a fast, free, minimalist, console MPEG audio player software program for UNIX and Linux operating systems. The development on this project ceased for a long time – but now it has a new maintainer.
mpg321 is a clone of mpg123.
Most distros have mpg321 in their repositories(not all have mpg123) – so just log in as root and use these commands to install it…
yum install mpg321 – For RedHat, Fedora, CentOS etc.
apt-get install mpg321 – For Debian, Ubuntu, etc.
Using mpg321 is straight forward. Since it has no GUI, just go to the folder with the song and just execute the command…
If you want to play all the songs in a folder, you have to create a list of files in that folder. Then you have to specify this list as an argument for the mpg321 command. These commands can get the job done…
Create a list of all MP3 Files in the current folder…
find . -name "*.mp3"|sed 's/\.\///;'|sort>List.lst
Use this list as the play list for mpg321
mpg123 --list List.lst
Why Use Command Line Players?
If we have a number of shiny GUI players, why should one use a command line player? Unless you are an anti-GUI command line guru, chances are you don’t need it. But still, it has its uses.
For example, if you have to restart the X Server often for some reason, then mpg321 is the best player for you. All other player will stop playing when X server is down.
This actually happend to me – when I bought my second LCD screen, it took me some time to configure it. And that meant editing the
xorg.conf file and restarting the X Server to see if it worked. At that time, I opened a virtual terminal(Ctrl+Alt+F1) and opened mpg321 with a bunch of MP3s in the list. It kept playing even if the X server is down. This is propably the reason that I was still sane after around six hours of XOrg configuration.
Tags: cli, mp3, mpg123, mpg321, player, review
Posted in Audio, Command Line, Tools | 11 Comments »