Skip to content

Instantly share code, notes, and snippets.

@dersam
Last active May 28, 2024 22:14
Show Gist options
  • Save dersam/0ec781e8fe552521945671870344147b to your computer and use it in GitHub Desktop.
Save dersam/0ec781e8fe552521945671870344147b to your computer and use it in GitHub Desktop.
Open GitKraken using the current repo directory in the cli.
## 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'!
@jorahood
Copy link

jorahood commented Aug 31, 2021

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
    }

@pablogs9
Copy link

Is there any way to open a folder in an already open instance of Gitkraken? I'm on Linux

@Mayurifag
Copy link

Mayurifag commented Nov 30, 2021

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.

@pablogs9
Copy link

pablogs9 commented Dec 1, 2021

--new-window works like charm!

@jebeaudet
Copy link

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment