1

I have a python script I want to use for navigation. it returns a directory path ex /user/bin/dir/ I am making an ailas to it but I cant seem to pass it variables

this works in a shell

> cd `python ~doug/scripts/nv.py arg1
>>/user/bin/dir/

alias nav='cd python ~doug/scripts/nv.py $1' but this alias doesn't work

I would expect arg1 gets passed to $1

1
  • err cd python ~doug/scripts/nv.py arg1 Commented Jan 26, 2013 at 23:46

1 Answer 1

2

bash aliases cannot take parameters; you want to use a shell function instead:

nav () {
    cd $(python ~doug/scripts/nv.py $1)
}
Sign up to request clarification or add additional context in comments.

1 Comment

Depending on the script, you might want cd "$(python ~doug/scripts/nv.py "$@")" to pass all arguments instead of just the first, and also avoid trouble if the script outputs paths with spaces or glob characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.