diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 98f672d..3314186 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -16,8 +16,9 @@ alias ~="cd ~" # My own creation! See: https://github.com/jakejarvis/simpip alias ipv4="curl -4 simpip.com --max-time 1 --proto-default https --silent" alias ipv6="curl -6 simpip.com --max-time 1 --proto-default https --silent" -alias ip="ipv6; ipv4" +alias ip="ipv4; ipv6" alias iploc="ipconfig getifaddr en0" +alias ips="ip; ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" alias dns-clear="networksetup -setdnsservers Wi-Fi" alias dns-check="networksetup -getdnsservers Wi-Fi" @@ -30,6 +31,7 @@ alias hosts="sudo $EDITOR /etc/hosts" alias speed="wget -O /dev/null http://cachefly.cachefly.net/100mb.test" alias digg="dig @8.8.8.8 +nocmd any +multiline +noall +answer" +# Update: brew, npm, gem, macos alias update="brew update; brew upgrade; brew cask upgrade; brew cleanup; nvm install node --latest-npm --reinstall-packages-from=node; npm install npm -g; npm update -g; gem update --system; gem update; gem cleanup; sudo gem update --system; sudo gem update; sudo gem cleanup; sudo softwareupdate -ia --include-config-data;" alias rehide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" @@ -42,20 +44,27 @@ alias displays="system_profiler SPDisplaysDataType" alias cpu="sysctl -n machdep.cpu.brand_string" alias screenfetch="neofetch" -alias ripfinder="killall Finder" -alias ripdock="killall Dock" -alias ripmenu="killall SystemUIServer NotificationCenter" +alias ripfinder="sudo killall Finder" +alias ripdock="sudo killall Dock" +alias ripmenu="sudo killall SystemUIServer NotificationCenter" -alias finder="open ./" -alias vsc="code ./" +alias finder="open -a Finder ./" +alias vs="code ./" -alias gundo="git reset --soft HEAD~1" -alias gc="git commit -m" -alias gca="git add . && git commit -m" +alias gc="git commit -m" # + commit message +alias gca="git add . && git commit -m" # + commit message alias gs="git status -sb" alias gl="git log --pretty=short" alias gd="git diff" alias gds="git diff --staged" +alias gpom="git push origin master" +alias glom="git pull origin master" +alias gpo="git push origin" # + branch name +alias glo="git pull origin" # + branch name +alias gb="git checkout" # + branch name +alias gbn="git checkout -b" # + branch name +alias grm="git rebase -i origin/master" +alias gundo="git reset --soft HEAD~1" alias dc="docker-compose" diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 7826fc8..eec2fe3 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -45,14 +45,21 @@ unshort() { curl -sIL $1 | sed -n 's/Location: *//p' } -# Create a custom git.io short URL (if available) -# ex: gitio jakesdotfiles https://github.com/jakejarvis/dotfiles => https://git.io/jakesdotfiles +# Create a git.io short URL (custom slug optional) +# ex: gitio https://github.com/jakejarvis/dotfiles [jakesdotfiles] => https://git.io/jakesdotfiles +# https://blog.github.com/2011-11-10-git-io-github-url-shortener gitio() { - if [ -z "${1}" ] || [ -z "${2}" ]; then - echo "Usage: \`gitio slug url\`" - return 1 - fi - curl -i https://git.io/ -F "url=${2}" -F "code=${1}" + PARAMS="-F \"url=$1\"" + if [ -n "$2" ]; then PARAMS="$PARAMS -F \"code=$2\""; fi + RESPONSE=$(eval "curl -i https://git.io $PARAMS 2>&1" | grep "Location: ") + echo "${RESPONSE//Location: /}" +} + +# Transfers text file as sharable link. +# See https://transfer.sh/ +transfer() { + if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi + tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; } # List files in an S3 bucket