Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 128 lines (106 sloc) 2.68 KB
#!/bin/bash
#All my custom BASH functions
# encode a given image file as base64 and output css background property to clipboard
function 64enc() {
openssl base64 -in $1 | awk -v ext="${1#*.}" '{ str1=str1 $0 }END{ print "background:url(data:image/"ext";base64,"str1");" }'|pbcopy
echo "$1 encoded to clipboard"
}
function alert() {
file="/Users/asimpson/.sendgrid-key";
if [ -f "$file" ]; then
source "$file";
curl -F "to=$email" \
-F "toname=Boxcar" \
-F "subject=$1" \
-F "text= " \
-F "from=adam@adamsimpson.net" \
-F "api_user=a_simpson" \
-F "api_key=$key" \
https://api.sendgrid.com/api/mail.send.json;
else
echo "$file not found";
fi
}
function tunnel_off {
PID="$(ps aux | grep $1 | grep -v grep | awk '{print $2}')";
kill ${PID} && networksetup -setsocksfirewallproxystate Wi-Fi off;
}
function tunnel {
ssh -D 8080 -f -q -N $1 && networksetup -setsocksfirewallproxystate Wi-Fi on
}
function muxdef {
tmux split-window -v;
tmux split-window -t 1 -h;
tmux send-keys -t 0 "v" C-m;
tmux send-keys -t 2 "gitsh" C-m;
}
function tnew {
tmux new-session -d -s $1;
tmux split-window -v;
tmux split-window -t 1 -h;
tmux send-keys -t 0 "v" C-m;
tmux send-keys -t 2 "gitsh" C-m;
tmux attach-session -t $1;
}
function marked {
open -a Marked\ 2.app $@
}
function xman {
open dash://man:$1
}
function grab {
git checkout $1 -- $2
}
function filepath {
git log -p --follow -- $1
}
function ip {
YELLOW="\033[33m"
IP=$(ifconfig | grep 'inet 1' | cut -c 6- | awk 'NR==2 {print $1}')
echo -e ${YELLOW}$IP
echo $IP | pbcopy
}
function logs {
git log -p --grep $1
}
function move_dock {
if [ "$1" = "left" ]; then
defaults write com.apple.dock pinning -string start && killall Dock
fi
if [ "$1" = "right" ]; then
defaults write com.apple.dock pinning -string end && killall Dock
fi
if [ "$1" = "middle" ]; then
defaults write com.apple.dock pinning -string middle && killall Dock
fi
}
function dashboard_toggle {
if [ "$1" = "kill" ]; then
defaults write com.apple.dashboard mcx-disabled -boolean YES && killall Dock
fi
if [ "$1" = "show" ]; then
defaults write com.apple.dashboard mcx-disabled -boolean NO && killall Dock
fi
}
function vhost {
sudo ~/.dotfiles/osx/mamp_vh.sh $1
}
function al {
awk "/#\[$1\]/,/#\[end\]/ { print }" ~/.dotfiles/bash/aliases | cut -c 7-
}
function hack {
for file in /Applications/MAMP/Library/vhosts/domains/*
do
if [ -f "$file" ];then
echo -e "${YELLOW}${file##/*/}${NC}"
fi
done
}
function hg {
fc -lf 1 -1 | grep --color=auto $1
}
function nb() {
name=$1;
git checkout -b ${name} origin/${name};
}
alias fuck='$(thefuck $(fc -ln -1))'
You can’t perform that action at this time.