This repository has no description
3.8 kB
147 lines
1{ pkgs, ... }:
2{
3 environment.systemPackages = with pkgs; [
4 atuin
5 direnv
6 fzf
7 ];
8 environment.variables.ATUIN_CONFIG_DIR = toString (
9 pkgs.writeTextDir "/config.toml" ''
10 auto_sync = true
11 update_check = false
12 sync_address = "http://green.r:8888"
13 sync_frequency = 0
14 style = "compact"
15 ''
16 );
17 programs.zsh = {
18 enable = true;
19 shellInit = ''
20 #disable config wizard
21 zsh-newuser-install() { :; }
22 '';
23 interactiveShellInit = ''
24 unsetopt nomatch # no matches found urls
25 setopt autocd extendedglob
26 bindkey -e
27
28
29 # # setopt inc_append_history
30 # bindkey '^R' history-incremental-search-backward
31
32 #C-x C-e open line in editor
33 autoload -z edit-command-line
34 zle -N edit-command-line
35 bindkey "^X^E" edit-command-line
36
37 #fzf inclusion
38 eval "$(${pkgs.fzf}/bin/fzf --zsh)"
39
40 # atuin distributed shell history
41 export ATUIN_NOBIND="true" # disable all keybdinings of atuin
42 eval "$(atuin init zsh)"
43 bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin
44 # use zsh only session history
45 fc -p
46
47 #completion magic
48 autoload -Uz compinit
49 compinit
50 zstyle ':completion:*' menu select
51
52 #enable automatic rehashing of $PATH
53 zstyle ':completion:*' rehash true
54
55 # fancy mv which interactively gets the second argument if not given
56 function mv() {
57 if [[ "$#" -ne 1 ]] || [[ ! -e "$1" ]]; then
58 command mv -v "$@"
59 return
60 fi
61
62 newfilename="$1"
63 vared newfilename
64 command mv -v -- "$1" "$newfilename"
65 }
66
67 #beautiful colors
68 eval $(dircolors -b ${
69 pkgs.fetchFromGitHub {
70 owner = "trapd00r";
71 repo = "LS_COLORS";
72 rev = "a75fca8545f91abb8a5f802981033ef54bf1eac0";
73 sha256 = "1lzj0qnj89mzh76ha137mnz2hf86k278rh0y9x124ghxj9yqsnb4";
74 }
75 }/LS_COLORS)
76 zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS}
77
78 #emacs bindings
79 bindkey "[7~" beginning-of-line
80 bindkey "[8~" end-of-line
81 bindkey "Oc" emacs-forward-word
82 bindkey "Od" emacs-backward-word
83
84 # direnv integration
85 eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
86 '';
87 promptInit = ''
88 autoload -U promptinit
89 promptinit
90
91 p_error='%(?..%F{red}%?%f )'
92 t_error='%(?..%? )'
93
94 case $UID in
95 0)
96 p_username='%F{red}root%f'
97 t_username='root'
98 ;;
99 1337)
100 p_username=""
101 t_username=""
102 ;;
103 *)
104 p_username='%F{blue}%n%f'
105 t_username='%n'
106 ;;
107 esac
108
109 if test -n "$SSH_CLIENT"; then
110 p_hostname='@%F{magenta}%M%f '
111 t_hostname='@%M '
112 else
113 p_hostname=""
114 t_hostname=""
115 fi
116
117 #check if in nix shell
118 if test -n "$IN_NIX_SHELL"; then
119 p_nixshell='%F{green}[s]%f '
120 t_nixshell='[s] '
121 else
122 p_nixshell=""
123 t_nixshell=""
124 fi
125
126 PROMPT="$p_error$p_username$p_hostname$p_nixshell%~ "
127 TITLE="$t_error$t_username$t_hostname$t_nixshell%~"
128 case $TERM in
129 (*xterm* | *rxvt*)
130 function precmd {
131 PROMPT_EVALED=$(print -P "$TITLE")
132 echo -ne "\033]0;$$ $PROMPT_EVALED\007"
133 }
134 # This seems broken for some reason
135 # # This is seen while the shell waits for a command to complete.
136 # function preexec {
137 # PROMPT_EVALED=$(print -P "$TITLE")
138 # echo -ne "\033]0;$$ $PROMPT_EVALED $1\007"
139 # }
140 ;;
141 esac
142 '';
143 };
144 environment.shellAliases.ns = "nix-shell --command zsh";
145
146 users.defaultUserShell = "/run/current-system/sw/bin/zsh";
147}