summaryrefslogtreecommitdiff
path: root/.zsh/zshrc
diff options
context:
space:
mode:
Diffstat (limited to '.zsh/zshrc')
-rw-r--r--.zsh/zshrc/20_compsys30
-rw-r--r--.zsh/zshrc/30_aliases17
-rw-r--r--.zsh/zshrc/40_history2
-rw-r--r--.zsh/zshrc/70_vcs_info4
-rw-r--r--.zsh/zshrc/80_prompt11
-rw-r--r--.zsh/zshrc/80_python30
-rw-r--r--.zsh/zshrc/90_profiles124
-rw-r--r--.zsh/zshrc/99_fzf22
-rw-r--r--.zsh/zshrc/99_gcloud19
9 files changed, 110 insertions, 149 deletions
diff --git a/.zsh/zshrc/20_compsys b/.zsh/zshrc/20_compsys
index 3da9ea8..712a4ab 100644
--- a/.zsh/zshrc/20_compsys
+++ b/.zsh/zshrc/20_compsys
@@ -9,9 +9,21 @@
# Released under the terms of the Artistic Licence 2.0
#
# Source repository: git://git.distanz.ch/dotfiles/zsh.git
-#
-zstyle :compinstall filename '$ZDOTDIR/zshrc/20_compsys'
+zstyle :compinstall filename "$ZDOTDIR/zshrc/20_compsys"
+
+### INIT
+
+autoload -Uz compinit
+compinit -d $ZVARDIR/comp-$HOST
+
+# load fancy completion list and menu handler
+zmodload zsh/complist
+
+# avoid old-style completion (compctl)
+zstyle ':completion:*' use-compctl false
+
+### OPTIONS
# do not complete just at the end
setopt completeinword
@@ -37,13 +49,6 @@ setopt correct
# be magic about adding/removing final characters on tab completion
setopt auto_param_keys auto_param_slash auto_remove_slash
-# load fancy completion list and menu handler
-zmodload zsh/complist
-
-# initialise the completion system
-autoload -U compinit
-compinit -d $ZVARDIR/comp-$HOST
-
# cache results
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path $ZVARDIR/compcache
@@ -65,7 +70,7 @@ zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' stop yes
# match uppercase from lowercase
-zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
+zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
# ignore working and backup copies, and compiled objects
#zstyle ':completion:*:(all-|)files' ignored-patterns \
@@ -134,6 +139,9 @@ zstyle ':completion:*:manuals.*' insert-sections true
zstyle ':completion:*:man:*' menu yes select
# provide .. as a completion
-zstyle ':completion:*' special-dirs ..
+zstyle ':completion:*' special-dirs true
+
+# automatically load bash completion functions
+autoload -Uz bashcompinit && bashcompinit
# vim:ft=zsh
diff --git a/.zsh/zshrc/30_aliases b/.zsh/zshrc/30_aliases
index 876d26c..6343989 100644
--- a/.zsh/zshrc/30_aliases
+++ b/.zsh/zshrc/30_aliases
@@ -18,8 +18,11 @@ alias ...='cd ../../'
alias cal='cal -m'
alias egrep='egrep --color=auto'
alias grep='grep --color=auto'
-alias m='mount'
-alias u='umount'
+alias ip='ip -color=auto'
+# most often used commands from top10
+alias m='make'
+alias g='git'
+alias v='vim'
# show history with timestamps (taken from oh-my-zsh)
alias history='fc -El 1'
@@ -45,6 +48,14 @@ alias rm='nocorrect rm'
alias pylab='ipython --pylab'
alias qpylab='ipython qtconsole --ConsoleWidget.font_family="Inconsolata" --ConsoleWidget.font_size=11 --colors=Linux --pylab '
+# k8s
+alias k='kubectl'
+alias kw='kubectl -o wide'
+alias ks='kubectl -n kube-system'
+alias ksw='kubectl -n kube-system -o wide'
+alias wk='watch kubectl'
+alias wks='watch kubectl -n kube-system'
+
# get top 10 shell commands
alias top10='print -l ? ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
@@ -52,7 +63,7 @@ alias top10='print -l ? ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
alias bofh='fortune bofh-excuses'
# Quake 3 (on the second screen)
-alias q3='SDL_VIDEO_FULLSCREEN_HEAD=1 ioquake3'
+alias q3='SDL_VIDEO_FULLSCREEN_HEAD=0 ioquake3'
# host aliases
alias distanz="ssh tklauser@distanz.ch -t \"screen -dRU\""
diff --git a/.zsh/zshrc/40_history b/.zsh/zshrc/40_history
index 7017189..0e5241e 100644
--- a/.zsh/zshrc/40_history
+++ b/.zsh/zshrc/40_history
@@ -8,7 +8,7 @@
# Source repository: git://git.distanz.ch/dotfiles/zsh.git
HISTFILE=$HOME/.zsh_history
-HISTSIZE=5000
+HISTSIZE=1000000
SAVEHIST=$HISTSIZE
# append history list to the history file (think multiple zsh sessions)
diff --git a/.zsh/zshrc/70_vcs_info b/.zsh/zshrc/70_vcs_info
index a57a33f..bb37850 100644
--- a/.zsh/zshrc/70_vcs_info
+++ b/.zsh/zshrc/70_vcs_info
@@ -12,9 +12,9 @@ autoload -Uz vcs_info
# http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#SEC273
zstyle ':vcs_info:*' actionformats \
- '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
+ '%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
- '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
+ '%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
# disable some vcs I don't use
diff --git a/.zsh/zshrc/80_prompt b/.zsh/zshrc/80_prompt
index 858c166..2c84f67 100644
--- a/.zsh/zshrc/80_prompt
+++ b/.zsh/zshrc/80_prompt
@@ -18,19 +18,14 @@ PS2='\`%_> '
PS3='?# '
PS4='+%N:%i:%_> '
-# set variable debian_chroot if running in a chroot with /etc/debian_chroot
-if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
-fi
-
# don't use colors on dumb terminals
if [[ "$TERM" == dumb ]] ; then
- PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m%40<...<%B%~%b%<< %# "
+ PROMPT="${EXITCODE}%n@%m%40<...<%B%~%b%<< %# "
else
if (( EUID != 0 )); then
- PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${WHITE}@%m${NO_COLOUR}:%40<...<%B%~%b%<< "'${vcs_info_msg_0_}'"%# " # primary prompt string
+ PROMPT="${RED}${EXITCODE}${WHITE}${RED}%n${WHITE}@%m${NO_COLOUR}:%40<...<%B%~%b%<< "'${vcs_info_msg_0_}'"%# " # primary prompt string
else
- PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m%40<...<%B%~%b%<< %# " # primary prompt string
+ PROMPT="${BLUE}${EXITCODE}${WHITE}${RED}%n${NO_COLOUR}@%m%40<...<%B%~%b%<< %# " # primary prompt string
fi
fi
diff --git a/.zsh/zshrc/80_python b/.zsh/zshrc/80_python
new file mode 100644
index 0000000..6357b52
--- /dev/null
+++ b/.zsh/zshrc/80_python
@@ -0,0 +1,30 @@
+# zshenv/80_python
+#
+# Set up tools related to Python
+#
+# Copyright © 2014-2022 Tobias Klauser <tklauser@distanz.ch>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: git://git.distanz.ch/dotfiles/zsh.git
+
+# see https://opensource.com/article/19/5/python-3-default-mac
+if command -v pyenv 1>/dev/null 2>&1; then
+ eval "$(pyenv init -)"
+fi
+
+# >>> conda initialize >>>
+# !! Contents within this block are managed by 'conda init' !!
+__conda_setup="$('/opt/homebrew/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
+if [ $? -eq 0 ]; then
+ eval "$__conda_setup"
+else
+ if [ -f "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" ]; then
+ . "/opt/homebrew/anaconda3/etc/profile.d/conda.sh"
+ else
+ export PATH="/opt/homebrew/anaconda3/bin:$PATH"
+ fi
+fi
+unset __conda_setup
+# <<< conda initialize <<<
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/90_profiles b/.zsh/zshrc/90_profiles
deleted file mode 100644
index 18ecf00..0000000
--- a/.zsh/zshrc/90_profiles
+++ /dev/null
@@ -1,124 +0,0 @@
-# zshrc/90_profiles
-#
-# set up directory specific variables and options
-#
-# http://michael-prokop.at/blog/2009/05/30/directory-specific-shell-configuration-with-zsh
-#
-# chpwd_profiles taken from grml zshrc
-#
-# Copyright © 2010-2017 Tobias Klauser <tklauser@distanz.ch>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: git://git.distanz.ch/dotfiles/zsh.git
-
-CHPWD_PROFILE='default'
-
-zstyle ':chpwd:profiles:/home/tklauser/go(|/|/*)' profile distanz
-zstyle ':chpwd:profiles:/home/tobiask/go(|/|/*)' profile distanz
-zstyle ':chpwd:profiles:/home/tklauser/src(|/|/*)' profile distanz
-zstyle ':chpwd:profiles:/home/tobiask/src(|/|/*)' profile distanz
-zstyle ':chpwd:profiles:/scratch/tobiask/go(|/|/*)' profile distanz
-zstyle ':chpwd:profiles:/home/tobiask/zi(|/|/*)' profile zhinst
-zstyle ':chpwd:profiles:/scratch/tobiask/zi(|/|/*)' profile zhinst
-zstyle ':chpwd:profiles:/scratch/yocto-zi(|/|/*)' profile zhinst
-
-chpwd_profile_distanz()
-{
- [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
- print "chpwd(): Switching to profile: $profile"
-
- export GIT_AUTHOR_EMAIL="tklauser@distanz.ch"
- export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
-}
-
-chpwd_profile_zhinst()
-{
- [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
- print "chpwd(): Switching to profile: $profile"
-
- export GIT_AUTHOR_EMAIL="tobias.klauser@zhinst.com"
- export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
-}
-
-function chpwd_profiles() {
- # Say you want certain settings to be active in certain directories.
- # This is what you want.
- #
- # zstyle ':chpwd:profiles:/usr/src/grml(|/|/*)' profile grml
- # zstyle ':chpwd:profiles:/usr/src/debian(|/|/*)' profile debian
- #
- # When that's done and you enter a directory that matches the pattern
- # in the third part of the context, a function called chpwd_profile_grml,
- # for example, is called (if it exists).
- #
- # If no pattern matches (read: no profile is detected) the profile is
- # set to 'default', which means chpwd_profile_default is attempted to
- # be called.
- #
- # A word about the context (the ':chpwd:profiles:*' stuff in the zstyle
- # command) which is used: The third part in the context is matched against
- # ${PWD}. That's why using a pattern such as /foo/bar(|/|/*) makes sense.
- # Because that way the profile is detected for all these values of ${PWD}:
- # /foo/bar
- # /foo/bar/
- # /foo/bar/baz
- # So, if you want to make double damn sure a profile works in /foo/bar
- # and everywhere deeper in that tree, just use (|/|/*) and be happy.
- #
- # The name of the detected profile will be available in a variable called
- # 'profile' in your functions. You don't need to do anything, it'll just
- # be there.
- #
- # Then there is the parameter $CHPWD_PROFILE is set to the profile, that
- # was is currently active. That way you can avoid running code for a
- # profile that is already active, by running code such as the following
- # at the start of your function:
- #
- # function chpwd_profile_grml() {
- # [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
- # ...
- # }
- #
- # The initial value for $CHPWD_PROFILE is 'default'.
- #
- # Version requirement:
- # This feature requires zsh 4.3.3 or newer.
- # If you use this feature and need to know whether it is active in your
- # current shell, there are several ways to do that. Here are two simple
- # ways:
- #
- # a) If knowing if the profiles feature is active when zsh starts is
- # good enough for you, you can put the following snippet into your
- # .zshrc.local:
- #
- # (( ${+functions[chpwd_profiles]} )) && print "directory profiles active"
- #
- # b) If that is not good enough, and you would prefer to be notified
- # whenever a profile changes, you can solve that by making sure you
- # start *every* profile function you create like this:
- #
- # function chpwd_profile_myprofilename() {
- # [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
- # print "chpwd(): Switching to profile: $profile"
- # ...
- # }
- #
- # That makes sure you only get notified if a profile is *changed*,
- # not everytime you change directory, which would probably piss
- # you off fairly quickly. :-)
- #
- # There you go. Now have fun with that.
- local -x profile
-
- zstyle -s ":chpwd:profiles:${PWD}" profile profile || profile='default'
- if (( ${+functions[chpwd_profile_$profile]} )) ; then
- chpwd_profile_${profile}
- fi
-
- CHPWD_PROFILE="${profile}"
- return 0
-}
-chpwd_functions=( ${chpwd_functions} chpwd_profiles )
-
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/99_fzf b/.zsh/zshrc/99_fzf
new file mode 100644
index 0000000..f186c06
--- /dev/null
+++ b/.zsh/zshrc/99_fzf
@@ -0,0 +1,22 @@
+# zshenv/99_fzf
+#
+# Set up fzf (https://github.com/junegunn/fzf)
+#
+# Copyright © 2022 Tobias Klauser <tklauser@distanz.ch>
+#
+# Source repository: git://git.distanz.ch/dotfiles/zsh.git
+
+FZF="${HOME}/.fzf"
+# Installed using Homebrew
+[ -d $FZF ] || FZF="/usr/local/opt/fzf"
+[ -d $FZF ] || FZF="/opt/homebrew/opt/fzf"
+
+if [ -d $FZF ] ; then
+ path_append $FZF/bin
+
+ # Auto-completion
+ [[ $- == *i* ]] && source "${FZF}/shell/completion.zsh" 2> /dev/null
+
+ # Key bindings
+ source "${FZF}/shell/key-bindings.zsh"
+fi
diff --git a/.zsh/zshrc/99_gcloud b/.zsh/zshrc/99_gcloud
new file mode 100644
index 0000000..9257ef9
--- /dev/null
+++ b/.zsh/zshrc/99_gcloud
@@ -0,0 +1,19 @@
+# zshrc/99_gcloud
+#
+# Copyright © 2021 Tobias Klauser <tklauser@distanz.ch>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: git://git.distanz.ch/dotfiles/zsh.git
+
+if [ -f /usr/share/google-cloud-sdk/completion.zsh.inc ] ; then
+ source /usr/share/google-cloud-sdk/completion.zsh.inc
+elif [ -f $HOME/google-cloud-sdk/completion.zsh.inc ] ; then
+ source $HOME/google-cloud-sdk/completion.zsh.inc
+fi
+
+if [ -x "$(which gke-gcloud-auth-plugin)" ] ; then
+ # https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
+ export USE_GKE_GCLOUD_AUTH_PLUGIN=True
+fi
+
+# vim:ft=zsh