2015-09-19 21:40:51 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
{
|
2018-01-18 22:53:33 +00:00
|
|
|
|
environment.systemPackages = [ pkgs.fzf ];
|
2015-09-19 21:40:51 +00:00
|
|
|
|
programs.zsh = {
|
|
|
|
|
enable = true;
|
|
|
|
|
shellInit = ''
|
|
|
|
|
#disable config wizard
|
|
|
|
|
zsh-newuser-install() { :; }
|
|
|
|
|
'';
|
|
|
|
|
interactiveShellInit = ''
|
|
|
|
|
setopt autocd extendedglob
|
|
|
|
|
bindkey -e
|
|
|
|
|
|
|
|
|
|
#history magic
|
|
|
|
|
bindkey "[A" up-line-or-local-history
|
|
|
|
|
bindkey "[B" down-line-or-local-history
|
|
|
|
|
|
|
|
|
|
up-line-or-local-history() {
|
|
|
|
|
zle set-local-history 1
|
|
|
|
|
zle up-line-or-history
|
|
|
|
|
zle set-local-history 0
|
|
|
|
|
}
|
|
|
|
|
zle -N up-line-or-local-history
|
|
|
|
|
down-line-or-local-history() {
|
|
|
|
|
zle set-local-history 1
|
|
|
|
|
zle down-line-or-history
|
|
|
|
|
zle set-local-history 0
|
|
|
|
|
}
|
|
|
|
|
zle -N down-line-or-local-history
|
|
|
|
|
|
|
|
|
|
setopt share_history
|
|
|
|
|
setopt hist_ignore_dups
|
|
|
|
|
# setopt inc_append_history
|
|
|
|
|
bindkey '^R' history-incremental-search-backward
|
|
|
|
|
|
|
|
|
|
#C-x C-e open line in editor
|
|
|
|
|
autoload -z edit-command-line
|
|
|
|
|
zle -N edit-command-line
|
|
|
|
|
bindkey "^X^E" edit-command-line
|
|
|
|
|
|
2018-01-18 22:53:33 +00:00
|
|
|
|
#fzf inclusion
|
|
|
|
|
source ${pkgs.fzf}/share/fzf/completion.zsh
|
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
|
|
|
|
|
|
2015-09-19 21:40:51 +00:00
|
|
|
|
#completion magic
|
|
|
|
|
autoload -Uz compinit
|
|
|
|
|
compinit
|
|
|
|
|
zstyle ':completion:*' menu select
|
|
|
|
|
|
|
|
|
|
#enable automatic rehashing of $PATH
|
|
|
|
|
zstyle ':completion:*' rehash true
|
|
|
|
|
|
2018-02-13 16:34:58 +00:00
|
|
|
|
#beautiful colors
|
2018-01-15 23:09:46 +00:00
|
|
|
|
eval $(dircolors -b ${pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "trapd00r";
|
|
|
|
|
repo = "LS_COLORS";
|
2018-05-01 14:04:21 +00:00
|
|
|
|
rev = "a75fca8545f91abb8a5f802981033ef54bf1eac0";
|
|
|
|
|
sha256="1lzj0qnj89mzh76ha137mnz2hf86k278rh0y9x124ghxj9yqsnb4";
|
2018-01-15 23:09:46 +00:00
|
|
|
|
}}/LS_COLORS)
|
2015-09-19 21:40:51 +00:00
|
|
|
|
alias ls='ls --color'
|
2018-02-13 16:34:58 +00:00
|
|
|
|
zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS}
|
2015-09-19 21:40:51 +00:00
|
|
|
|
|
|
|
|
|
#emacs bindings
|
|
|
|
|
bindkey "[7~" beginning-of-line
|
|
|
|
|
bindkey "[8~" end-of-line
|
|
|
|
|
bindkey "Oc" emacs-forward-word
|
|
|
|
|
bindkey "Od" emacs-backward-word
|
|
|
|
|
|
|
|
|
|
#aliases
|
|
|
|
|
alias ll='ls -l'
|
|
|
|
|
alias la='ls -la'
|
|
|
|
|
|
|
|
|
|
#fancy window title magic
|
|
|
|
|
'';
|
|
|
|
|
promptInit = ''
|
2016-06-26 15:10:25 +00:00
|
|
|
|
# TODO: figure out why we need to set this here
|
|
|
|
|
HISTSIZE=900001
|
|
|
|
|
HISTFILESIZE=$HISTSIZE
|
|
|
|
|
SAVEHIST=$HISTSIZE
|
|
|
|
|
|
2015-09-19 21:40:51 +00:00
|
|
|
|
autoload -U promptinit
|
|
|
|
|
promptinit
|
|
|
|
|
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_error='%(?..%F{red}%?%f )'
|
|
|
|
|
t_error='%(?..%? )'
|
2015-09-19 21:40:51 +00:00
|
|
|
|
|
|
|
|
|
case $UID in
|
|
|
|
|
0)
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_username='%F{red}root%f'
|
|
|
|
|
t_username='root'
|
2015-09-19 21:40:51 +00:00
|
|
|
|
;;
|
|
|
|
|
1337)
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_username=""
|
|
|
|
|
t_username=""
|
2015-09-19 21:40:51 +00:00
|
|
|
|
;;
|
|
|
|
|
*)
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_username='%F{blue}%n%f'
|
|
|
|
|
t_username='%n'
|
2015-09-19 21:40:51 +00:00
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if test -n "$SSH_CLIENT"; then
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_hostname='@%F{magenta}%M%f '
|
|
|
|
|
t_hostname='@%M '
|
|
|
|
|
else
|
|
|
|
|
p_hostname=""
|
|
|
|
|
t_hostname=""
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#check if in nix shell
|
2018-02-13 16:35:21 +00:00
|
|
|
|
if test -n "$IN_NIX_SHELL"; then
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_nixshell='%F{green}[s]%f '
|
|
|
|
|
t_nixshell='[s] '
|
2015-09-19 21:40:51 +00:00
|
|
|
|
else
|
2018-01-22 17:05:43 +00:00
|
|
|
|
p_nixshell=""
|
|
|
|
|
t_nixshell=""
|
2015-09-19 21:40:51 +00:00
|
|
|
|
fi
|
2018-01-22 17:05:43 +00:00
|
|
|
|
|
|
|
|
|
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
|
2015-09-19 21:40:51 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
2018-01-22 17:05:43 +00:00
|
|
|
|
environment.shellAliases.ns = "nix-shell --command zsh";
|
|
|
|
|
|
2018-01-30 17:15:57 +00:00
|
|
|
|
users.defaultUserShell = "/run/current-system/sw/bin/zsh";
|
2015-09-19 21:40:51 +00:00
|
|
|
|
}
|