summaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.zshrc211
1 files changed, 122 insertions, 89 deletions
diff --git a/zsh/.zshrc b/zsh/.zshrc
index 271d475..9f9aaf2 100644
--- a/zsh/.zshrc
+++ b/zsh/.zshrc
@@ -8,23 +8,115 @@ compinit -u
compctl -K tln muxa
compdef mosh=ssh
promptinit
+
HISTFILE=~/.zshistory
HISTSIZE=1000
SAVEHIST=1000
+
setopt completealiases
setopt no_multios
+
bindkey -v
bindkey '^R' history-incremental-search-backward
bindkey '^A' vi-beginning-of-line
bindkey '^E' vi-end-of-line
+
zstyle ':completion:*' completer _complete _ignored
zstyle ':completion:*' menu select=2
zstyle :compinstall filename '~/.zshrc'
zstyle '*' hosts # do not use /etc/hosts
+
ZDIR=~/.zsh/
_HOST_TYPE=$(uname)
# #############################################################################
+# functions
+# #############################################################################
+
+diff ()
+{
+ if [[ -x $(which colordiff 2>/dev/null) ]]; then
+ colordiff "$@"
+ else
+ command diff "$@"
+ fi
+}
+
+irb ()
+{
+ which pry &>/dev/null
+ if [[ $? -eq 0 ]]; then
+ pry "$@"
+ else
+ command irb "$@"
+ fi
+}
+
+lsof_kill ()
+{
+ lsof $1 | grep -v COMMAND | cut -d " " -f 2- | strips | cut -d " " -f 1 | xargs kill
+}
+
+tln ()
+{
+ reply=( $(tmux list-sessions | cut -d: -f1) )
+}
+
+watch_pdflatex ()
+{
+ echo $1
+ ls $@ | entr pdflatex --interaction=batchmode $1
+ echo "tell application \"Preview\" to activate" | osascript -
+ echo "tell application \"iTerm2\" to activate" | osascript -
+}
+
+pdfprevfile ()
+{
+ pdftoppm $1 -f 1 -l 1 -singlefile -png
+}
+
+getcert ()
+{
+ openssl s_client -showcerts -connect $1 <dev/null > $2
+}
+
+on_gcloud () {
+ curl metadata.google.internal -i --connect-timeout 0.25 &>/dev/null
+ if [[ $? -eq 0 ]]; then
+ echo "yes"
+ else
+ echo "no"
+ fi
+}
+
+on_aws () {
+ if [[ $(hostname -f | cut -d. -f 2) == "ec2" ]]; then
+ echo "yes"
+ else
+ echo "no"
+ fi
+}
+
+function chpwd
+{
+ if [[ -e $ZDIR/functions ]] {
+ source ~/.zsh/functions/rtab.zsh
+ if [[ $(pwd) == $HOME ]]; then
+ psvar[1]=$(print -P %~)
+ else
+ psvar[1]=$(rtab)
+ fi
+ } else {
+ psvar[1]=$(print -P %~)
+ }
+}
+chpwd
+zstyle ':prompt:rtab' fish yes
+zstyle ':prompt:rtab' nameddirs yes
+
+
+
+# #############################################################################
# exports
# #############################################################################
@@ -78,9 +170,6 @@ case $_HOST_TYPE in
;;
esac
-# get a white background in mutt
-#COLORFGBG="White;Black"
-
# #############################################################################
# terminal
# #############################################################################
@@ -100,15 +189,6 @@ stty -ixon # enable mapping of C-s in vim..
autoload -U colors && colors
-in_google_cloud () {
- curl metadata.google.internal -i --connect-timeout 0.25 &>/dev/null
- if [[ $? -eq 0 ]]; then
- echo "yes"
- else
- echo "no"
- fi
-}
-
# possible colors: black, white, green, cyan, red, yellow, magenta
case `hostname` in
bryant|barkley|bogues*|curry*|durant*|iverson*|jordan*|ming*|nowitzki*|oneal*|robinson*)
@@ -119,10 +199,6 @@ case `hostname` in
HOSTCOLOR_BG=blue
HOSTCOLOR_FG=black
;;
- 2pac|coltrane|donna|vicious|lemmy|CLuster)
- HOSTCOLOR_BG=green
- HOSTCOLOR_FG=black
- ;;
*)
HOSTCOLOR_BG=black
HOSTCOLOR_FG=white
@@ -130,9 +206,17 @@ case `hostname` in
esac
# google cloud
-if [[ $(in_google_cloud) == "yes" ]]; then
+if [[ $(on_gcloud) == "yes" ]]; then
HOSTCOLOR_BG=cyan
HOSTCOLOR_FG=white
+ alias tmux="tmux -f ~/.tmux.gcloud.conf"
+fi
+
+# aws
+if [[ $(on_aws) == "yes" ]]; then
+ HOSTCOLOR_BG=yellow
+ HOSTCOLOR_FG=black
+ alias tmux="tmux -f ~/.tmux.aws.conf"
fi
function chpwd
@@ -224,77 +308,26 @@ alias my_ip='echo "$(curl 'https://api.ipify.org' 2>/dev/null)"'
alias t_timeline='while true; do clear; t timeline -n 16 -C icon; sleep 600; done'
if [[ $_HOST_TYPE == "Linux" ]]; then
-alias cal='while true; do clear; echo; khal calendar; sleep 600; done'
-alias wifi_list='sudo iwlist wlan0 scan'
-alias always_on='xset dpms 0 0 0'
-if [[ $(hostname) == "bogues" ]]; then
- alias vgaoff='xrandr --output VGA1 --off && xrandr --output LVDS1 --mode 1024x768'
- alias vgaclone='xrandr --output VGA1 --mode 1024x768'
-elif [[ $(hostname) == "barkley" ]]; then
- alias vgaoff='xrandr --output DP2 --off && xrandr --output eDP1 --mode 1920x1080'
- alias vgaclone='xrandr --output DP2 --mode 1280x1024'
- alias presentation='xrandr --output eDP1 --mode 1024x768 && xrandr --output DP2 --mode 1024x768'
- alias presentation-off='xrandr --output DP2 --off && xrandr --output eDP1 --mode 1920x1080'
-fi
-alias vgaext='xrandr --output VGA1 --mode 1024x768 --left-of LVDS1 --rotate right'
-alias vga21='xrandr --output VGA1 --mode 1600x1200 --rate 60 --rotate right && xrandr --output LVDS1 --off'
-alias vga22w='xrandr --output VGA1 --mode 1680x1050 --rate 60 --rotate left && xrandr --output LVDS1 --off'
-alias reboot='sudo shutdown -r now'
-alias halt='sudo shutdown -h now'
-alias lp2p='/usr/bin/lp -o sides=two-sided-long-edge'
-alias lp4p='/usr/bin/lp -o sides=two-sided-short-edge -o number-up=2'
-alias lp8p='/usr/bin/lp -o sides=two-sided-short-edge -o number-up=4 -o landscape'
-alias lpimg='/usr/bin/lp -o fit-to-page'
-fi
-
-# #############################################################################
-# functions
-# #############################################################################
-
-diff ()
-{
- if [[ -x $(which colordiff 2>/dev/null) ]]; then
- colordiff "$@"
- else
- command diff "$@"
- fi
-}
-
-irb ()
-{
- which pry &>/dev/null
- if [[ $? -eq 0 ]]; then
- pry "$@"
- else
- command irb "$@"
+ alias cal='while true; do clear; echo; khal calendar; sleep 600; done'
+ alias wifi_list='sudo iwlist wlan0 scan'
+ alias always_on='xset dpms 0 0 0'
+ if [[ $(hostname) == "bogues" ]]; then
+ alias vgaoff='xrandr --output VGA1 --off && xrandr --output LVDS1 --mode 1024x768'
+ alias vgaclone='xrandr --output VGA1 --mode 1024x768'
+ elif [[ $(hostname) == "barkley" ]]; then
+ alias vgaoff='xrandr --output DP2 --off && xrandr --output eDP1 --mode 1920x1080'
+ alias vgaclone='xrandr --output DP2 --mode 1280x1024'
+ alias presentation='xrandr --output eDP1 --mode 1024x768 && xrandr --output DP2 --mode 1024x768'
+ alias presentation-off='xrandr --output DP2 --off && xrandr --output eDP1 --mode 1920x1080'
fi
-}
-
-lsof_kill ()
-{
- lsof $1 | grep -v COMMAND | cut -d " " -f 2- | strips | cut -d " " -f 1 | xargs kill
-}
-
-tln ()
-{
- reply=( $(tmux list-sessions | cut -d: -f1) )
-}
-
-watch_pdflatex ()
-{
- echo $1
- ls $@ | entr pdflatex --interaction=batchmode $1
- echo "tell application \"Preview\" to activate" | osascript -
- echo "tell application \"iTerm2\" to activate" | osascript -
-}
-
-pdfprevfile ()
-{
- pdftoppm $1 -f 1 -l 1 -singlefile -png
-}
-
-getcert ()
-{
- openssl s_client -showcerts -connect $1 <dev/null > $2
-}
+ alias vgaext='xrandr --output VGA1 --mode 1024x768 --left-of LVDS1 --rotate right'
+ alias vga21='xrandr --output VGA1 --mode 1600x1200 --rate 60 --rotate right && xrandr --output LVDS1 --off'
+ alias vga22w='xrandr --output VGA1 --mode 1680x1050 --rate 60 --rotate left && xrandr --output LVDS1 --off'
+ alias reboot='sudo shutdown -r now'
+ alias halt='sudo shutdown -h now'
+ alias lp2p='/usr/bin/lp -o sides=two-sided-long-edge'
+ alias lp4p='/usr/bin/lp -o sides=two-sided-short-edge -o number-up=2'
+ alias lp8p='/usr/bin/lp -o sides=two-sided-short-edge -o number-up=4 -o landscape'
+ alias lpimg='/usr/bin/lp -o fit-to-page'
+fi