-
-
Save dersam/0ec781e8fe552521945671870344147b to your computer and use it in GitHub Desktop.
## Open GitKraken using the current repo directory. | |
## For when you want a prettier view of your current repo, | |
## but prefer staying in the cli for most things. | |
## This will break if GitKraken ever removes the -p flag. | |
## If you're not using OSX, the path is definitely different. | |
kraken () { | |
~/Applications/GitKraken.app/Contents/MacOS/GitKraken -p $(pwd) | |
} | |
# If you want a git alias, add the following to your git config under [alias] | |
kraken = !"~/Applications/GitKraken.app/Contents/MacOS/GitKraken -p $(pwd)" | |
# Now you can 'git kraken'! |
Thanks @hlynbech for that tip - I totally missed the gitkraken://
scheme. I've updated my ~/.gitconfig
with the following:
[alias]
kraken = !open "gitkraken://repo$(cd "${1:-.}" && git rev-parse --show-toplevel); :"
Note that it works regardless of the directory you are in, even if some subdir within your clone, and allows you to specify some other directory on the command line.
Thanks @hlynbech! I've tried a few things from this thread and yours was the only one that worked for me.
In case anyone coming from Google is wondering, I'm using MacOS Mojave and Zsh.
Yes, @hlynbech url scheme approach is working here too.
Slight update for anyone who cares - if you happen to have a subrepo or other git-repo inside of another repo this requires a slight fix to use the current working directory instead of just the root of the current repository, so this is my current alias:
kraken = !open "gitkraken://repo$(cd "${GIT_PREFIX:-.}/${1:-.}" && git rev-parse --show-toplevel); :"
I liked Sourcetree's stree foo
on Mac. Similarly krak
opens a repo dir passed as arg:
krak () {
dir="$(cd "$(dirname "$1")"; pwd -P)/$(basename "$1")"
open gitkraken://repo/$dir
}
Is there any way to open a folder in an already open instance of Gitkraken? I'm on Linux
I've ended up with this zsh alias, but, I guess, that would work elsewhere:
alias gk='(eval "gitkraken --new-window -p \"$(git rev-parse --show-toplevel)\" -l /dev/null >/dev/null 2>&1 &")'
It's based on solution from older commends, but:
- It uses
(
and)
to hide the printing of PID process, thats printed by kernel if you use&
— thats why I decided to write the comment. - It uses
--new-window
to open repo, if gitkraken already launched somewhere. - It uses
git rev-parse --show-toplevel
and not pwd to get repository right - It uses black magic
-l /dev/null >/dev/null 2>&1 &
to hide all the shit and logs.
@pablogs9 use --new-window
. Yea, it's not that obvious.
--new-window
works like charm!
https://gist.github.com/dersam/0ec781e8fe552521945671870344147b#gistcomment-3453223
I made this Quick Action using your logic, it worked just fine
I will share to you the exported files:
Link: https://github.com/rbatty19/mac-os-automators/
more info:
https://stackoverflow.com/questions/70815538/open-with-shortcut-quick-action-for-vs-code-git-kraken
https://stackoverflow.com/questions/64040393/open-a-folder-in-vscode-through-finder-in-macos
I added this to my .bashrc
and it works like a charm in any directory inside a git repo you might be
function kraken() {
open -na 'GitKraken' --args -p $(git rev-parse --absolute-git-dir)
}
I added this to my
.bashrc
and it works like a charm in any directory inside a git repo you might befunction kraken() { open -na 'GitKraken' --args -p $(git rev-parse --absolute-git-dir) }
work to me
to anyone else who stumbles on this. to handle dirs with spaces:
alias kraken="open -na 'GitKraken' --args -p \"$(git rev-parse --absolute-git-dir)\""
alias gk="kraken"
The new url schema works better for me, I couldn't get any suggestions above to work with GitKraken 7.3.2.
So the idea is that GitKraken automatically installs an URI-schema handler in MacOS that handles URIs that start with gitkraken://
From the docs I learned that the first path component is a directive, so opening a repo is just the directive "repo", so if I have my repo at "/Users/myuser/git/InterestingGitRepo", the terminal command is plainly
which opens my repo in a new tab in GitKraken.
So in terms of the aliases in this thread, you could use this: