]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - shell/zsh/rc
shell: set GOTOOLCHAIN=local
[config/dotfiles.git] / shell / zsh / rc
index 7222619ca0b86c08de528ba30bc082951f3174a2..515ae9bd30c64fb2704e65e87804e45eb429811f 100644 (file)
@@ -1,6 +1,6 @@
 # Zsh configuration file.
 
-# Copyright (C) 2011-2014  Simon Ruderich
+# Copyright (C) 2011-2018  Simon Ruderich
 #
 # This file is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -108,8 +108,10 @@ fi
 # functions).
 fpath=(~/.zsh/functions $fpath)
 # Autoload my functions (except completion functions and hidden files). Thanks
-# to caphuso from the Zsh example files for this idea.
-if [[ -d ~/.zsh/functions ]]; then
+# to caphuso from the Zsh example files for this idea. Check if there are any
+# functions to load or autoload fails; thanks to okdana in #zsh on Freenode
+# (2018-07-18 09:29 CEST) for the idea to use (#qNY1) for the check.
+if [[ -d ~/.zsh/functions && -n ${fpath[1]}/^_*(#qNY1^/:t) ]]; then
     autoload -Uz ${fpath[1]}/^_*(^/:t)
 fi
 
@@ -182,6 +184,13 @@ bindkey -a '^P' history-beginning-search-backward # binding for Vi-mode
 # after calling ^P.
 bindkey -a '^N' history-beginning-search-forward
 
+# Use current input when pressing Ctrl-R. Thanks to Mikachu in #zsh on
+# Freenode (2016-07-08 20:54 CEST).
+zshrc-history-incremental-pattern-search-backward() {
+    zle .history-incremental-pattern-search-backward $BUFFER
+}
+zle -N history-incremental-pattern-search-backward \
+    zshrc-history-incremental-pattern-search-backward
 # Enable incremental search which is especially useful when the string is an
 # argument and not the command.
 bindkey '^R' history-incremental-pattern-search-backward
@@ -219,6 +228,9 @@ local green="%{${fg[green]}%}"
 local yellow="%{${fg[yellow]}%}"
 local default="%{${fg[default]}%}"
 
+# Linux network namespace
+local netns="$(ip netns identify 2>/dev/null)"
+
 # vcs_info was added in 4.3.9 but it works in earlier versions too. So load it
 # if the necessary files are available in ~/.zsh/functions/vcs_info (often a
 # symbolic link to current checkout of Zsh's sources).
@@ -432,6 +444,10 @@ zshrc_prompt_precmd() {
     if [[ -n $SSH_CONNECTION ]]; then
         host="%U${host}%u"
     fi
+    # Linux network namespace if any
+    if [[ -n $netns ]]; then
+        host="${host}[$netns]"
+    fi
 
     # Number of background processes in yellow if not zero.
     local background="%(1j.${yellow}%j${default}.)"
@@ -790,7 +806,6 @@ bindkey '^F' complete-files
 compdef slocate=locate
 compdef srsync=rsync
 compdef srsync-incremental=rsync
-compdef svalgrind=valgrind
 compdef sc=systemctl
 
 
@@ -847,7 +862,7 @@ alias -g S='| sort'
 alias -g SL='| sort | less'
 alias -g T='| tail'
 alias -g U='| uniq'
-alias -g X='`xsel -p || xclip -o`' # X selection
+alias -g X='-- "$(xsel -p || xclip -o)"' # X selection
 
 # Make going up directories simple.
 alias -g ...='../..'