Hacker News new | past | comments | ask | show | jobs | submit login

Oh. Thanks for the tip. This might make me finally embrace powershell. I’ve been using WSL+zsh+fzf as a Windows CLI for continuity with day job Mac tools, but git CLI performance is only usable inside the WSL file system.



You can also add a small script to your WSL under `/usr/local/bin/git`:

  GIT_WINDOWS="/mnt/c/Program Files/Git/bin/git.exe"
  GIT_LINUX="/usr/bin/git"
  
  case "$(pwd -P)" in
  /mnt/?/*)
    case "$@" in
    # Needed to fix prompt, but it breaks things like paging, colours, etc
    rev-parse*)
      # running linux git for rev-parse seems faster, even without translating paths
      exec "$GIT_LINUX" "$@"
      ;;
    *)
      exec "$GIT_WINDOWS" -c color.ui=always "$@"
      ;;
    esac
    ;;
  *)
    exec "$GIT_LINUX" "$@"
    ;;
  esac

This allows you to use `git` in your WSL shell but it'll pick whichever executable is suitable for the filesystem that the repo is in :)


Thank you. I will use this.


The code as written above only works if you haven't changed the mountpoint for your windows partition (i.e. from /mnt), consider that


This might make me finally embrace powershell

Yeah, I have a bit of a love-hate relationship with it. But I actually have that with all shells out there. I don't know if it's just me or the shells, or (the most likely I think): a bit of both. But PS is available out of the box and using objects vs plain text is a major win in my book, and even though I still don't know half of the syntax by heart it feels less of an endless fight than other shells. And since I use the shell itself for rather basic things and for the rest only for tools (like shown here), we get along just fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: