ifacethoughts

Browsing Directories And Files With Command Line

I am a command line fan! I use the terminal for working with files and directories. The directory stack tools – pushd, popd and dirs are superstars compared to what we get from the modern file managers.

In addition to this the shell has some more tricks up its sleeve.

CDPATH

CDPATH lets you set multiple base directories. By default, you have to provide relative path from your current directory to the new directory. Sometimes these relative paths can be long and can cause errors.

By using CDPATH you can ask the shell to look for the directories you have mentioned in additional directories. For example, if I have /home/anadgouda/projects/blog and /home/anadgouda/projects/xfce and I do CDPATH=.:~/projects, I can use cd blog and cd xfce to change to blog or xfce from anywhere in my file system, as an absolute path. This will help you a lot for those frequently used directories.

shopt -s cdspell

shopt is a way of controlling optional shell behaviour. This command will correct the name automatically when you miss a character in the name or change the case. Though it handles minor errors it is plenty helpful in being productive.

set completion-ignore-case-on

You can add this command to your ~/.inputrc file and the shell will make the autocompletion case-insensitive. Personally, I prefer the case sensitivity, but if you think otherwise, use this and get it done your way.

set show-all-if-ambiguous on

If you are irritated by having to press TAB twice to list possibilities, this command will rescue you. Put this in your ~/.inputrc and the shell will list the matches immediately.

And since this is based on the bash shell, you can use this on all OSs that support it, like Unix systems, Macs and I guess Cygwin as well. Try these out and see if you get more productive with your command line.

Discussion [Participate or Link]

  1. Amit said:

    This is really useful.. actually you can post a series of such good command line tutorials. At least post once in a week….Thanks & Regards….

  2. Using The export Shell Command | iface thoughts said:

    […] to work properly, exporting some others might have side-effects. For example, exporting the CDPATH variable might cause some scripts to unpredicted behaviour from programs which assume that the […]

  3. Harrison Powers said:

    This post has vastly improved my shell efficiency. Please keep up the great work

  4. Maxim said:

    This is helpful for people like me who always forget the command line commands … Good work

    Maxim
    InoVVorX

  5. Programming » Blog Archive » Using The export Shell Command said:

    […] to work properly, exporting some others might have side-effects. For example, exporting the CDPATH variable might cause some scripts to unpredicted behaviour from programs which assume that the […]

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
My bookmarks

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.