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 From df18d18ab36953a6c4179d5cb638e1d99d2ee182 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 13 Feb 2018 17:34:58 +0100 Subject: l zsh: add LS_COLORS in zsh menu --- lass/2configs/zsh.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index add30fbf..0a32ce51 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -50,16 +50,15 @@ #enable automatic rehashing of $PATH zstyle ':completion:*' rehash true + #beautiful colors eval $(dircolors -b ${pkgs.fetchFromGitHub { owner = "trapd00r"; repo = "LS_COLORS"; rev = "master"; sha256="05lh5w3bgj9h8d8lrbbwbzw8788709cnzzkl8yh7m1dawkpf6nlp"; }}/LS_COLORS) - - #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 -- cgit v1.2.3 From f7606723eddae1e6a70a4b6374a950ed3503346a Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 13 Feb 2018 17:35:21 +0100 Subject: l zsh: check for --- lass/2configs/zsh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lass/2configs/zsh.nix') diff --git a/lass/2configs/zsh.nix b/lass/2configs/zsh.nix index 0a32ce51..aa3e6731 100644 --- a/lass/2configs/zsh.nix +++ b/lass/2configs/zsh.nix @@ -108,7 +108,7 @@ fi #check if in nix shell - if test -n "$buildInputs"; then + if test -n "$IN_NIX_SHELL"; then p_nixshell='%F{green}[s]%f ' t_nixshell='[s] ' else -- cgit v1.2.3