While Git supports aliases and I am a big fan of Git aliases, (e.g. ‘git lg’), the most valuable to me (and most used) aliases are shell aliases (e.g. ‘gc’ for ‘git commit’).
command line
Automatically Switch Node Version in Zsh from package.json
Add this code to $HOME/.zshrc to automatically set the node version to match the version in package.json.
Quickly Delete Large Directory from the Command line
When deleting a large directory from the command line, it can take a frustratingly long time for the task to complete. This is a trick I use to speed things up.
Using jq and nvm to set Node version
The nvm command allows you to switch between versions of node. Often a project will include a .nvmrc file to specify the version of node to use. Even if a project does not contain an .nvmrc file, you may be able to read the preferred node version from package.json and use that value with nvm.
Remove newline at end of text file
Sometimes when I’m working with files in Git, I find myself with a change in a file that says “No newline at end of file”. This occurs when my editor adds the missing newline at the end of the file. While you should have a newline at the end of the file, you may have a reason for not wanting to add this change. In that case, you can remove the newline from the end of the file.
Writing Posts with CLI Commands
A lot of the posts I write include command-line interface (CLI) commands to type in. I’ve found over time there are things I can do to improve how these commands are communicated.
Add git status to zsh prompt
One of the things that made me much better at Git was making my current branch (and whether or not I have any changed files) always visible. By default zsh includes everything you need to do this, you just need to configure it.
Add a Blank line at the Beginning of Command Line Prompt
While there are many ways to customization your command line prompt, one that can help readability is adding a blank line at the beginning of each prompt.
Curl Examples Posting Data and Displaying Headers
Curl is a fantastic tool for making web requests from the command line. As a developer, I find this tool particularly useful. Retrieve Content at a URL curl https://salferrarello.com/ Making a HEAD Call Sometimes, we want to see the Header Values returned from a URL using the HEAD. The HTTP HEAD method requests the headers […]
Git Previous Branch
When working with Git on the command line, I spend a lot of time switching back and forth between two branches. Even with Git tab completion, it is a lot of typing. However Git has a shortcut for the previous branch, a single dash (-).