1

I want to do:

alias go=cd $(go.py $1)

then run

?> go home

go.py prints some directory (/my/special/home), which is used by cd to go to that location. But, it doesn't work. If I change the alias to:

alias go=cd $(go.py home)

it works fine, but I want it to be a bit more configurable. Something with the syntax I don't understand I assume.

1
  • I think your first deal is going to literally spit out, if you type "go home", cd $(go.py $1) home Commented Aug 25, 2017 at 0:07

1 Answer 1

3

Use a function instead of an alias:

function go() { cd "$(go.py "${1}")" } 
Sign up to request clarification or add additional context in comments.

2 Comments

I tried something like that, but didn't use the curly braces for the argument. If you know, how does bash parse those?
Actually it doesn't matter here. You could also use "$1". The curly braces are good when you use variable names like ${FOO_BAR}. If you would use $FOO_BAR it is unclear if the variable is called FOO_BAR or if you expand the variable FOO and append the string _BAR. That's why it is a good habit to use curly braces.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.