Last active
October 5, 2023 16:42
-
-
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.
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
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