Skip to content

Instantly share code, notes, and snippets.

@gerardo-junior
Last active May 29, 2018 13:33
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 gerardo-junior/8b023ddfc9b7260da6a6b3f0f96c3068 to your computer and use it in GitHub Desktop.
Save gerardo-junior/8b023ddfc9b7260da6a6b3f0f96c3068 to your computer and use it in GitHub Desktop.
My personal zsh configuration
# Configure antigen
source /usr/share/zsh/share/antigen.zsh
antigen use oh-my-zsh
antigen bundle git
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen theme robbyrussell
antigen apply
if [ $TILIX_ID ] || [ $VTE_VERSION ]; then
source /etc/profile.d/vte.sh
fi
# Copies the piped input onto the clipboard
alias copy="xclip -selection c"
# Pastes the clipboards contents into the terminal
alias paste="xclip -selection clipboard -o"
# Pretty print formt
alias json="python -m json.tool"
alias xml="xmllint --format -"
# Output text cases
alias lcase="tr '[:upper:]' '[:lower:]'"
alias ucase="tr '[:lower:]' '[:upper:]'"
# Slugify commad
alias slugify="iconv -t ascii//TRANSLIT | sed -r 's/[~\\^]+//g' | sed -r 's/[^a-zA-Z0-9]+/-/g' | sed -r 's/^-+\\|-+$//g' | lcase"
# Backup commad
backup() {
[ -z "$1" ] && (echo "ERROR: Empty input"; return 1)
input=$1
[ -e $input ] || (echo "ERROR: File not found"; return 1)
if [ -z "$2" ]; then
output="$HOME/.backup$(realpath -- $input 2> /dev/null | sed -r 's/(.+)\/.+/\1/')"
[ -d $output ] || mkdir -p $output
else
output=$(realpath -- "$2" 2> /dev/null)
[ -d $output ] || (echo "ERROR: Invalid output"; return 1)
fi
output="$output/$(echo $input | sed 's/.*\///' | slugify).$(date '+%Y-%m-%d').bpk.tgz"
tar -cpzf $output \
--exclude=$output \
--exclude=/proc \
--exclude=/lost+found \
--exclude=/mnt \
--exclude=/sys \
--exclude=/media \
$input
unset input output
echo "Backup make with success"; return 0
}
# Output code with highlight
highlight () { vimcat -c "set syntax=$1" }
# Create mini webserver
alias webserver="python -m http.server"
# Get my external ip
alias myIp="curl -sSL 'https://api.ipify.org?format=json'"
# Check if you is a tor client
alias isTor="curl -sSL 'https://check.torproject.org/api/ip'"
# Check location of a ip
trackIp () { curl -sSL "http://ip-api.com/json/$1" }
# Send text to termbin (like pastebin)
alias tb="nc termbin.com 9999"
# Expose local servers to the internet (80:0.0.0.0:80)
expose () { ssh -R "$1" serveo.net }
# Unshorten url
unshorten () { curl -sSL "https://unshorten.me/json/$1" }
# Scan file with virus total
scanFileWithVirusTotal () {
curl -sSL -F "file=@$@" -F \
apikey='[API KEY]' \
https://www.virustotal.com/vtapi/v2/file/scan
}
scanUrlWithVirusTotal () {
curl -sSL --request POST \
--url 'https://www.virustotal.com/vtapi/v2/url/scan' \
-d apikey='[API KEY]' \
-d "url=$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment