From a3751cdb4731ff238d02e1e0e84bbe8aaa9217ac Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 16 Jan 2018 00:09:46 +0100 Subject: l zsh: cleanup --- lass/2configs/zsh.nix | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index 4d33aa79..728c0cc0 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -7,10 +7,8 @@ zsh-newuser-install() { :; } ''; interactiveShellInit = '' - #unsetopt nomatch setopt autocd extendedglob bindkey -e - zstyle :compinstall filename '/home/lass/.zshrc' #history magic bindkey "" up-line-or-local-history @@ -40,7 +38,6 @@ bindkey "^X^E" edit-command-line #completion magic - fpath=(~/.zsh/completions $fpath) autoload -Uz compinit compinit zstyle ':completion:*' menu select @@ -48,14 +45,18 @@ #enable automatic rehashing of $PATH zstyle ':completion:*' rehash true - - #eval $( dircolors -b ~/.LS_COLORS ) + eval $(dircolors -b ${pkgs.fetchFromGitHub { + owner = "trapd00r"; + repo = "LS_COLORS"; + rev = "master"; + sha256="05lh5w3bgj9h8d8lrbbwbzw8788709cnzzkl8yh7m1dawkpf6nlp"; + }}/LS_COLORS) # export MANPAGER='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | vim -R -c "set ft=man nonu nomod nolist" -' #beautiful colors alias ls='ls --color' - zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS} + # zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS} #emacs bindings bindkey "[7~" beginning-of-line @@ -66,24 +67,24 @@ #aliases alias ll='ls -l' alias la='ls -la' - alias pinginet='ping 8.8.8.8' - alias du='du -hd1' - alias qiv="qiv -f -m" - alias zshres="source ~/.zshrc" #fancy window title magic case $TERM in (*xterm* | *rxvt*) - - # Write some info to terminal title. - # This is seen when the shell prompts for input. function precmd { - print -Pn "\e]0;%(1j,%j job%(2j|s|); ,)%~\a" + if test -n "$SSH_CLIENT"; then + echo -ne "\033]0;$$ $USER@$HOST $PWD\007" + else + echo -ne "\033]0;$$ $USER@$PWD\007" + fi } - # Write command and args to terminal title. # This is seen while the shell waits for a command to complete. function preexec { - printf "\033]0;%s\a" "$1" + if test -n "$SSH_CLIENT"; then + echo -ne "\033]0;$$ $USER@$HOST $PWD $1\007" + else + echo -ne "\033]0;$$ $USER@$PWD $1\007" + fi } ;; esac @@ -119,4 +120,5 @@ ''; }; users.users.mainUser.shell = "/run/current-system/sw/bin/zsh"; + users.users.root.shell = "/run/current-system/sw/bin/zsh"; } -- cgit v1.2.3 From 26db462bb278d01d42f052e8c3207cd515dee98e Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 18 Jan 2018 23:53:33 +0100 Subject: l zsh: add fzf --- lass/2configs/zsh.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index 728c0cc0..7b0ef79f 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -1,5 +1,6 @@ { config, lib, pkgs, ... }: { + environment.systemPackages = [ pkgs.fzf ]; programs.zsh = { enable = true; shellInit = '' @@ -37,6 +38,10 @@ zle -N edit-command-line bindkey "^X^E" edit-command-line + #fzf inclusion + source ${pkgs.fzf}/share/fzf/completion.zsh + source ${pkgs.fzf}/share/fzf/key-bindings.zsh + #completion magic autoload -Uz compinit compinit @@ -52,8 +57,6 @@ sha256="05lh5w3bgj9h8d8lrbbwbzw8788709cnzzkl8yh7m1dawkpf6nlp"; }}/LS_COLORS) - # export MANPAGER='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | vim -R -c "set ft=man nonu nomod nolist" -' - #beautiful colors alias ls='ls --color' # zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS} -- cgit v1.2.3 From 697b202e25d9c738e6d5ebf265f1005520cfb1ac Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 22 Jan 2018 18:05:43 +0100 Subject: l zsh: use zsh in nix-shell & better prompt --- lass/2configs/zsh.nix | 64 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 25 deletions(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index 7b0ef79f..f2c32ba2 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -72,25 +72,6 @@ alias la='ls -la' #fancy window title magic - case $TERM in - (*xterm* | *rxvt*) - function precmd { - if test -n "$SSH_CLIENT"; then - echo -ne "\033]0;$$ $USER@$HOST $PWD\007" - else - echo -ne "\033]0;$$ $USER@$PWD\007" - fi - } - # This is seen while the shell waits for a command to complete. - function preexec { - if test -n "$SSH_CLIENT"; then - echo -ne "\033]0;$$ $USER@$HOST $PWD $1\007" - else - echo -ne "\033]0;$$ $USER@$PWD $1\007" - fi - } - ;; - esac ''; promptInit = '' # TODO: figure out why we need to set this here @@ -101,27 +82,60 @@ autoload -U promptinit promptinit - error='%(?..%F{red}%?%f )' + p_error='%(?..%F{red}%?%f )' + t_error='%(?..%? )' case $UID in 0) - username='%F{red}root%f ' + p_username='%F{red}root%f' + t_username='root' ;; 1337) - username="" + p_username="" + t_username="" ;; *) - username='%F{blue}%n%f ' + p_username='%F{blue}%n%f' + t_username='%n' ;; esac if test -n "$SSH_CLIENT"; then - PROMPT="$error$username@%F{magenta}%M%f %~ " + p_hostname='@%F{magenta}%M%f ' + t_hostname='@%M ' + else + p_hostname="" + t_hostname="" + fi + + #check if in nix shell + if test -n "$buildInputs"; then + p_nixshell='%F{green}[s]%f ' + t_nixshell='[s] ' else - PROMPT="$error$username%~ " + p_nixshell="" + t_nixshell="" fi + + PROMPT="$p_error$p_username$p_hostname$p_nixshell%~ " + TITLE="$t_error$t_username$t_hostname$t_nixshell%~" + case $TERM in + (*xterm* | *rxvt*) + function precmd { + PROMPT_EVALED="$(print -P $TITLE)" + echo -ne "\033]0;$$ $PROMPT_EVALED\007" + } + # This is seen while the shell waits for a command to complete. + function preexec { + PROMPT_EVALED="$(print -P $TITLE)" + echo -ne "\033]0;$$ $PROMPT_EVALED $1\007" + } + ;; + esac ''; }; + environment.shellAliases.ns = "nix-shell --command zsh"; + users.users.mainUser.shell = "/run/current-system/sw/bin/zsh"; users.users.root.shell = "/run/current-system/sw/bin/zsh"; } -- cgit v1.2.3 From 7b49153a48924274a9174002e766b9f56b532ba2 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 30 Jan 2018 18:15:57 +0100 Subject: l zsh: set as default shell for everyone --- lass/2configs/zsh.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index f2c32ba2..add30fbf 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -136,6 +136,5 @@ }; environment.shellAliases.ns = "nix-shell --command zsh"; - users.users.mainUser.shell = "/run/current-system/sw/bin/zsh"; - users.users.root.shell = "/run/current-system/sw/bin/zsh"; + users.defaultUserShell = "/run/current-system/sw/bin/zsh"; } -- cgit v1.2.3