about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2014-10-13 05:27:24 +0200
committeraszlig <aszlig@redmoonstudios.org>2014-10-13 05:27:24 +0200
commit37a57d2753f84c809a470693ad3afb6c4e791ade (patch)
treee434a2a28283309b42bd39aa7c4e7f0b4e778457
parentda03760eeb325a48e2fd743af3e7e89cfd204390 (diff)
common-workstation: Add zsh configuration.
I'm tired of copying around my zsh configuration file, which I didn't
include in my NixOS configurations because it was quite messy so far.

It is still a bit messy, but at least most of the old crap is gone now,
and we're using programs.zsh to configure it.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
-rw-r--r--common-workstation.nix1
-rw-r--r--zsh.nix86
2 files changed, 87 insertions, 0 deletions
diff --git a/common-workstation.nix b/common-workstation.nix
index a6ae7839..b5f3eff6 100644
--- a/common-workstation.nix
+++ b/common-workstation.nix
@@ -4,6 +4,7 @@
   imports = [
     ./common.nix
     ./packages.nix
+    ./zsh.nix
     <nixpkgs/nixos/modules/programs/virtualbox.nix>
   ];
 
diff --git a/zsh.nix b/zsh.nix
new file mode 100644
index 00000000..d700d42a
--- /dev/null
+++ b/zsh.nix
@@ -0,0 +1,86 @@
+{ lib, ... }:
+
+{
+  environment.shellInit = ''
+    export EDITOR="vim"
+    export EMAIL="aszlig@redmoonstudios.org"
+    export AUDIOSERVER="tcp/linx:8000"
+    export SCUMMVM_PORT="128:0"
+  '';
+
+  programs.zsh.enable = true;
+
+  programs.zsh.shellAliases.t = "task";
+
+  programs.zsh.shellInit = "zsh-newuser-install() { :; }";
+
+  programs.zsh.interactiveShellInit = lib.mkAfter ''
+    export HISTFILE=~/.histfile
+    export HISTSIZE=100000
+    export SAVEHIST=100000
+
+    setopt extendedglob
+    setopt extendedhistory
+    setopt globcomplete
+    setopt histnostore
+    setopt histreduceblanks
+    setopt correct
+    setopt dvorak
+    setopt interactivecomments
+    setopt autopushd
+    setopt autocd
+    setopt beep
+
+    bindkey -v
+    if [[ "$TERM" = xterm ]]; then
+      bindkey -v '\e[H' vi-beginning-of-line
+      bindkey -v '\e[F' vi-end-of-line
+    else
+      bindkey -v '\e[1~' vi-beginning-of-line
+      bindkey -v '\e[4~' vi-end-of-line
+    fi
+
+    bindkey -a '/' history-incremental-pattern-search-backward
+    bindkey -a '?' history-incremental-pattern-search-forward
+    bindkey '\e[A' up-line-or-history
+    bindkey '\e[B' down-line-or-history
+
+    zstyle ':completion:*' completer _expand _complete _ignored _approximate
+    zstyle ':completion:*' expand prefix suffix
+    zstyle ':completion:*' group-name '''
+    zstyle ':completion:*' insert-unambiguous true
+    zstyle ':completion:*' list-colors '''
+    zstyle ':completion:*' list-prompt \
+      %SAt %p: Hit TAB for more, or the character to insert%s
+    zstyle ':completion:*' list-suffixes true
+    zstyle ':completion:*' matcher-list ''' \
+      'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]}' \
+      'l:|=* r:|=*' 'r:|[._-]=** r:|=**'
+    zstyle ':completion:*' max-errors 2 numeric
+    zstyle ':completion:*' menu select=long
+    zstyle ':completion:*' original true
+    zstyle ':completion:*' preserve-prefix '//[^/]##/'
+    zstyle ':completion:*' prompt \
+      'Hm, did you mistype something? There are %e errors in the completion.'
+    zstyle ':completion:*' select-prompt \
+      %SScrolling active: current selection at %p%s
+    zstyle ':completion:*' use-compctl false
+    zstyle ':completion:*' verbose true
+
+    autoload -Uz compinit
+    compinit
+
+    autoload -Uz zmv
+  '';
+
+  programs.zsh.promptInit = ''
+    autoload -Uz prompt_special_chars
+
+    () {
+        local p_machine='%(!..%B%F{red}%n%b%F{blue}@)%b%F{red}%m'
+        local p_path='%B%F{blue}[%F{cyan}%~%B%F{blue}]'
+        local p_exitcode='%F{green}%?%(!.%F{cyan}>.%b%F{green}>)%b%f '
+        PROMPT="$p_machine$p_path$p_exitcode"
+    }
+  '';
+}