From 5f21ebc0d3539276ccee967dd510e7aba8b31c0c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 3 Jan 2021 22:37:27 +0100 Subject: zsh customization --- user-profiles/zsh/default.nix | 1 + user-profiles/zsh/p10k.zsh | 11 +++++++++-- user-profiles/zsh/zshrc | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 user-profiles/zsh/zshrc (limited to 'user-profiles/zsh') diff --git a/user-profiles/zsh/default.nix b/user-profiles/zsh/default.nix index 58fa0376..88873c1a 100644 --- a/user-profiles/zsh/default.nix +++ b/user-profiles/zsh/default.nix @@ -21,6 +21,7 @@ in { source "${cfg.home.homeDirectory}/${p10kZsh}" ''; initExtra = lib.mkAfter '' + source ${./zshrc} source "${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ''; }; diff --git a/user-profiles/zsh/p10k.zsh b/user-profiles/zsh/p10k.zsh index fb9af12c..ff66f0df 100644 --- a/user-profiles/zsh/p10k.zsh +++ b/user-profiles/zsh/p10k.zsh @@ -37,6 +37,7 @@ vcs # git status # =========================[ Line #2 ]========================= newline # \n + dir prompt_char # prompt symbol ) @@ -100,6 +101,9 @@ time # current time # =========================[ Line #2 ]========================= newline + status + command_execution_time + time # ip # ip address and bandwidth usage for a specified network interface # public_ip # public IP address # proxy # system-wide http/https/ftp proxy @@ -500,7 +504,7 @@ # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as # it will signify error by turning red. - typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR=true typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' @@ -1540,7 +1544,10 @@ # - always: Trim down prompt when accepting a command line. # - same-dir: Trim down prompt when accepting a command line unless this is the first command # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off + + function p10k-on-pre-prompt() { p10k display '1'=show '2/left/dir'=hide '2/right/(status|command_execution_time|time)'=hide } + function p10k-on-post-prompt() { p10k display '2/left/(dir|prompt_char)'=show 'empty_line|1'=hide '2/right/(status|command_execution_time|time)'=show } # Instant prompt mode. # diff --git a/user-profiles/zsh/zshrc b/user-profiles/zsh/zshrc new file mode 100644 index 00000000..3660ef27 --- /dev/null +++ b/user-profiles/zsh/zshrc @@ -0,0 +1,26 @@ +fancy-ctrl-z () { + emulate -LR zsh + if [[ $#BUFFER -eq 0 ]]; then + [[ -n $(jobs -s) ]] && bg + zle redisplay + else + zle push-input + fi +} +zle -N fancy-ctrl-z +bindkey '^Z' fancy-ctrl-z + +function fancy-ctrl-d() { + zle || exit 0 + [[ -n $BUFFER ]] && return + typeset -g precmd_functions=(fancy-ctrl-d) + zle accept-line +} +zle -N fancy-ctrl-d +bindkey '^D' fancy-ctrl-d +setopt ignore_eof + +# word navigation for urxvt +bindkey -e +bindkey ';5C' emacs-forward-word +bindkey ';5D' emacs-backward-word \ No newline at end of file -- cgit v1.2.3