Created
February 19, 2017 16:23
-
-
Save chew-z/d8352d9e2260d48ad154cfe1bafa84c0 to your computer and use it in GitHub Desktop.
My multiple .aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# For a full list of active aliases, run `alias`. | |
# | |
# virtualenv | |
# lazy loading saves on shell startup time | |
workon() { | |
[ -z "$WORKON_HOME" ] && { | |
unset -f workon | |
export WORKON_HOME=$HOME/.virtualenvs | |
export PROJECT_HOME=$HOME/Documents/Python | |
source /usr/local/bin/virtualenvwrapper.sh | |
# Aliases for virtualenvwrapper | |
alias mkv="mkvirtualenv" | |
alias toggle="toggleglobalsitepackages" | |
} | |
workon "$@" | |
} | |
# We have set export PIP_REQUIRE_VIRTUALENV=true in zshenv | |
# How do we install or upgrade a global package? | |
# We can temporarily turn off this restriction | |
gpip(){ | |
PIP_REQUIRE_VIRTUALENV="" pip "$@" | |
} | |
gpip3(){ | |
PIP_REQUIRE_VIRTUALENV="" pip3 "$@" | |
} | |
# | |
# Using brew vim / MacVim's vim seems to read gvimrc | |
# alias vim="/Applications/MacVim.app/Contents/MacOS/Vim" | |
# You can leave out the path to the application completely, as open consults the LaunchServices DB. | |
# open -t Causes the file to be opened with the default text editor, as determined via LaunchServices | |
alias edit="open -a MacVim.app $1" | |
alias tw="open -a TextWrangler" | |
# When opening a file from Terminal (with "mvim") you are actually starting a new Vim process manually | |
# and this process connects to the MacVim app which responds by opening up a new window. | |
# This is why "mvim" always opens a new window. | |
# using mvim script even with modifications isn't reliable for me | |
# alias mvim="open -a MacVim.app $1" | |
mvim () { ([[ -z $@ ]] || touch "$@" ) && open -a MacVim "$@"; } | |
# | |
# aliases for configs | |
alias curlconfig="edit ${HOME}/.curlrc" | |
alias dnsmasqconfig="edit /usr/local/etc/dnsmasq/dnsmasq.conf" | |
# alias siftconfig="subl $ {HOME}/.sift.conf" | |
alias mpvconfig="edit ${HOME}/.config/mpv/mpv.conf" | |
alias muttconfig="edit ${HOME}/.muttrc" | |
alias privoxyconfig="edit /usr/local/etc/privoxy/config" | |
alias polipoconfig="edit /usr/local/etc/polipo/config" | |
alias trimconfig="edit ${HOME}/.config/trim_zsh_history.conf" | |
alias vimconfig="edit ${HOME}/.vimrc" | |
alias gvimconfig="edit ${HOME}/.gvimrc" | |
alias ytlconfig="edit ${HOME}/.config/youtube-dl/config" | |
# alias wgetconfig="edit ${HOME}/.wgetrc" | |
alias zshconfig="edit ${HOME}/.zshrc" | |
alias zshenv="edit ${HOME}/.zshenv" | |
alias zshalias="edit ${HOME}/.aliases" | |
# aliases for apps | |
# dig | |
alias ip="dig +short -4 A" | |
alias ip6="dig +short -6 A" | |
alias dig="dig +nocmd +multiline +noall +answer" | |
alias ping="ping -c 3" | |
# grep | |
if [[ -x `which ggrep` ]]; then | |
alias grep='ggrep --color=auto' | |
fi | |
# search within files with ag, browse results with fzf | |
search() { | |
# --only-matching | |
ag --nocolor --nobreak --nonumbers --noheading $@ | fzf --header=$@ --exit-0 | |
} | |
# ff - fuzzy open/edit files from anywhere | |
# Ctrl-O - open, Ctrl-E - edit selected | |
ff() { | |
local out file key | |
# IFS=$'\n' | |
out=(${(f)"$(locate -i0 "$1" | fzf --query="$2" --header="$1" --read0 -0 -1 -m --expect=ctrl-o,ctrl-e)"}) | |
key=$(head -1 <<< "$out") | |
file=$(head -2 <<< "$out" | tail -1) | |
if [ -n "$file" ]; then | |
print -l "$file" | |
[ "$key" = ctrl-o ] && open "$file" || edit "$file" # edit is aliased above | |
fi | |
} | |
# open directory in finder | |
alias finder="open \$1" | |
# move to Trash instead of removing | |
alias rm="trash" | |
# use Apple ditto in place of copy | |
alias copy='echo "using ditto as copy";ditto' | |
alias cp='echo "using ditto as cp";ditto' | |
# use pigz in place of gzip - multiprocessor and parallel | |
alias gzip='echo "using pigz as gzip";pigz' | |
# Send url to instapaper, quietly | |
alias s2i="cd $HOME/Documents/Python/utils; python3 $HOME/Documents/Python/utils/send3instapaper.py --source $1" | |
# brew wget is sick with IRI's [-dco file url] | |
alias wget='echo "using httpie as wget";http -d' | |
# Downloading video [mp4] with youtube-dl | |
alias ytl='youtube-dl $@' | |
# youtube-dl for porn etc via tor | |
alias xtl='youtube-dl --proxy socks5://127.0.0.1:9050/ $@' | |
# streaming with mpv & youtube-dl (also from playlist file, one url per row) | |
# changes https:// to ytdl:// (activating youtube-dl hook script in mpv) | |
# mpv prefers vp9 format | |
function mtl() { | |
# StreamCache script - adjusting speed per cache size/network | |
if [[ $1 =~ https*://.+ ]] | |
then | |
url=$(echo $1 | sed 's/^https*:/ytdl:/' ) | |
mpv --quiet --keep-open=no --script=/usr/local/etc/mpv/StreamCache.lua "$url" | |
else | |
while read line; | |
do | |
echo "playing $line" | |
url=$(echo $line | sed -e 's/https:/ytdl:/' ) | |
[[ ! -z "$url" ]] && mpv --quiet --keep-open=no --script=/usr/local/etc/mpv/StreamCache.lua "$url" | |
sleep 1.5 | |
done < $1 | |
fi | |
} | |
# | |
# Preview or Quick-Look | |
alias preview="open \$1 -a 'Preview'" | |
alias ql="qlmanage -p $* &> /dev/null" | |
# back aliases | |
alias -s png=ql | |
alias -s jpg=ql | |
alias -s gif=ql | |
alias -s raw=preview | |
alias -s icns=ql | |
alias -s pdf=preview | |
alias -s log=ql | |
# use Sublime Text | |
alias -s csv=subl | |
alias -s enmd=subl | |
alias -s markdown=subl | |
alias -s md=subl | |
alias -s taskpaper=subl | |
alias -s text=subl | |
alias -s todo=subl | |
# | |
# history statistics from last 1000 commands | |
alias stats="history 1000 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" | |
alias zshist="subl $HOME/.zsh_history" | |
alias trim="python3 $HOME/Documents/Python/utils/trim_zsh_history.py" | |
# Aliases for tor | |
# alias curl="curl -x http://localhost:8123" # use privoxy or polipo! | |
# Aliases for proxy | |
alias polip="brew services restart polipo" | |
alias privox="brew services restart privoxy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment