git-r-done
premise
One day I stood a new server up, imported my SSH keys, and began setting up my environment. To my chagrin, I found my SSH keys weren't working with hub
.
hub
is a program by Github that wraps the classic git
command with an extra layer of commands aimed at making CLI interactions with GitHub far more streamlined.
The specifics are, for me, all irrelevant except for one:
- typing
git clone username/repositoryname
will auto-add the https://github.com and download the URL
and maybe:
- something that ties my GitHub login to my SSH key
I don't use that second thing (voluntarily), it's just something that hub does, but for some reason it breaks every so often, and fails to authenticate my SSH key.
Usually I'm on a time crunch, so that's where git-r-done
comes in.
Operation
This is an insanely simple script:
if [[ -z $1 ]]; then
echo "usage: jrmgit username/repo-name"
echo "example: jrmgit jeromescuggs/git-r-done"
else
git clone https://github.com/$1 $2
fi
Assuming the standard stdout usage of $1
and $2
as stand-ins for prompt entries, this script simply takes the user input and sticks "git clone https://github.com/" in front of it.
Ideally this is used with the username/repositoryname combo to mimic the desired function that hub
performs.
Installation
I usually have a directory in my $HOME folder where i keep executables that are more widget-y in nature but not installed via npm, pip, gem, etc.
To set up a local folder to execute scripts from, you can add it to your PATH by including something like this in your .bashrc
or .zshrc
:
export PATH="$PATH:/home/$USER/.my-scripts-bin/"
Feel free to name it whatever, but I like to always add bin
in to make it obvious that executables are stored there.
Regardless of the above step, to use this script clone this repo locally, and then move either jrmgit
or jrmgit.sh
to your desired location. If it's in a bin
, simply type
jrmgit jeromescuggs/git-r-done gits/git-r-done
and the repository at https:///github.com/jeromescuggs/git-r-done will be downloaded to [current dir]/gits/git-r-done.
Oh, I forgot to mention explicitly that jrmgit
also handles target directories, as per the above example where the cloned repo was placed in ./gits/git-r-done
.