From 7cab8a6bdaa5fad873ab94bc4a7b0cc57306a6cd Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 15 Jan 2017 13:23:49 -0600 Subject: [PATCH] Initial commit --- .gitignore | 1 + .zshrc | 82 +++++++++++++++++++++++++++++++++++++++++ README | 4 ++ functions/_fmkrb5 | 5 +++ functions/kadmin | 12 ++++++ functions/precmd | 1 + functions/startrole | 6 +++ functions/switchrealm | 51 +++++++++++++++++++++++++ functions/vi-search-fix | 2 + functions/vmip | 2 + 10 files changed, 166 insertions(+) create mode 100644 .gitignore create mode 100644 .zshrc create mode 100644 README create mode 100644 functions/_fmkrb5 create mode 100644 functions/kadmin create mode 100644 functions/precmd create mode 100644 functions/startrole create mode 100644 functions/switchrealm create mode 100644 functions/vi-search-fix create mode 100644 functions/vmip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dea2d4f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.zcompdump diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..b50a136 --- /dev/null +++ b/.zshrc @@ -0,0 +1,82 @@ +HISTSIZE=SAVEHIST=10000 +HISTFILE=~/.zsh_history +setopt APPEND_HISTORY +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_FIND_NO_DUPS +setopt HIST_IGNORE_SPACE +setopt INTERACTIVE_COMMENTS + +export LESSCOLOR=1 +export PYTHONWARNINGS=default,ignore::ImportWarning +export NOSE_REDNOSE=1 + +bindkey "^?" backward-delete-char +bindkey "^W" backward-kill-word +bindkey -M viins "${terminfo[khome]}" beginning-of-line +bindkey -M vicmd "${terminfo[khome]}" beginning-of-line +bindkey -M viins "^[[H" beginning-of-line +bindkey -M vicmd "^[[H" beginning-of-line +bindkey -M viins "${terminfo[kend]}" end-of-line +bindkey -M vicmd "${terminfo[kend]}" end-of-line +bindkey -M viins "^[[F" end-of-line +bindkey -M vicmd "^[[F" end-of-line +bindkey -M viins "^[[1;5C" vi-forward-word +bindkey -M vicmd "^[[1;5C" vi-forward-word +bindkey -M viins "^[[1;5D" vi-backward-word +bindkey -M vicmd "^[[1;5D" vi-backwardword +bindkey -M viins "${terminfo[kdch1]}" vi-delete-char +bindkey -M vicmd "${terminfo[kdch1]}" vi-delete-char +bindkey "^R" history-incremental-search-backward + +alias rm='rm -I' +alias ls='LC_COLLATE=C ls -N --color=auto --group-directories-first' +alias g='git status' +alias gc='git diff --cached --color|less -S' +alias gd='git diff --color|less -S' +alias gl='git log --graph --oneline --decorate --date-order --all --color|less -S' +alias gs='git show --stat --patch --color HEAD|less -S' +alias hd='hg diff --color=always|less -S' +alias hl='hg shortlog --graph --color=always|less -S' +alias hs='hg export --color=always|less -S' +alias pep8='PYTHONWARNINGS= pep8' +alias pylint='PYTHONWARNINGS= pylint -rn' +alias flake8='PYTHONWARNINGS= flake8' +alias aws='PYTHONWARNINGS= aws' +alias grep='grep --color=auto' +alias rmrpmbuild='rm -rf BUILD BUILDROOT RPMS SRPMS' +alias apache2='/usr/sbin/apache2 -d ~/.local/lib64/apache2 -f httpd.conf' +alias openconnect='/usr/sbin/openconnect -i vpn0 --juniper --syslog -b --pid-file=/tmp/openconnect.pid -u dhatch ssl.firemon.com' +alias ipsec='/usr/sbin/ipsec' + +zstyle ':completion:*:sudo::' environ PATH="/sbin:/usr/sbin:$PATH" HOME="/root" + +typeset -U path +typeset -U fpath + +fpath[1,0]=~/.zsh/functions + +case $TERM in +*xterm*|rxvt) + autoload precmd + ;; +esac + +autoload kadmin +autoload startrole +autoload switchrealm +autoload vmip + +autoload -U compinit promptinit +compinit +promptinit + +os=$(. /etc/os-release; echo $ID) +case ${os} in; +gentoo) + prompt gentoo + ;; +centos|redhat|rhel) + prompt redhat + ;; +esac +unset os diff --git a/README b/README new file mode 100644 index 0000000..5f6be63 --- /dev/null +++ b/README @@ -0,0 +1,4 @@ +Add this line to ~/.zshenv in order to use these ZSH configuration files +without copying/linking them to the "standard" paths: + + export ZDOTDIR=${HOME}/.zsh diff --git a/functions/_fmkrb5 b/functions/_fmkrb5 new file mode 100644 index 0000000..a9ac450 --- /dev/null +++ b/functions/_fmkrb5 @@ -0,0 +1,5 @@ +#compdef fmkrb5 + +_arguments \ + '(-):command: _command_names -e' \ + '*::arguments: _normal' diff --git a/functions/kadmin b/functions/kadmin new file mode 100644 index 0000000..57f0521 --- /dev/null +++ b/functions/kadmin @@ -0,0 +1,12 @@ +# vim: set ft=zsh : +# +kadmin() { + local realm=$(klist | awk -F@ '/Default principal/{print $2}') + if [[ -z ${realm} ]]; then + echo 'could not find realm' + return 1 + fi + command kadmin -r ${realm} +} + +kadmin "$@" diff --git a/functions/precmd b/functions/precmd new file mode 100644 index 0000000..1d04794 --- /dev/null +++ b/functions/precmd @@ -0,0 +1 @@ +print -Pn "\e]0;%n@%m:%~ (%y%)\a" diff --git a/functions/startrole b/functions/startrole new file mode 100644 index 0000000..57bc067 --- /dev/null +++ b/functions/startrole @@ -0,0 +1,6 @@ +# vim: set ft=zsh : + +for arg; do + install -d roles/${arg}/{,tasks,templates,defaults,files,meta,vars,handlers} + touch roles/${arg}/tasks/main.yml +done diff --git a/functions/switchrealm b/functions/switchrealm new file mode 100644 index 0000000..fe37be1 --- /dev/null +++ b/functions/switchrealm @@ -0,0 +1,51 @@ +# vim: set ft=zsh : + +switchrealm() { + local realm principal + + case ${1:l} in + s|sp|securepassage.com) + realm=SECUREPASSAGE.COM + localdomain=${realm:l} + principal=dhatch@${realm} + ;; + d|dev|dev.cloud.frmn) + realm=DEV.CLOUD.FRMN + localdomain=${realm:l} + principal=dhatch@${realm} + ;; + t|test|testing|testing.cloud.frmn) + realm=TESTING.CLOUD.FRMN + localdomain=${realm:l} + principal=dhatch@${realm} + ;; + p|prod|prod.cloud.frmn) + realm=PROD.CLOUD.FRMN + localdomain=${realm:l} + principal=dhatch@${realm} + ;; + *) + realm=${1} + localdomain=${3:-${realm:l}} + ;; + esac + + if [[ -z ${realm} ]]; then + unset KRB5CCNAME + unset LOCALDOMAIN + else + cachefile=/tmp/.krb5cc_$(id -u)_${realm} + export KRB5CCNAME=${cachefile} + export LOCALDOMAIN=${localdomain} + if ! klist -s; then + : ${principal:=${2:-${LOGNAME}}} + if [[ ! ${principal} = *@* ]]; then + principal=${principal}@${realm} + fi + kinit ${principal} + fi + fi + klist +} + +switchrealm "$@" diff --git a/functions/vi-search-fix b/functions/vi-search-fix new file mode 100644 index 0000000..5cb4767 --- /dev/null +++ b/functions/vi-search-fix @@ -0,0 +1,2 @@ +zle vi-cmd-mode +zle .history-incremental-search-backward diff --git a/functions/vmip b/functions/vmip new file mode 100644 index 0000000..3a4d189 --- /dev/null +++ b/functions/vmip @@ -0,0 +1,2 @@ +virsh qemu-agent-command $1 '{"execute":"guest-network-get-interfaces"}' \ + | jq -r '.return | .[] | select(.name=="eth0") | .["ip-addresses"] | .[] | select(.["ip-address-type"] == "ipv6" and (.["ip-address"]|startswith("fe80")|not)) | .["ip-address"]'