Skip to content

Instantly share code, notes, and snippets.

@mieky
Created March 28, 2024 18:33
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 mieky/67fcdf744f914f3cff716df6fafe2cf6 to your computer and use it in GitHub Desktop.
Save mieky/67fcdf744f914f3cff716df6fafe2cf6 to your computer and use it in GitHub Desktop.
Fish script to open Git repo in VS Code
function code-repo --description 'Open current Git repo in VSCode'
if not type -q git
echo "couldn't find command: git"
return 1
end
if not type -q code
echo "couldn't find command: code"
return 1
end
set --local git_repo_root $(git rev-parse --show-toplevel 2>/dev/null)
if not string length --quiet $git_repo_root
echo "Current directory is not inside a git repo"
else
echo "Opening in VSCode: $git_repo_root"
code $git_repo_root
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment