Skip to content

Instantly share code, notes, and snippets.

@swaathi
Last active May 29, 2019 14:11
Show Gist options
  • Save swaathi/8c18be3a437e498034a5a3ede54d0ce9 to your computer and use it in GitHub Desktop.
Save swaathi/8c18be3a437e498034a5a3ede54d0ce9 to your computer and use it in GitHub Desktop.
Add quick functions to your shell
#! /bin/bash
if [[ $1 == 'me' ]]; then
cat "$(which show)"
elif [[ $1 == 'loc' ]]; then
echo `which show`
elif [[ $1 == 'install' ]]; then
echo "Ensure to place this file in `usr/local/bin` and read instructions on https://gist.github.com/swaathi/8c18be3a437e498034a5a3ede54d0ce9/."
brew install fortune
brew install cowsay
brew install lolcat
elif [[ $1 == 'commands' ]]; then
echo 'show > loc | ssh | time | date | day | ip | irb | rand | brewstop | db'
echo 'show git > hash | Hash | key | config | ignore'
elif [[ $1 == 'edit' ]]; then
atom "$(which show)"
elif [[ $1 == 'ssh' ]]; then
cat '/Users/swaathi/.ssh/id_rsa.pub'
elif [[ $1 == 'time' ]]; then
echo `date +%H:%M`
elif [[ $1 == 'date' ]]; then
echo `date '+%A, %B %d'`
elif [[ $1 == 'day' ]]; then
echo `date +%A`
elif [[ $1 == 'ip' ]]; then
echo `ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'`
elif [[ $1 == 'irb' ]]; then
echo "irb -r crawler -I ./lib"
elif [[ $1 == 'rand' ]]; then
echo $(openssl rand -base64 ${2:-8} | tr -d "=+/" | cut -c1-25)
elif [[ $1 == 'git' ]]; then
if [[ $2 == 'hash' ]]; then
echo "$(git log --pretty=format:'%h')"
elif [[ $2 == 'Hash' ]]; then
echo "$(git log --pretty=format:'%H')"
elif [[ $2 == 'key' ]]; then
cat '/Users/swaathi/.github.access.key'
elif [[ $2 == 'config' ]]; then
cat `pwd`'/.git/config'
elif [[ $2 == 'ignore' ]]; then
echo "$(git rm -r --cached .)"
else
echo 'git option not found'
fi
elif [[ $1 == 'brewstop' ]]; then
`export HOMEBREW_NO_AUTO_UPDATE=1`
elif [[ $1 == 'sm' ]]; then
if [ -z "$2" ]; then
fortune | cowsay | lolcat -a -s 70 -d 20
else
echo $2 | cowsay | lolcat -a -s 70 -d 20
fi
elif [[ $1 == 'db' ]]; then
echo 'development:
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_bin
reconnect: false
database: <DATABASE-NAME-HERE>
pool: 50
username: root
password: root
socket: /tmp/mysql.sock
variables:
sql_mode: ""'
else
echo 'option not found'
fi
  1. Place the file 'show' in your usr/local/bin
  2. Edit the file and replace <username> with your username
  3. Grant all permissions (you can alternatively grant only read permissions) to it, chmod 777 show
  4. Execute show install
  5. Try it out!
show github
show ssh
show time
show date
show day
show ip
show rand

FUN TIP: Execute show sm

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