Skip to main content

I have the below function which will create alias on the fly,

s () {
        if [[ "x$1" != "x" ]]
        then
                alias $1="cd $PWD;pwd"
                echo "alias $1=\"cd $PWD;pwd\""
        else
                echo "Usage: s[s] <directory bookmark name>"
                return 1
        fi
}

When I want to bookmark a directory, I just type s dirName. This creates a alias like alias dirName="cd /my/current/directory/;pwd". so I can come back to this directory by just typing dirName. I have a version which saves it into bash_aliases as well. This works in any shell.

I have the below function which will create alias on the fly,

s () {
        if [[ "x$1" != "x" ]]
        then
                alias $1="cd $PWD;pwd"
                echo "alias $1=\"cd $PWD;pwd\""
        else
                echo "Usage: s[s] <directory bookmark name>"
                return 1
        fi
}

When I want to bookmark a directory, I just type s dirName. This creates a alias like alias dirName="cd /my/current/directory/;pwd". so I can come back to this directory by just typing dirName. I have a version which saves it into bash_aliases as well. This works in any shell.

I have the below function which will create alias on the fly,

s () {
    if [[ "x$1" != "x" ]]
    then
        alias $1="cd $PWD;pwd"
        echo "alias $1=\"cd $PWD;pwd\""
    else
        echo "Usage: s[s] <directory bookmark name>"
        return 1
    fi
}

When I want to bookmark a directory, I just type s dirName. This creates a alias like alias dirName="cd /my/current/directory/;pwd". so I can come back to this directory by just typing dirName. I have a version which saves it into bash_aliases as well. This works in any shell.

Source Link
balki
  • 4.7k
  • 6
  • 32
  • 47

I have the below function which will create alias on the fly,

s () {
        if [[ "x$1" != "x" ]]
        then
                alias $1="cd $PWD;pwd"
                echo "alias $1=\"cd $PWD;pwd\""
        else
                echo "Usage: s[s] <directory bookmark name>"
                return 1
        fi
}

When I want to bookmark a directory, I just type s dirName. This creates a alias like alias dirName="cd /my/current/directory/;pwd". so I can come back to this directory by just typing dirName. I have a version which saves it into bash_aliases as well. This works in any shell.