Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Created June 20, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelCurrin/fa0623d433a9e0cb70ed9e66e979a24d to your computer and use it in GitHub Desktop.
Save MichaelCurrin/fa0623d433a9e0cb70ed9e66e979a24d to your computer and use it in GitHub Desktop.
Random alias of the day

Why?

Too many aliases to remember all at once? Teach or remind yourself of one at a time.

On opening a new terminal window, show a random alias from your aliases and git aliases.

This is your IDE's tip of the day but in your terminal.

Follow instructions in this gist to setup.

Sample result

This can be triggered manually or on opening a new tab.

Examples my main aliases:

$ random_alias
alias update='sudo apt-get update && sudo apt-get upgrade'
$ random_alias
ls = ls-files

Examples my git aliases:

$ random_alias
br = branch -av

Listing aliases

Alias

You can store an alias like this:

alias foo='echo "Bar"'

If you run this you will see your alias values set:

$ alias
alias foo='echo "Bar"'
alias c='clear'
alias cp='cp -i'
...

Just be aware of that.

Git alias

You can set aliases as well specific to the git context.

Add this to your .gitconfig.

[alias]
    alias = ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /

Now you can run this to see your git aliases.

git alias
st = status -s
ci = commit
br = branch -av

Setup random alias viewer

Add this to your .bashrc or .aliases file. This will concantenate the output of the two alias commands then then pick one line randomly.

alias random_alias='{ alias & git alias ;} | shuf -n 1'

And then set it up in your .bashrc file to run on each new terminal tab opened.

random_alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment