All terminal related accessories + shortcuts we like are listed here.

Accessories

iTerm 2

Yeah get that.

Zsh

Yeah get that too.

Ohmyzsh

Get that too, why not.

silversearcher (ag)

ag - A code-searching tool similar to ack, but faster. Apparently ripgrep is even better.

Commands

Super special iterm2 commands

alt + cmd + a Notify when current running process is done. Puts a little eyeball in the top right corner.

Super special zsh commands

To change directories, you don't need to type cd ./../.. anymore (for going up two directories). If you type a path, it'll just go there (e.g. ./../..). If you want to go up more than one directory, shorthand for that is just another dot for each directory (e.g. ./../.. can be shortened to ...).

Terminal shortcuts

cmd + k Clear screen

cmd + r move screen down (similar to clear screen) - does not clear the terminal, moves it above the active line.

ctrl + a, ctrl + k Clear line

Unix commands

These are tools that are embedded into all Unix and Unix-like OSes (i.e. Linux family and OSX).

These are all handy commands. You generally should have the basic ones under your belt, so here's a page dedicated to the most basic commands so you can get around in terminal: Unix Basic Commands

Intermediate commands

curl

Download the resource from a url.

curl https://website.com/zipfile.zip -o outputfilename.zip
alias

alias - Lists all the aliases you have

alias | grep word - Lists all the aliases (for example) that have word in it.

|

| - Feeds the next command the preceding results. So in the above line, alias gets evaluated and the results are passed to grep.

sed

sed 's/word/newWord/g' ./filename.txt find and replaces word with newWord. Nice for scripting, but can also be done in vim or an IDE.

  • In vim: :%s/word/newWord/g
ssh-add

ssh-add -l shows all ssh keys

ssh-add -D delete all keys

zcat - read output of a single zipped file

Use case: unzipping single files that are zipped up for archive purposes.

zcat file.gz > file - quick unzip of a .zip or .gz file

zcat file.gz - write contents of zip straight to output

unzip

Unzip a compressed file. -o Determines the output folder.

unzip outputfilename.zip -o outputfolder
scp

Copy a file into a secure session (ssh).

#scp <file name> <username>@<host>:<destination directory>
scp testfile.txt mario@10.0.2.100:~

If you need to add creds

scp -rp -i ~/.ssh/my.pem testfile.txt mario@10.0.2.100:~
grep

This is built-in, but rg (ripgrep) is faster. This is for searching for words in files, or file names.

grep tacos
cat file.txt | grep tacos
grep --help | grep max
Grep something with a dash before it
grep -- -t
pbpaste

Paste from system clipboard. Vim does not copy/paste to this clipboard.

pbpaste
wc

Word count. By default it counts the amount of bytes (great).

-w will count the amount of words.

pbpaste | wc -w

rc file defaults

Some good values to have in your rc file (or at least I have):

# source this file faster
alias s=". ~/.zshrc"
# edit this file faster
alias e='vi ~/.zshrc'
 alias c='code .' # I'm stupid and want it to be even faster to run
 alias i='idea .'
 alias whihc='which'
 alias rgf='rg --files | rg'

 # Activate Virtual Environments, the pattern
 alias venv='source .venv/bin/activate'
 alias d='deactivate'

 # Notify when done
 alias isdone='it2attention start; it2attention fireworks'

 # Reset mainline to origin/mainline. Removes any weird state to mainline.
 alias gitreset='git checkout -B mainline origin/mainline'

 # Check for deleted/changed files named in git history
 githistoryfilename() {
     local FILE="$1"
     shift 1
     git log --all --full-history -- "**/$FILE.*"
 }
 # show if the repo you cd into has any stashed content
 function cd() {
   builtin cd [email protected] || return
   if [[ -d .git ]]; then
     if [[ $(git stash list) ]]; then
       echo "Stashed content:"
       git stash list
     fi
   fi
 }

 alias ls='ls -lah'

 # Find a string in a file name in all locations on your system
 # Usage: findall ".yaml""
 findall() {
     local FILE="$1"
     shift 1

     find / -name $FILE  2>&1 | grep -v "Permission denieid"
 }
 # Find a string in a file name in the current directory
 # Usage: finder ".yaml"
 finder() {
     local LOCATION="$1" \
           FILE="$2"
     shift 2

     find $LOCATION -name $FILE  2>&1 | grep -v "Permission denieid"
 }

 # Help command
 alias help='glow ~/help.md'

 # Maven
 alias java8='JAVA_HOME=/Library/Java/JavaVirtualMachines/<java8path>'
 alias java11='JAVA_HOME=/Library/Java/JavaVirtualMachines/<java11path>/Contents/Home' # Usage: `java8 mci` - can set java version if jenv isnt used in the repo, otherwise jenv will select the right version
 alias mi='mvn clean install'
 alias mci='mvn clean install'
 alias mci11='java11; mci'
 alias mci8='java8; mci'
 alias mcist='mvn clean -DskipTests install' # Maven Clean Install Skip Tests
 alias owasp='mvn dependency-check:check'
 alias mtree='mvn dependency:tree'

 startsshagent() {
   eval "$(ssh-agent -s)" >/dev/null
   ssh-add $SSH_AMAZON_CERT >/dev/null # Suppress OK messages
   ssh-add $SSH_GITHUB_CERT >/dev/null
 }

 startsshagent