alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools: init sh
author
lassulus
date
3 years ago
(Sep 3, 2023, 10:34 AM CEST)
commit
4031216a
4031216a4f32cd5148ad70504b8d548a95e6d725
parent
cac5f615
cac5f6150f3fc1ed828835cd2afa0cc076ae05de
+172
2 changed files
Expand all
Collapse all
Unified
Split
flake.nix
tools
zsh.nix
+2
flake.nix
View file
Reviewed
···
24
24
imports = [
25
25
./tools/nvim.nix
26
26
./tools/astronvim/flake-module.nix
27
27
+
28
28
+
./tools/zsh.nix
27
29
];
28
30
};
29
31
}
+170
tools/zsh.nix
View file
Reviewed
···
1
1
+
{ ... }:
2
2
+
{
3
3
+
perSystem = { system, pkgs, ... }: let
4
4
+
zshrc = ''
5
5
+
autoload -U compinit && compinit
6
6
+
7
7
+
# Setup custom interactive shell init stuff.
8
8
+
# Bind gpg-agent to this TTY if gpg commands are used.
9
9
+
export GPG_TTY=$(tty)
10
10
+
11
11
+
12
12
+
unsetopt nomatch # no matches found urls
13
13
+
setopt autocd extendedglob
14
14
+
bindkey -e
15
15
+
16
16
+
#C-x C-e open line in editor
17
17
+
autoload -z edit-command-line
18
18
+
zle -N edit-command-line
19
19
+
bindkey "^X^E" edit-command-line
20
20
+
21
21
+
#fzf inclusion
22
22
+
source ${pkgs.fzf}/share/fzf/completion.zsh
23
23
+
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
24
24
+
25
25
+
# atuin distributed shell history
26
26
+
export ATUIN_CONFIG_DIR=${pkgs.writeTextDir "/config.toml" ''
27
27
+
auto_sync = true
28
28
+
update_check = false
29
29
+
sync_address = "http://green.r:8888"
30
30
+
sync_frequency = 0
31
31
+
style = "compact"
32
32
+
''};
33
33
+
export ATUIN_NOBIND="true" # disable all keybdinings of atuin
34
34
+
eval "$(atuin init zsh)"
35
35
+
bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin
36
36
+
# use zsh only session history
37
37
+
fc -p
38
38
+
39
39
+
#completion magic
40
40
+
autoload -Uz compinit
41
41
+
compinit
42
42
+
zstyle ':completion:*' menu select
43
43
+
44
44
+
#enable automatic rehashing of $PATH
45
45
+
zstyle ':completion:*' rehash true
46
46
+
47
47
+
# fancy mv which interactively gets the second argument if not given
48
48
+
function mv() {
49
49
+
if [[ "$#" -ne 1 ]] || [[ ! -e "$1" ]]; then
50
50
+
command mv -v "$@"
51
51
+
return
52
52
+
fi
53
53
+
54
54
+
newfilename="$1"
55
55
+
vared newfilename
56
56
+
command mv -v -- "$1" "$newfilename"
57
57
+
}
58
58
+
59
59
+
#emacs bindings
60
60
+
bindkey "[7~" beginning-of-line
61
61
+
bindkey "[8~" end-of-line
62
62
+
bindkey "Oc" emacs-forward-word
63
63
+
bindkey "Od" emacs-backward-word
64
64
+
65
65
+
# direnv integration
66
66
+
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
67
67
+
68
68
+
# This function is called whenever a command is not found.
69
69
+
command_not_found_handler() {
70
70
+
local p='${pkgs.nix-index}/etc/profile.d/command-not-found.sh'
71
71
+
if [ -x "$p" ] && [ -f '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' ]; then
72
72
+
# Run the helper program.
73
73
+
"$p" "$@"
74
74
+
75
75
+
# Retry the command if we just installed it.
76
76
+
if [ $? = 126 ]; then
77
77
+
"$@"
78
78
+
else
79
79
+
return 127
80
80
+
fi
81
81
+
else
82
82
+
# Indicate than there was an error so ZSH falls back to its default handler
83
83
+
echo "$1: command not found" >&2
84
84
+
return 127
85
85
+
fi
86
86
+
}
87
87
+
88
88
+
89
89
+
# Setup aliases.
90
90
+
alias -- grep='grep --color=auto'
91
91
+
alias -- ip='ip -color=auto'
92
92
+
alias -- l='ls -alh'
93
93
+
alias -- la='ls -la'
94
94
+
alias -- ll='ls -l'
95
95
+
alias -- ls='ls --color'
96
96
+
alias -- ns='nix-shell --command zsh'
97
97
+
98
98
+
# Setup prompt.
99
99
+
autoload -U promptinit
100
100
+
promptinit
101
101
+
102
102
+
p_error='%(?..%F{red}%?%f )'
103
103
+
t_error='%(?..%? )'
104
104
+
105
105
+
case $UID in
106
106
+
0)
107
107
+
p_username='%F{red}root%f'
108
108
+
t_username='root'
109
109
+
;;
110
110
+
1337)
111
111
+
p_username=""
112
112
+
t_username=""
113
113
+
;;
114
114
+
*)
115
115
+
p_username='%F{blue}%n%f'
116
116
+
t_username='%n'
117
117
+
;;
118
118
+
esac
119
119
+
120
120
+
if test -n "$SSH_CLIENT"; then
121
121
+
p_hostname='@%F{magenta}%M%f '
122
122
+
t_hostname='@%M '
123
123
+
else
124
124
+
p_hostname=""
125
125
+
t_hostname=""
126
126
+
fi
127
127
+
128
128
+
#check if in nix shell
129
129
+
if test -n "$IN_NIX_SHELL"; then
130
130
+
p_nixshell='%F{green}[s]%f '
131
131
+
t_nixshell='[s] '
132
132
+
else
133
133
+
p_nixshell=""
134
134
+
t_nixshell=""
135
135
+
fi
136
136
+
137
137
+
PROMPT="$p_error$p_username$p_hostname$p_nixshell%~ "
138
138
+
TITLE="$t_error$t_username$t_hostname$t_nixshell%~"
139
139
+
case $TERM in
140
140
+
(*xterm* | *rxvt*)
141
141
+
function precmd {
142
142
+
PROMPT_EVALED=$(print -P "$TITLE")
143
143
+
echo -ne "\033]0;$$ $PROMPT_EVALED\007"
144
144
+
}
145
145
+
# This seems broken for some reason
146
146
+
# # This is seen while the shell waits for a command to complete.
147
147
+
# function preexec {
148
148
+
# PROMPT_EVALED=$(print -P "$TITLE")
149
149
+
# echo -ne "\033]0;$$ $PROMPT_EVALED $1\007"
150
150
+
# }
151
151
+
;;
152
152
+
esac
153
153
+
154
154
+
155
155
+
# Disable some features to support TRAMP.
156
156
+
if [ "$TERM" = dumb ]; then
157
157
+
unsetopt zle prompt_cr prompt_subst
158
158
+
unset RPS1 RPROMPT
159
159
+
PS1='$ '
160
160
+
PROMPT='$ '
161
161
+
fi
162
162
+
'';
163
163
+
in {
164
164
+
packages.sh = pkgs.writeScriptBin "sh" ''
165
165
+
zdotdir=$(mktemp -d)
166
166
+
export ZDOTDIR=${pkgs.writeTextDir "/.zshrc" zshrc}
167
167
+
exec ${pkgs.zsh}/bin/zsh "$@"
168
168
+
'';
169
169
+
};
170
170
+
}