Terminal Shortcuts — Zsh/Bash/Heroku
In this article I am listing the shortcuts I use most often in the terminal as well as a few I would love to add!
Although I am writing this so I will have a quick reference as I learn some new commands, I hope others may find some value as well.
Outline
- Zsh/Bash
- Oh My Zsh
- Git (Oh My Zsh)
- Heroku
Zsh/Bash
Zsh is my shell of choice because it is customizable and based on Bash. Use these commands in either Zsh or Bash.
!!
— bring up the last command. sudo !!
— reruns the last command in admin mode.
|
— add a pipe after a command to use the output in a new command. ex: history | grep mkdir
will search my history entries that include “mkdir”
alias x="y"
— create a custom shortcut. ex: alias c="clear"
will allow you to clear the console using “c” instead of “clear”. The possibilities with this are huge, as you can alias functions as well. Here is a nice list of user-created aliases.
cd
— navigate directly to your home directory
control
+ a
— move your cursor to the start of the line
control
+ e
— move your cursor to the end of the line
control
+ w
— delete one word (behind cursor)
control
+ u
— delete everything to the left of the cursor
control
+ k
— delete everything to the right of the cursor
control
+ y
— undo delete
mkdir -p
— create one or more parent directories. Use curly braces to make more than one child. ex: mkdir -p grandparent/parent/child{1,2,3}
sudo !!
— reruns a command in admin mode.
Oh My Zsh
Oh My Zsh is a framework for managing Zsh configurations. It comes bundled with thousands of functions and plugins. Install Oh My Zsh to gain access to these shortcuts.
..
, ...
, ....
, .....
— moves you up one, two, three, or four directories respectively
/
— use in place of cd
to navigate to your home directory
*.xxx
—list all the files in the current directory with a specific extension. ex: *.js
will list all of the .js
files in your current directory. Include sub-directories by pretending **/
like this: **/*.js
.
alias
— list all your current aliases (including all the ones Oh My Zsh created for you)
d
— list the directories used in this terminal session. ( use cd -n
to navigate to any of these. Replace n
with the number listed)
ls *(m-x)
— search for files by date modified. x
represents how far back you would like to search, for instance, ls *(m-10)
will return all files modified in the last 10 days.
ls *(Lm+x)
— search for files by size. For instance, ls *(Lm+1)
will return all files with a size larger than 1MB
md
— alias for mkdir -p
(create parent and children directories, see Zsh/Bash section for more details)
TAB
+ return
— use this command after starting to type a word. It will list all files and directories in your current location that match what you have entered.
rd
— alias for rmdir
(delete directory)
take
— create a new directory and cd
into it
zsh_stats
— list of top 20 commands and frequency they have been run
..
, ...
, ....
, .....
— moves you up one, two, three, or four directories respectively
Git (Oh My Zsh)
These Git shortcuts come included with Oh My Zsh and they represent the ones I use the most. Once you have Oh My Zsh installed, type alias
into your terminal to find these plus many many more.
g
— shortcut for git
ga
— shortcut forgit add
gaa
— shortcut for git add --all
gcb
— shortcut for git checkout -b
gcl
— shortcut for git clone
gf
— shortcut for git fetch
ggpull
— shortcut for git pull origin "$(git_current_branch)"
ggpush
— shortcut for git push origin "$(git_current_branch)"
gl
— shortcut for git pull
gp
— shortcut for git push
gsw
— shortcut for git switch
Heroku
Heroku is one of my favorite places to deploy projects because it is super easy to host React Projects and pretty easy to host Rails APIs. These are the most useful commands that come with their custom CLI. See the full list here.
heroku access
— list the email addresses of those who have access to the app.
heroku access:add EMAIL
— add a new user to your app. Replace “EMAIL” with the new user’s email address. See docs for additional options including adding a new user with specific permissions.
heroku access:remove EMAIL
— remove a user from the app.
heroku apps
— list all your Heroku apps
heroku apps:create [APP]
— create a new app
heroku apps:errors
— view all errors in the last 24 hours
heroku auth:login
— log in with your Heroku credentials
heroku buildpacks
—display the buildpacks for the app
heroku certs
— list the SSL certificates for an app
heroku commands
— list all the commands
heroku domains
— list the domains for an app
heroku logs
— display recent log output
heroku pg [DATABASE]
— show database information
heroku webhooks
— list webhooks on an app
heroku open
— open the app in a browser
Thank you for reading!
Check out some of my other stories; Send Email From Your React App With EmailJS, CSS Reset, or Recoil.js & simple global state.
Questions? Comments? Concerns? Contact me at joshuagauthreaux@gmail.com or through joshgotro.com.
Thank you and be well!