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

Open gitui in a given directory (gitui --cd=xyzdir/) #73

Closed
alistaircarscadden opened this issue May 20, 2020 · 5 comments
Closed

Open gitui in a given directory (gitui --cd=xyzdir/) #73

alistaircarscadden opened this issue May 20, 2020 · 5 comments
Labels
question Further information is requested

Comments

@alistaircarscadden
Copy link
Contributor

alistaircarscadden commented May 20, 2020

Is your feature request related to a problem? Please describe.

I'd like to set the tool up so that when I right click on a directory (in windows) it launches gitui in the clicked directory. To do this I'd need a way to open the program in a different directory.

Describe the solution you'd like

gitui.exe --cd=projectdir to open the tool in the directory called projectdir

Describe alternatives you've considered

The context menu works fine from inside the directory, but with git bash I'm used to clicking on a directory to open that tool, so it would be nice if this tool mirrored that behaviour. This is a low priority thing.

Additional context

image

@extrawurst
Copy link
Owner

hm couldn't that be done using a *.bat that does the cd $1 && gitui ? (sorry I a, no good in windows batch)

@extrawurst extrawurst added the question Further information is requested label May 20, 2020
@alistaircarscadden
Copy link
Contributor Author

alistaircarscadden commented May 20, 2020

To create the 'open w/ gitui' option in the context menu in Windows you create an entry in the Registry Editor. There are different registry keys for what appears in the context menu when you click inside a folder vs. when you click on a folder.

When you click inside of a folder, the gitui can be opened with no extra options, as the directory is already correct. See:

image

However, when you right click on a folder, the system opens the executable given from the current directory and provides the item you clicked on as %1. You can see how git-bash does it here:

image

So you gave me a good idea with the batch script. One limitation is that the value in regedit isn't run with a shell, rather just executed as a process, so putting something like pushd %1 && gitui.exe isn't possible. But, I created a gitui-in.bat that contains...

pushd %1
gitui.exe

and by setting the registry to...

image

I'm able to get it to work. Anyways, the --cd behaviour is supported by git bash as --cd and by PowerShell as -command Set-Location -literalPath, so I think it would feel a lot less hacky to do it with this tool as well.

@MCord
Copy link
Contributor

MCord commented May 20, 2020

another trick that might be useful is to run cmd directly like:

cmd /c "cd /d %1 && gitui"

this way you don't need a batch file.

@alistaircarscadden
Copy link
Contributor Author

@MCord I tried it and it works. Good idea.

@extrawurst
Copy link
Owner

wow you windows people, that is cool stuff!
@alistaircarscadden thanks for taking the time to put this together.

alistaircarscadden added a commit to alistaircarscadden/gitui that referenced this issue Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants