Results 1 to 5 of 5

Thread: cd into shortcuts

  1. #1
    Join Date
    Dec 2011
    Beans
    25

    Smile cd into shortcuts

    Hi all,

    So I have created a shortcut called thesis on my (dont know the proper name) folder explorer. I want to cd into this without actually typing in the long folder path into it in the terminal.

    i.e. can I do:
    cd thesis
    as opposed to cd ~/home/long/directory/path/thesis

    Thanks,
    Sachin

  2. #2
    Join Date
    Feb 2007
    Location
    Norway
    Beans
    51
    Distro
    Ubuntu Development Release

    Re: cd into shortcuts

    if you add a line to your ~/.bashrc like this:
    Code:
    alias goto-thesis=cd ~/home/long/directory/path/thesis
    Swith ~/home/long/directory/path/thesis with the actual path.

    Then you can just type goto-thesis in the terminal to go there. (You have to close and reopen the terminal after having added that line to $HOME/.bashrc).

  3. #3
    Join Date
    Jan 2012
    Beans
    342

    Re: cd into shortcuts

    Sachin ...

    I don't know that bash supports this but with zsh I can cd deep into a directory tree like so:

    Code:
    % mkdir -p long/directory/path/thesis
    % cd */**/thesis
    The problem with an alias is that it actually doesn't save that much typing.

    Code:
    % cd l<tab>d<tab>p<tab>t<tab>
    There are also other methods of shortening the path, we could use 'ln' to make a (symbolic) link (which is as reusable as an alias).

    Code:
    % ln -s long/directory/path/thesis thesis
    % cd thesis
    best ... khay

  4. #4
    Join Date
    Oct 2006
    Location
    New York
    Beans
    1,118
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: cd into shortcuts

    +1 for linking.
    xubuntu minimal, extensive experience, lshw: http://goo.gl/qCCtn
    blog: http://goo.gl/yLg78
    Linux viruses: http://goo.gl/6OCKA

  5. #5
    Join Date
    Jan 2011
    Location
    US
    Beans
    75
    Distro
    Ubuntu Development Release

    Re: cd into shortcuts

    Quote Originally Posted by Sachin_ruk View Post
    Hi all,

    So I have created a shortcut called thesis on my (dont know the proper name) folder explorer. I want to cd into this without actually typing in the long folder path into it in the terminal.

    i.e. can I do:
    cd thesis
    as opposed to cd ~/home/long/directory/path/thesis

    Thanks,
    Sachin
    The folder explorer is Nautilus
    MOBO: Gigabyte Ga-ma770-ud3 rev.2
    RAM:G.Skill 4x2gb = 8gb of 1066 mhz
    CPU: AMD Phemnom 955 Slight overclock 3.2GHZ Quad Core
    GPU: Nvidia 9800 512 mb

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •