Skip to content

Instantly share code, notes, and snippets.

@reflexdemon
Last active April 20, 2019 13:27
Show Gist options
  • Save reflexdemon/435ae62e734a99b85bab to your computer and use it in GitHub Desktop.
Save reflexdemon/435ae62e734a99b85bab to your computer and use it in GitHub Desktop.
Useful Bash command

Useful goodies for bash

##Bash first line (shebang)

#!/bin/bash

Profile

Good to have these on ~/.bash_profile

set completion-ignore-case on
# set show-all-if-ambiguous on
# TAB: menu-complete


# make bash autocomplete with up arrow/down arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

Find files recursively on subdirs

find . -name *.js

Search for running process

ps -eaf | grep -v grep | grep process

or

ps -efH | grep process

Delete all .DS_Store

find . "-name" ".DS_Store" -exec rm {} \;

Delete files older than 30 days

find /tmp  -mtime +30 -exec rm -rf {} \;

Good to have aliases that I love

alias ll="ls -ltra"
alias dir="ls -ltra"
alias li="find . -type f -exec basename {} \;"
alias pss="ps -ef| grep -v grep| grep"
alias cleanup_ds_store="find . \"-name\" \".DS_Store\" -exec rm {} \;"
alias os_mongo_shop="ssh -L 27017:IP_ADDRESS:27017 user@host -N"

#Hide and show .files on Finder for Mac
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
#Curl with permormance output
alias curlp='curl -w "Accesing %{url_effective}\nHTTP Response\t%{response_code}\nTook %{time_total}s to respond to download %{size_download} bytes.\n" -o NUL -s'
alias whatismyip="http http://ip-api.com/json | jq '.query +\", \"+.city +\", \"+.regionName +\", \"+ .country + \", \" + .org'"

Like to have them on the bash profile

#Print a nerd joke :) of chuck noris
http --timeout=2.5 http://api.icndb.com/jokes/random?limitTo=[nerdy] | jq ".value.joke"

# Print cli weather
curl wttr.in/Alpharetta,GA,USA\?0 --connect-timeout 3

# Print your public IP address 
http --timeout=2.5 https://ipapi.co/json | jq '.ip +", " +.city +", "+.region +", "+ .country + ", " + .org'

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