Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't go into a subshell, just cd #29

Closed
RobertAudi opened this issue Aug 18, 2014 · 5 comments

Comments

@RobertAudi
Copy link

commented Aug 18, 2014

It would be cool if ghq look just ran cd ... instead of going into a subshell. (The subshell feature annoys me actually...). Or at least add a configuration for it?

@syohex

This comment has been minimized.

Copy link
Contributor

commented Aug 19, 2014

Overwrite SHELL environment variable when ghq look is invoked.

% SHELL=true ghq look ghq
@motemen

This comment has been minimized.

Copy link
Owner

commented Aug 19, 2014

I'd like to, but I don't think ghq can change the shell's working directory since it is just a command, not a shell function. Any ideas to implement that?

One solution would be providing a shell function like:

ghq () {
    if [ "$1" = look -a -n "$2" ]; then
        cd $(command ghq list -p $2)
        return
    fi

    command ghq "$@"
}
@RobertAudi

This comment has been minimized.

Copy link
Author

commented Aug 19, 2014

@motemen the shell function works perfectly! Thanks a lot 👍

(Should have thought of that before asking... 😒)

@motemen

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2014

I'm glad 🙆

@motemen motemen closed this Aug 20, 2014
@vlaw

This comment has been minimized.

Copy link

commented May 9, 2017

The shell function is great.
But if you have some projects whose names are like below,

$ ghq list --unique vue
vuerify
vue

Executing ghq look vue will get into the wrong directory.

So, I change the function a little, just in case someone encounter the same problem.

ghq () {
    if [ "$1" = look -a -n "$2" ]; then
        cd $(command ghq list -e -p $2) 
        return
    fi

    command ghq "$@"
}

add -e to do an exact match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.