Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Last active November 10, 2020 16:43
Show Gist options
  • Select an option

  • Save ddrscott/18920cbad5151efc35c0fd4ed18feb0f to your computer and use it in GitHub Desktop.

Select an option

Save ddrscott/18920cbad5151efc35c0fd4ed18feb0f to your computer and use it in GitHub Desktop.

Terminal Illness - Lightning Talk

This is a shotgun blast of commands I use from terminal for fun and profit. Some say I'm crazy for living in the "black screen", I like to think of it as a Terminal Illness.

Pipes are the only friends that won't let you down

Most used commands

history | awk '{print $2}' | sort | uniq -c | sort -n

awk is my Bestie!

# Build a command
ls | awk -F '.' '{print("git mv " $0 " " $1 ".yml")}'


# Then execute it
ls | awk -F '.' '{system("git mv " $0 " " $1 ".yml")}'

Keep your Bash history forever

Remember that command that you spent all that time writing? Now you will!

# ~/.bashrc
HISTSIZE=9999999
HISTFILESIZE=9999999
shopt -s histappend
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Search the history like a champ

Give ctrl-r (reverse search history) super powers with fuzzy search.

Old: history New: fzf

git clone https://github.com/junegunn/fzf.git ~/.fzf

~/.fzf/install


# ~/.bashrc
# set height to full screen
export FZF_CTRL_R_OPTS='--height 100'

Run a command when something changes

brew install entr

apt-get install entr

find . | entr -cs 'echo something changed at `date`'

find . | entr -cs 'pytest'

Who needs Excel?!

cat ~/Downloads/results-20201030-111437.csv | column -ts ','  | less -S

Done

banner -w 50 done | snail


# A slower tail -f
# Example:
#     cat foo | snail
#     cat bar | snail 0.1
function snail() {
  awk -v s="${1:-'0.3'}" 'system("sleep " s) {exit} 1'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment