How do I create a symbol to represent a path to easily cd into a directory?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?







share|improve this question

















  • 1




    Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
    – slm♦
    Jul 5 at 19:06










  • Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
    – Cyrus
    Jul 5 at 19:08















up vote
1
down vote

favorite












In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?







share|improve this question

















  • 1




    Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
    – slm♦
    Jul 5 at 19:06










  • Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
    – Cyrus
    Jul 5 at 19:08













up vote
1
down vote

favorite









up vote
1
down vote

favorite











In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?







share|improve this question













In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?









share|improve this question












share|improve this question




share|improve this question








edited Jul 5 at 18:58









Jeff Schaller

30.8k846104




30.8k846104









asked Jul 5 at 18:54









thecommonwealthcollective

82




82







  • 1




    Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
    – slm♦
    Jul 5 at 19:06










  • Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
    – Cyrus
    Jul 5 at 19:08













  • 1




    Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
    – slm♦
    Jul 5 at 19:06










  • Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
    – Cyrus
    Jul 5 at 19:08








1




1




Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
– slm♦
Jul 5 at 19:06




Related - unix.stackexchange.com/questions/31161/…. This Q&A has a whole host of tools to help navigate directories via CLI.
– slm♦
Jul 5 at 19:06












Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
– Cyrus
Jul 5 at 19:08





Put this to your .bashrc: [[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
– Cyrus
Jul 5 at 19:08











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Two options come to mind:




  • Use a variable:



    w="/my/working/directory"
    cd "$w"



  • Use an alias:



    alias cdw='cd /my/working/directory'
    cdw






share|improve this answer






























    up vote
    2
    down vote













    You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.



    mkdir ~/dir_aliases
    ln -s /path/to/alias ~/dir_aliases/@
    ln -s /another/path ~/dir_aliases/%
    ...


    Then add this dir to CDPATH (probably in .bashrc or similar)



    CDPATH=~/dir_aliases


    Typing



    cd @


    will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to



    cd $(readlink -f .)


    to see the real path.)






    share|improve this answer





















    • cd -P is a simpler way than using readlink to use the real path.
      – jamesdlin
      Jul 18 at 7:54










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453710%2fhow-do-i-create-a-symbol-to-represent-a-path-to-easily-cd-into-a-directory%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Two options come to mind:




    • Use a variable:



      w="/my/working/directory"
      cd "$w"



    • Use an alias:



      alias cdw='cd /my/working/directory'
      cdw






    share|improve this answer



























      up vote
      1
      down vote



      accepted










      Two options come to mind:




      • Use a variable:



        w="/my/working/directory"
        cd "$w"



      • Use an alias:



        alias cdw='cd /my/working/directory'
        cdw






      share|improve this answer

























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Two options come to mind:




        • Use a variable:



          w="/my/working/directory"
          cd "$w"



        • Use an alias:



          alias cdw='cd /my/working/directory'
          cdw






        share|improve this answer















        Two options come to mind:




        • Use a variable:



          w="/my/working/directory"
          cd "$w"



        • Use an alias:



          alias cdw='cd /my/working/directory'
          cdw







        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Jul 12 at 16:11









        Kusalananda

        101k13199312




        101k13199312











        answered Jul 5 at 18:58









        nohillside

        1,856616




        1,856616






















            up vote
            2
            down vote













            You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.



            mkdir ~/dir_aliases
            ln -s /path/to/alias ~/dir_aliases/@
            ln -s /another/path ~/dir_aliases/%
            ...


            Then add this dir to CDPATH (probably in .bashrc or similar)



            CDPATH=~/dir_aliases


            Typing



            cd @


            will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to



            cd $(readlink -f .)


            to see the real path.)






            share|improve this answer





















            • cd -P is a simpler way than using readlink to use the real path.
              – jamesdlin
              Jul 18 at 7:54














            up vote
            2
            down vote













            You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.



            mkdir ~/dir_aliases
            ln -s /path/to/alias ~/dir_aliases/@
            ln -s /another/path ~/dir_aliases/%
            ...


            Then add this dir to CDPATH (probably in .bashrc or similar)



            CDPATH=~/dir_aliases


            Typing



            cd @


            will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to



            cd $(readlink -f .)


            to see the real path.)






            share|improve this answer





















            • cd -P is a simpler way than using readlink to use the real path.
              – jamesdlin
              Jul 18 at 7:54












            up vote
            2
            down vote










            up vote
            2
            down vote









            You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.



            mkdir ~/dir_aliases
            ln -s /path/to/alias ~/dir_aliases/@
            ln -s /another/path ~/dir_aliases/%
            ...


            Then add this dir to CDPATH (probably in .bashrc or similar)



            CDPATH=~/dir_aliases


            Typing



            cd @


            will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to



            cd $(readlink -f .)


            to see the real path.)






            share|improve this answer













            You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.



            mkdir ~/dir_aliases
            ln -s /path/to/alias ~/dir_aliases/@
            ln -s /another/path ~/dir_aliases/%
            ...


            Then add this dir to CDPATH (probably in .bashrc or similar)



            CDPATH=~/dir_aliases


            Typing



            cd @


            will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to



            cd $(readlink -f .)


            to see the real path.)







            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Jul 12 at 16:14









            choroba

            24.1k33967




            24.1k33967











            • cd -P is a simpler way than using readlink to use the real path.
              – jamesdlin
              Jul 18 at 7:54
















            • cd -P is a simpler way than using readlink to use the real path.
              – jamesdlin
              Jul 18 at 7:54















            cd -P is a simpler way than using readlink to use the real path.
            – jamesdlin
            Jul 18 at 7:54




            cd -P is a simpler way than using readlink to use the real path.
            – jamesdlin
            Jul 18 at 7:54












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453710%2fhow-do-i-create-a-symbol-to-represent-a-path-to-easily-cd-into-a-directory%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            The Forum (Inglewood, California)

            Palaiologos