Browse Source

Various cleanups in zsh config

Emmanuel Bouthenot 8 years ago
parent
commit
b1bf949f09
6 changed files with 39 additions and 35 deletions
  1. 17 0
      .zsh/config/01_presto.zsh
  2. 13 0
      .zsh/config/02_runasroot.zsh
  3. 3 2
      .zsh/config/10_alias.zsh
  4. 0 4
      .zsh/config/50_debian.zsh
  5. 3 0
      .zshenv
  6. 3 29
      .zshrc

+ 17 - 0
.zsh/config/01_presto.zsh

@@ -0,0 +1,17 @@
+#
+# Load prezto
+#
+
+BUNDLES_ROOT="${ZSHDOTDIR}/bundles"
+PREZTO_INIT="${BUNDLES_ROOT}/prezto/init.zsh"
+if [ -f "${PREZTO_INIT}" ]; then
+    export ZDOTDIR="${BUNDLES_ROOT}"
+    source "${PREZTO_INIT}"
+    unset ZDOTDIR
+fi
+unset BUNDLES_ROOT PREZTO_INIT
+
+# Fix some prezto defaults
+if (( $+aliases[debi] )); then
+    unalias debi
+fi

+ 13 - 0
.zsh/config/02_runasroot.zsh

@@ -0,0 +1,13 @@
+#
+# Use the user zsh configuration as root
+#
+
+if [[ "$SUDO_USER" ]] && [[ "$UID" = 0 ]]; then
+    # define root history path
+    export HISTFILE="$ZSHDOTDIR/history/history_root"
+    if [[ -f ~/.zcompdump ]]; then
+        # ugly hack : reset some file perms to normal to avoid warnings
+        chmod 0644 ~/.zcompdump
+        chown "$SUDO_USER:$SUDO_USER" ~/.zcompdump
+    fi
+fi

+ 3 - 2
.zsh/config/10_alias.zsh

@@ -32,8 +32,9 @@ alias cp='cp -i'
 alias vlock='clear;vlock'
 alias q='clear;exit'
 
-export GREP_OPTIONS="--color=auto"
-alias mgrep="grep -rnisH"
+alias grep="grep --color=auto"
+alias egrep="egrep --color=auto"
+alias mgrep="grep -rnisH --color=auto"
 
 alias rsu="sudo -E zsh"
 alias reloadsh="exec zsh"

+ 0 - 4
.zsh/config/50_debian.zsh

@@ -20,10 +20,6 @@ alias dbuild="time debuild -eDEB_BUILD_OPTIONS='parallel=9' -i -us -uc --lintian
 alias apt-show-obsolete="aptitude search '?obsolete'"
 alias apt-purge-obsolete="apt-get --purge remove $(aptitude search '?obsolete' -F '%p' | xargs)"
 
-
-# fix some zpresto aliases
-unalias debi
-
 apt-rbdepends() {
     grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
 }

+ 3 - 0
.zshenv

@@ -2,6 +2,9 @@
 # Environment variables
 #
 
+# PATH
+export PATH="${HOME}/bin:${HOME}/.bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+
 # LANG settings
 export LANG=fr_FR.UTF-8
 export LC_MESSAGES=en_US.UTF-8

+ 3 - 29
.zshrc

@@ -6,40 +6,14 @@
 #  but WITHOUT ANY WARRANTY
 #
 
-# define personal zsh config directory
+# Define personal zsh config directory
 export ZSHDOTDIR="${HOME}/.zsh"
 
-# redefine PATH
-export PATH="${HOME}/bin:${HOME}/.bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
-
-# load prezto
-BUNDLES_ROOT="${ZSHDOTDIR}/bundles"
-PREZTO_INIT="${BUNDLES_ROOT}/prezto/init.zsh"
-if [ -f "${PREZTO_INIT}" ]; then
-    export ZDOTDIR="${BUNDLES_ROOT}"
-    source "${PREZTO_INIT}"
-    unset ZDOTDIR
-fi
-unset BUNDLES_ROOT PREZTO_INIT
-
-# overide insecure stuff with compinit while using 'sudo zsh'
-# my functions (don't forget to modify fpath before call compinit !!)
-#if [ -z "$SUDO_USER" -a "$UID" != 0 ]; then
-#    fpath=($ZSHDOTDIR/functions.d $fpath)
-#fi
-
-# include custom configuration
+# Include custom configuration
 for f in ${ZSHDOTDIR}/config/*.zsh; do
     if [[ -r "${f}" ]]; then
         . "${f}"
     fi
 done
 
-# using 'sudo zsh'
-if [ "$SUDO_USER" -a "$UID" = 0 ]; then
-    # define root history path
-    export HISTFILE="$ZSHDOTDIR/history/history_root"
-    # ugly hack : reset some file perms to normal to avoid warnings
-    chmod 0644 ~/.zcompdump
-    chown "$SUDO_USER:$SUDO_USER" ~/.zcompdump
-fi
+unset ZSHDOTDIR