Skip to content

Instantly share code, notes, and snippets.

@ephdtrg
Forked from carlolars/gitkraken-wsl-bash.bat
Created June 29, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ephdtrg/5cd7a7f6fb63f4951f7bcde644750d99 to your computer and use it in GitHub Desktop.
Save ephdtrg/5cd7a7f6fb63f4951f7bcde644750d99 to your computer and use it in GitHub Desktop.
Use bash from WSL as sh.exe for GitKraken (5.0.4) for Windows
@echo off
REM Make sure that the path to the script is correct!
@bash -l -c "~/bin/gitkraken-wsl-bash.sh %*"
#!/bin/bash
# Mount root for windows drives, default is /mnt/ but can be changed in /etc/wsl.conf
MOUNT_ROOT=/mnt/
# Read GitKraken's hook script and arguments from STDIN
read -r GITKRAKEN_CMD
# Cleanup the path to the script:
# - Replace two or more '\' in a row with a single '/'.
# - Replace the windows drive letter (C:) with the mount point for the drive (/mnt/c)
FIXED_CMD=$(echo $GITKRAKEN_CMD | sed 's_\\\{2,\}_/_g' | sed "s_\([A-Z]\)\:/_$MOUNT_ROOT\L\1/_g")
# Run the hook script
bash -c "$FIXED_CMD"
  1. Copy gitkraken-wsl-bash.bat and gitkraken-wsl-bash.sh, I put them in ~/bin.
  2. Make sure that the script path in the bat-file and MOUNT_ROOT in the sh-file are correct.
  3. Set gitkraken-wsl-bash.bat as 'Path to sh.exe' in GitKraken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment