generated from ryantm/home-manager-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
shell.nix
77 lines (66 loc) · 1.77 KB
/
shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ pkgs, lib, ...}:
let
essentialShellAliases = {
bash-noprofile = "bash --noprofile";
zsh-noprofile = "zsh -d -f -i";
e = "emacs -nw";
ec = "emacsclient -nw -c";
recd = "cd / && cd -";
ll = "ls -lAFG";
l = "ls -laFG";
};
shellFunctions = ''
function cdmkdir() {
if [[ $# -ne 1 ]]; then
echo "Usage: cdmkdir <dir>"
exit 1
fi
mkdir -p $1
cd $1
}
'';
in
{
home.packages = [
pkgs.bash
];
home.sessionVariables = {
LIBRARY_PATH = ''${lib.makeLibraryPath [pkgs.libiconv]}''${LIBRARY_PATH:+:$LIBRARY_PATH}'';
};
programs = {
autojump = {
enable = true;
};
# Since we do not install home-manager, you need to let home-manager
# manage your shell, otherwise it will not be able to add its hooks
# to your profile.
bash = {
enable = lib.mkOverride 100 true;
shellAliases = essentialShellAliases // {
reload = "unset __HM_SESS_VARS_SOURCED && exec bash";
};
initExtra = shellFunctions;
};
zsh = {
enable = true;
enableAutosuggestions = true;
syntaxHighlighting.enable = true;
shellAliases = essentialShellAliases // {
reload = "unset __HM_SESS_VARS_SOURCED && exec zsh";
};
# Fix zsh for macos: https://gist.github.com/Linerre/f11ad4a6a934dcf01ee8415c9457e7b2
loginExtra = ''
[ -r $HOME/.zshenv ] && . $HOME/.zshenv
'';
initExtra = ''
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '\e[A' up-line-or-beginning-search
bindkey '\e[B' down-line-or-beginning-search
${shellFunctions}
'';
};
};
}