Written by Nick F
Published on 2025-11-13
Back to blog

 

I setup a lot of shell aliases to make my command line life a little easier.

I actually use zsh for my daily shells, but my alias file started when I was a bash user, so in my mind these are all bash aliases even though they work in zsh too.

Generate a password

alias genpassword='date|md5|pbcopy; echo Copied!; pbpaste'

This relies on the pbcopy command that comes with Macs. It's a great tool to quickly generate a strong password. Sometimes I am setting up a new database or other application specific user and it's handy to be able to generate something quickly. Note that I use 1password for my personal password management, so if I'm signing up for something as a person I might use their tool to generate a password, or I'll save what I made with genpassword into 1password.

Scratch

alias scratch=code ~/scratch.md

One of my most common commands it to run scratch to open a dedicated scratchpad file with my editor. I often need to just jot some notes down in a meeting, or reformat some snippet of code I got on slack, or whatever. The scratch file is a temporary place to work on something short and small. Many times I edit my daily standup message in the scratch file before pasting it into Slack. It's a handy spot. Here code will open VSCode, but any GUI editor that you can launch with a command will work just fine.

Show Path

alias showpath="echo \$PATH | tr ':' '\n'"

Sometimes a command doesn't run when I expect it to, and a bad $PATH value in the shell environment is something to check out. Normally PATH has a colon between entries, so this quick pass through tr turns it into a much more readable result.

SSH Remember

alias ssh-remember="ssh-add -t 259200 && echo Three Days"

I have a pass phrase on my ssh keys, so when I push or pull to github or SSH to a host, I have to enter the password. It gets old after a while. I'm only doing this on my personal computer at my house, so the security risk is pretty low that someone else will have access to the device. Thus, with this command, SSH won't ask for the password again for three more days, or until the laptop turns off. It's a way to balance security with convenience.

Python VENV

alias v="source ~/venv/bin/activate"

Installing a bunch of python packages can get messy. Not just python, but I seem to use a lot of Python, and at some point it got messy. So I setup a ~/venv folder to be a sort of "default" virtual environment that I can quickly drop into to install or run some python things and not worry about messing up the global install folder. I am actually using this less these days, I mostly use it to invoke yt-dlp for downloading a youtube video.

Environment Keys

alias env-keys="env | awk -F= '{print \$1}'"

Here is a quick one to just list all the defined keys in your ENV. It's another handy tool for exploring what is going on in your environment. If you have a lot of keys defined, try env-keys | column to make it more readable on your terminal.