Hacker News new | past | comments | ask | show | jobs | submit login

Simple bashrc function

    # go up X directories
    up_dir() {
        num_of_dirs=$1
        for i in $(seq 1 $num_of_dirs)
        do
            cd ..
        done
    }
    alias up=up_dir
Usage:

    $ pwd
    /home/user/svn/automation/puppet/trunk/modules/ossec/templates
    $ up 4
    $ pwd
    /home/user/svn/automation/puppet



    # Hah, I have almost the exact same thing in my bash_profile
    up () {
        TIMES=${1:-1};

        for ((i=1; i<=$TIMES; i++));
        do
            cd ..
        done
    }
EDIT: Although now I'm looking at it and it looks like I made a strange choice with `TIMES=${1:-1};`. Oh well, I think it was my first bash script... it's funny to look back at the hack-y crap that your bash_profile accumulates over time.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: