Created
March 28, 2024 18:33
-
-
Save mieky/67fcdf744f914f3cff716df6fafe2cf6 to your computer and use it in GitHub Desktop.
Fish script to open Git repo in VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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