I had to change a bunch of Git remotes from GitHub SSH URLs (e.g. git@github.com:salcode/salcode-zsh.git) to GitHub https URLs (e.g. https://github.com/salcode/salcode-zsh.git) on a bunch of different repos. This is how I made it easier for myself.
command line
xargs: warning: options –max-args and –replace/-I/-i are mutually exclusive, ignoring previous –max-args value
This threw me for a loop so I’m writing this down to help others (and likely me in the future). I swear I’ve used “xargs” with both “-I” and “–max-args” in the past but now I’m getting this warning and things are behaving improperly. It turns out there are two version of xargs, (FreeBSD xargs and GNU xargs). FreeBSD xargs is installed on BSD systems (including MacOS) and GNU xargs is found on on Linux systems. This warning (and the incorrect result you also get) indicate you’re running GNU xargs.
Git Editor Roulette
A question came up about setting the Git editor to a bash function, which I could not figure out. I was, however, able to set the Git editor to a bash script. As a proof of concept, here is a bash script to randomly choose an editor (nano or vim) when using Git.
Git Squash Back To
Often in my work, I’ll create a number of commits before I craft my correct solution. Having these missteps in separate commits doesn’t provide any real value and adds noise so I’ll often squash these commits into a single commit. Historically, I’ve used a Git interactive rebase to do this but as I was reminded on Mastodon, it seems like there should be a quicker way, so I’ve created a Git alias, “git squashbackto”, to do this.
Get GitHub PR Number from Current Branch
When scripting a task using the GitHub CLI, I found I needed the Pull Request (PR) number for my current branch (technically my current commit). I was able to use “gh pr view” to get the information.
GitHub Bypass Failed Status Check
Sometimes a GitHub status check fails and you want to override it so you can still merge your PR.
Convert Markdown to Plaintext
I recently had to convert some markdown into plaintext and rather than use an online tool I wanted to do it locally. This is the solution I found.
Git Alias Can Not Change Directory
I wanted to add a Git alias that does a “git clone” and then “cd” to change into the new directory. However, while the “git clone” worked fine, the directory change did not. It turns out you can NOT change directories from within a Git alias.
cd in script without polluting previous directory
I wanted to write a shell alias to get the Git status of a specific directory (~/code/projectx). How could I change directories without polluting the previous directory? (so ‘cd -‘ still works as it did before I ran my alias)
Notify When Command Completes
When I kick off a long running process on a project (e.g. “npm install”) and I shift my focus somewhere else, I often get absorbed in my other task and don’t return to the original process as soon as I wanted to. I’ve addressed this in the past by setting a timer to remind me to come back and check. More recently, I’ve started adding a audio notification to tell me when the task is completed.