sigh, I did it again. Wrote another bash script to make my workflow better.
I've been trying to wean myself off the desktop directory, so I decided to separate my stuff into two directories, ~/personal
and ~/work
but it was becoming a bit of a nuisance to switch between the two directories, especially when cloning repositories.
The first solution was to alias w to cd ~/work
and p to cd ~/personal
. Now that fixed the switching bit, but what about the cloning from Github?
I had already worked on the workspaces issue using another script that manipulates tmux but that doesn't quite solve the cloning issue.
So I did what I could, and wrote another script to make this process faster.
Call the script and parse two arguments, and it switches to the desired directory (work or personal) and clones the repo.
This is what I managed to come up with:
#!/usr/bin/env bash
PERSONAL_OR_WORK="$1"
URL="$2"
GIT_URL="git@github.com:"$URL
if [ "$PERSONAL_OR_WORK" == "" ]; then
echo "Destination not set"
echo "usage:
clone [p/w] username/repo"
elif [ "$PERSONAL_OR_WORK" == "p" ]; then
echo "Switched to personal"
cd ~/personal/ && `git clone $GIT_URL`
elif [ "$PERSONAL_OR_WORK" == "w"]; then
echo "Switched to work"
cd ~/work/ && `git clone $GIT_URL`
fi
It's a bunch of if-else
statements but they fix my problem.
The code could also be better but I don't feel like refactoring since it works just fine.
This means I have to update my earlier script that allows me to create repositories on my GitHub account from my terminal since it clones the repo to the ~/Desktop
. But I just have to replace ~/Desktop
with ~/personal
You can check out other dumb stuff I scripted here
That's it for today, hope you enjoyed me fixing non-existent problems 🤣🤣