Skip to content

Instantly share code, notes, and snippets.

@maurelian
Last active October 5, 2023 16:42
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 maurelian/e9a226782c1830376ac79baf87447002 to your computer and use it in GitHub Desktop.
Save maurelian/e9a226782c1830376ac79baf87447002 to your computer and use it in GitHub Desktop.
vrepo (view repo) alias for getting source and opening it in your editor quickly.
vrepo () {
if [[ $# -ne 1 ]]
then
echo "Usage: vRepo <github URL or org/repo-name>"
return 1
fi
if [[ $1 == *"github.com"* ]]
then
urlPath=$(echo $1 | sed 's/.*github.com\///')
org=$(echo $urlPath | cut -d '/' -f1)
repo=$(echo $urlPath | cut -d '/' -f2)
else
org=$(echo $1 | cut -d '/' -f1)
repo=$(echo $1 | cut -d '/' -f2)
fi
dest_dir="$HOME/Projects/various-repos/$org-$repo"
echo "cloning $org/$repo into $dest_dir"
gh clone "https://github.com/$org/$repo" "$dest_dir"
cd "$dest_dir"
code "$dest_dir"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment