forked from kclejeune/system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
executable file
·125 lines (121 loc) · 3.09 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
config,
inputs,
lib,
pkgs,
...
}:
let
functions = builtins.readFile ./functions.sh;
aliases =
rec {
ls = "${pkgs.eza}/bin/eza --color=auto --classify=auto --git-repos --icons=auto";
la = "${ls} -a";
ll = "${ls} -la";
lt = "${ls} -lat";
ga = "git add";
"ga." = "git add .";
"-" = "cd -";
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
"......" = "cd ../../../../..";
}
// lib.optionalAttrs pkgs.stdenvNoCC.isDarwin rec {
# darwin specific aliases
ibrew = "arch -x86_64 brew";
abrew = "arch -arm64 brew";
};
in
{
# override programs.zsh while waiting for my `alias -- "foo=bar"` fix to hit upstream
disabledModules = [ "${inputs.home-manager}/modules/programs/zsh.nix" ];
imports = [ "${inputs.my-home-manager-fork}/modules/programs/zsh.nix" ];
programs.zsh =
let
mkZshPlugin =
{
pkg,
file ? "${pkg.pname}.plugin.zsh",
}:
{
name = pkg.pname;
src = pkg.src;
inherit file;
};
in
{
enable = true;
autocd = true;
dotDir = ".config/zsh";
localVariables = {
LANG = "en_US.UTF-8";
GPG_TTY = "/dev/ttys000";
DEFAULT_USER = "${config.home.username}";
CLICOLOR = 1;
LS_COLORS = "ExFxBxDxCxegedabagacad";
TERM = "xterm-256color";
};
shellAliases = aliases;
initExtraBeforeCompInit = ''
fpath+=~/.zfunc
'';
initExtra = ''
${functions}
${lib.optionalString pkgs.stdenvNoCC.isDarwin ''
if [[ -d /opt/homebrew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
''}
unset RPS1
'';
profileExtra = ''
${lib.optionalString pkgs.stdenvNoCC.isLinux "[[ -e /etc/profile ]] && source /etc/profile"}
'';
plugins = [
(mkZshPlugin { pkg = pkgs.zsh-autopair; })
(mkZshPlugin { pkg = pkgs.zsh-completions; })
(mkZshPlugin { pkg = pkgs.zsh-autosuggestions; })
(mkZshPlugin {
pkg = pkgs.zsh-fast-syntax-highlighting;
file = "fast-syntax-highlighting.plugin.zsh";
})
(mkZshPlugin { pkg = pkgs.zsh-history-substring-search; })
];
oh-my-zsh = {
enable = true;
plugins = [
"git"
"sudo"
"asdf"
];
};
};
programs.bash = {
enable = true;
shellAliases = aliases;
initExtra = ''
${functions}
if [[ -d "${config.home.homeDirectory}/.asdf/" ]]; then
. "${config.home.homeDirectory}/.asdf/asdf.sh"
. "${config.home.homeDirectory}/.asdf/completions/asdf.bash"
fi
'';
};
# starship - a customizable prompt for any shell
programs.starship = {
enable = true;
# custom settings
settings = {
add_newline = false;
aws.disabled = true;
gcloud.disabled = true;
line_break.disabled = false;
};
};
#autojump - a 'cd' command that learns
programs.autojump = {
enable = true;
};
}