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