Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
190 lines (146 sloc) 4.47 KB
# vim: set ft=zsh:
# Aliases (common to bash and zsh)
# "Safe" commands
alias mv="mv -i"
alias cp="cp -i"
alias rm="rm -i"
# Awesome LS
alias ls='ls -Gph'
alias ll='ls -l'
alias la='ll -a'
# I like colours.
alias grep='grep --color'
# Useful aliases
alias tarz='tar -xzvf'
alias svi="sudo vim"
alias mkdir='mkdir -p'
alias isodate='date +%Y-%m-%d'
alias unixtime='date +%s'
# Python doctest
alias doctest='python -m doctest'
alias doctest3='python3 -m doctest'
# Gets me in the habit of using a better Python...
alias ipy=ipython
# Jekyll post generation
function post-jekyll {
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
D="$d $(date +"%H:%M:%S")"
slug=$(echo $title | tr '[:upper:]' '[:lower:]' | tr '[:space:]' '-')
slug="${slug:0:${#slug}-1}"
post="./_posts/$d-$slug.md"
body=""
read -d '' body <<EOF
---
title: $title
---
EOF
echo "$body" > $post
$EDITOR $post
}
# Webdev stuff.
alias jeks='jekyll serve --baseurl "" --watch'
# Erlang rebar stuff
alias erlb='erl -pz ebin deps/*/ebin'
# For no real reason:
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
# Starts the named virtual machine.
function vm-start {
VBoxManage startvm $1 --type headless
}
# Virtual Machine aliases
alias start-lmde='vm-start LMDE'
alias pause-lmde='VBoxManage controlvm LMDE savestate'
# Mount aliases
alias cshome-mount='mkdir -p ~/Desktop/cshome && sshfs login: ~/Desktop/cshome'
alias cshome-unmount='umount ~/Desktop/cshome && rmdir ~/Desktop/cshome'
# This will never run out of its novelty.
alias such=git
alias very=git
alias much=git
alias wow='git status -s'
# :?
alias yass='yes yass'
# Get content-type of file.
alias mime='file -b --mime-type'
# View Apache/PHP errors.
alias errors='tail -f /var/log/apache2/error_log'
# View errors, but on the server!
alias serrros='ssh livebook tail -f /var/log/apache2/error_log'
# Use Pygements to colour source code in less.
alias pcat='pygmentize -g'
function pless () {
pcat $1 | less
}
# Add a tac commond on systems that lack it.
hash tac 2> /dev/null || alias tac='tail -r'
# https://github.com/emilisto/itmux/blob/master/itmux.sh
function itmux-ssh() {
local arg_attach
CMD="ssh $@ -t $ITMUX_TMUX_RELATIVE_PATH -C"
# Check if session exists on server and if so, attach to it.
eval $CMD has-session &> /dev/null
if [[ $? -eq 0 ]]; then
arg_attach="attach"
fi
eval $CMD $arg_attach
if [[ $? -eq 0 ]]; then
echo -e $GREEN"Session detached."$NORMAL
else
echo $RED"tmux returned with error exit status - have you installed the required"
echo "iTerm2 version of tmux on the remote host? Try doing:"
echo $YELLOW"\$ itmux-ssh-install $@"$NORMAL
fi
}
# Loads psysh(1) using the composer autoloader (assumes vendor/ is in base of
# git repository).
alias apsysh='psysh "$(git rev-parse --show-toplevel)"/vendor/autoload.php'
# Webdev stuff.
alias behat='$(git rev-parse --show-toplevel)/vendor/bin/behat' # --no-paths'
alias jasmine='$(npm bin)/jasmine'
alias metamap-start='/usr/local/public_mm/bin/skrmedpostctl start && /usr/local/public_mm/bin/wsdserverctl start'
alias metamap-stop='/usr/local/public_mm/bin/skrmedpostctl stop && /usr/local/public_mm/bin/wsdserverctl stop'
#alias serve='python -m SimpleHTTPServer &>>| .access.log &'
# Pushes and deploys a project (e.g., LiveBook).
#alias dep='git push && fab d'
alias dep='git push && fab deploy --user=easantos'
# Show/hide folders in Finder.
alias hide='chflags hidden'
# Unconditionally git commit --ammend
alias gcamend='env GIT_EDITOR=true git commit --amend'
# Circumvent the above restriction
gpip(){
PIP_REQUIRE_VIRTUALENV="" pip $@
}
gpip3(){
PIP_REQUIRE_VIRTUALENV="" pip3 $@
}
# Print from the grad student printers!
function gradprint() {
if [ -z "$1" ] ; then
echo "Must provide a filename." 1>&2
return 1
fi
if ! stat -qf '' $1 ; then
echo "File \`\`$1'' does not exist!" 1>&2
return 2
fi
FILENAME=/tmp/$(basename $1)
REMOTE=login
scp $1 $REMOTE:$FILENAME && ssh -Y $REMOTE xdg-open $FILENAME
}
# ANTLR4 stuff
alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.5-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
alias grun='java org.antlr.v4.runtime.misc.TestRig'
# manswitch <cmd> <flag>
# e.g.,
# manswitch curl -x
# From: https://www.commandlinefu.com/commands/view/9065/what-is-the-use-of-this-switch-
function manswitch () {
man $1 | less -p "^ +$2"
}