2015-08-23 02:48:35 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
##
|
2016-10-20 20:54:38 +02:00
|
|
|
with import <stockholm/lib>;
|
2015-08-23 02:48:35 +02:00
|
|
|
let
|
|
|
|
mainUser = config.krebs.build.user.name;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
users.extraUsers.${mainUser}.shell = "/run/current-system/sw/bin/zsh";
|
2015-12-15 15:33:34 +01:00
|
|
|
programs.zsh= {
|
|
|
|
enable = true;
|
2017-12-08 14:30:44 +01:00
|
|
|
enableCompletion = true ; #manually at the end
|
2015-12-15 15:33:34 +01:00
|
|
|
interactiveShellInit = ''
|
|
|
|
HISTSIZE=900001
|
|
|
|
HISTFILESIZE=$HISTSIZE
|
|
|
|
SAVEHIST=$HISTSIZE
|
2017-12-08 14:30:44 +01:00
|
|
|
HISTFILE=$HOME/.zsh_history
|
2015-12-15 15:33:34 +01:00
|
|
|
|
|
|
|
setopt HIST_IGNORE_ALL_DUPS
|
|
|
|
setopt HIST_IGNORE_SPACE
|
|
|
|
setopt HIST_FIND_NO_DUPS
|
|
|
|
bindkey -e
|
|
|
|
# shift-tab
|
|
|
|
bindkey '^[[Z' reverse-menu-complete
|
2016-01-13 23:20:40 +01:00
|
|
|
bindkey "\e[3~" delete-char
|
2015-12-15 15:33:34 +01:00
|
|
|
zstyle ':completion:*' menu select
|
2015-12-16 11:40:48 +01:00
|
|
|
|
2016-07-22 12:35:06 +02:00
|
|
|
${pkgs.gnupg}/bin/gpg-connect-agent updatestartuptty /bye >/dev/null
|
2016-07-21 02:04:45 +02:00
|
|
|
GPG_TTY=$(tty)
|
|
|
|
export GPG_TTY
|
2017-01-11 11:01:30 +01:00
|
|
|
LS_COLORS=$LS_COLORS:'di=1;31:' ; export LS_COLORS
|
|
|
|
|
2016-07-21 02:04:45 +02:00
|
|
|
unset SSH_AGENT_PID
|
|
|
|
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
2017-07-23 18:46:48 +02:00
|
|
|
|
|
|
|
# fzf
|
|
|
|
__fsel_fzf() {
|
|
|
|
local cmd="''${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
|
|
|
-o -type f -print \
|
|
|
|
-o -type d -print \
|
|
|
|
-o -type l -print 2> /dev/null | cut -b3-"}"
|
|
|
|
setopt localoptions pipefail 2> /dev/null
|
|
|
|
eval "$cmd" | FZF_DEFAULT_OPTS="--height ''${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
|
|
|
|
echo -n "''${(q)item} "
|
|
|
|
done
|
|
|
|
local ret=$?
|
|
|
|
echo
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
__fzf_use_tmux__() {
|
|
|
|
[ -n "$TMUX_PANE" ] && [ "''${FZF_TMUX:-0}" != 0 ] && [ ''${LINES:-40} -gt 15 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
__fzfcmd() {
|
|
|
|
__fzf_use_tmux__ &&
|
|
|
|
echo "fzf-tmux -d''${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
|
|
|
|
}
|
|
|
|
|
|
|
|
fzf-file-widget() {
|
|
|
|
LBUFFER="''${LBUFFER}$(__fsel_fzf)"
|
|
|
|
local ret=$?
|
|
|
|
zle redisplay
|
|
|
|
typeset -f zle-line-init >/dev/null && zle zle-line-init
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
zle -N fzf-file-widget
|
|
|
|
bindkey '^T' fzf-file-widget
|
|
|
|
|
|
|
|
compdef _pass brain
|
|
|
|
zstyle ':completion::complete:brain::' prefix "$HOME/brain"
|
2018-09-16 00:26:42 +02:00
|
|
|
compdef _pass secrets
|
|
|
|
zstyle ':completion::complete:secrets::' prefix "$HOME/.secrets-pass/"
|
2017-12-08 14:30:44 +01:00
|
|
|
|
|
|
|
# ctrl-x ctrl-e
|
|
|
|
autoload -U edit-command-line
|
|
|
|
zle -N edit-command-line
|
|
|
|
bindkey '^xe' edit-command-line
|
|
|
|
bindkey '^x^e' edit-command-line
|
|
|
|
|
2017-07-23 18:46:48 +02:00
|
|
|
'';
|
2015-12-15 15:33:34 +01:00
|
|
|
|
|
|
|
promptInit = ''
|
|
|
|
RPROMPT=""
|
|
|
|
autoload colors && colors
|
|
|
|
case $UID in
|
|
|
|
0) PROMPT="%{$fg[red]%}%~%{$reset_color%} " ;;
|
|
|
|
9001) PROMPT="%{$fg[green]%}%~%{$reset_color%} " ;;
|
|
|
|
*) PROMPT="%{$fg[yellow]%}%n %{$fg[green]%}%~%{$reset_color%} " ;;
|
|
|
|
esac
|
|
|
|
if test -n "$SSH_CLIENT"; then
|
|
|
|
PROMPT="%{$fg[magenta]%}%m $PROMPT"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2017-05-19 11:53:44 +02:00
|
|
|
|
2017-09-04 15:00:06 +02:00
|
|
|
users.users.${mainUser}.packages = [
|
2017-05-19 11:53:44 +02:00
|
|
|
pkgs.nix-zsh-completions
|
2017-07-23 18:46:48 +02:00
|
|
|
pkgs.fzf
|
2017-05-19 11:53:44 +02:00
|
|
|
];
|
2015-08-23 02:48:35 +02:00
|
|
|
}
|