Skip to main content
Rollback to Revision 1 - Edit approval overridden by post owner or moderator
Source Link
Bernhard
  • 12.4k
  • 4
  • 60
  • 70

I amIt is not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

IfIn case you have more choices, you could better use a case structure may be better.

I am not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

If you have more choices, a case structure may be better.

It is not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

In case you have more choices, you could better use a case structure.

It isI am not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

In caseIf you have more choices, you could better use a case structure may be better.

It is not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

In case you have more choices, you could better use a case structure.

I am not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

If you have more choices, a case structure may be better.

Source Link
Bernhard
  • 12.4k
  • 4
  • 60
  • 70

It is not completely sure what you are asking, but an alias just expands to what is in the alias. If you have two aliases, you can append the different commands, even aliases.

alias "foo=cd /path/to/foo; go"
alias "foo2=cd /path/to/foo2; go"

In any other situation, you could specify a function in your .bashrc

function go ()
{
    if [ "$PWD" == "/path/to/foo" ]; then
       cmd1
    elif [ "$PWD" == "/path/to/go" ]; then
       cmd2
    fi;
}

In case you have more choices, you could better use a case structure.