summaryrefslogtreecommitdiffstats
path: root/common/commandline
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2020-12-03 16:45:06 +0100
committerMinijackson <minijackson@riseup.net>2020-12-03 16:45:06 +0100
commit3f0e83cb4816e637d8c916fb77217e1c5824dbe5 (patch)
tree65b48ffe6e82459cde97b8ee61a597402ba2617b /common/commandline
downloadnixos-config-reborn-3f0e83cb4816e637d8c916fb77217e1c5824dbe5.tar.gz
nixos-config-reborn-3f0e83cb4816e637d8c916fb77217e1c5824dbe5.zip
initial commit: most of previous configuration reworked
Diffstat (limited to 'common/commandline')
-rw-r--r--common/commandline/dircolors.nix74
-rw-r--r--common/commandline/git.nix58
-rw-r--r--common/commandline/htop.nix44
-rw-r--r--common/commandline/tmux.nix79
-rw-r--r--common/commandline/zsh.nix59
5 files changed, 314 insertions, 0 deletions
diff --git a/common/commandline/dircolors.nix b/common/commandline/dircolors.nix
new file mode 100644
index 0000000..7ef3a4d
--- /dev/null
+++ b/common/commandline/dircolors.nix
@@ -0,0 +1,74 @@
1{ config, ... }:
2
3{
4 home-manager.users.minijackson = { ... }:
5 {
6 programs.dircolors = {
7 enable = true;
8 settings = {
9 # Enable on the alacritty terminal
10 TERM = "alacritty*";
11
12 DIR = "01;94";
13 EXEC = "01;92";
14
15 FIFO = "93"; # pipe"
16 BLK = "93;01"; # block device driver"
17 CHR = "93;01"; # character device driver"
18
19 # archives or compressed (yellow)
20 ".tar" = "01;33";
21 ".tgz" = "01;33";
22 ".arc" = "01;33";
23 ".arj" = "01;33";
24 ".taz" = "01;33";
25 ".lha" = "01;33";
26 ".lz4" = "01;33";
27 ".lzh" = "01;33";
28 ".lzma" = "01;33";
29 ".tlz" = "01;33";
30 ".txz" = "01;33";
31 ".tzo" = "01;33";
32 ".t7z" = "01;33";
33 ".zip" = "01;33";
34 ".z" = "01;33";
35 ".dz" = "01;33";
36 ".gz" = "01;33";
37 ".lrz" = "01;33";
38 ".lz" = "01;33";
39 ".lzo" = "01;33";
40 ".xz" = "01;33";
41 ".zst" = "01;33";
42 ".tzst" = "01;33";
43 ".bz2" = "01;33";
44 ".bz" = "01;33";
45 ".tbz" = "01;33";
46 ".tbz2" = "01;33";
47 ".tz" = "01;33";
48 ".deb" = "01;33";
49 ".rpm" = "01;33";
50 ".jar" = "01;33";
51 ".war" = "01;33";
52 ".ear" = "01;33";
53 ".sar" = "01;33";
54 ".rar" = "01;33";
55 ".alz" = "01;33";
56 ".ace" = "01;33";
57 ".zoo" = "01;33";
58 ".cpio" = "01;33";
59 ".7z" = "01;33";
60 ".rz" = "01;33";
61 ".cab" = "01;33";
62 ".wim" = "01;33";
63 ".swm" = "01;33";
64 ".dwm" = "01;33";
65 ".esd" = "01;33";
66 };
67 };
68 };
69
70 home-manager.users.root = { ... }:
71 {
72 programs.dircolors = config.home-manager.users.minijackson.programs.dircolors;
73 };
74}
diff --git a/common/commandline/git.nix b/common/commandline/git.nix
new file mode 100644
index 0000000..597ef64
--- /dev/null
+++ b/common/commandline/git.nix
@@ -0,0 +1,58 @@
1{ config, pkgs, ... }:
2
3{
4 # TODO: add signing
5 home-manager.users.minijackson = { ... }:
6 {
7 programs.git = {
8 enable = true;
9 package = pkgs.gitAndTools.gitFull;
10 userEmail = "minijackson@riseup.net";
11 userName = "Minijackson";
12
13 extraConfig = let
14 deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta";
15 in {
16 core = {
17 whitespace = "trailing-space,space-before-tab";
18 pager = deltaCommand;
19 interactive.diffFilter = "${deltaCommand} --color-only";
20 };
21 merge = { tool = "nvimdiff"; };
22 "mergetool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; };
23
24 delta = with config.theme.colors; {
25 features = "line-numbers decorations";
26 whitespace-error-style = "22 reverse";
27 decorations = {
28 minus-style = "normal red";
29 minus-non-emph-style = "normal red";
30 minus-emph-style = "normal brightred";
31 minus-empty-line-marker-style = "normal red";
32
33 plus-style = "reverse green";
34 plus-non-emph-style = "reverse green";
35 plus-emph-style = "reverse brightgreen";
36 plus-empty-line-marker-style = "reverse green";
37
38 whitespace-error-style = "reverse green";
39
40 line-numbers-minus-style = "brightred";
41 line-numbers-zero-style = "brightblack";
42 line-numbers-plus-style = "brightgreen";
43
44 file-style = "bright${dominantName}";
45 line-numbers-left-style = dominantName;
46 line-numbers-right-style = dominantName;
47 };
48 };
49
50 };
51 };
52 };
53
54 home-manager.users.root = { ... }:
55 {
56 programs.git = config.home-manager.users.minijackson.programs.git;
57 };
58}
diff --git a/common/commandline/htop.nix b/common/commandline/htop.nix
new file mode 100644
index 0000000..f9732a6
--- /dev/null
+++ b/common/commandline/htop.nix
@@ -0,0 +1,44 @@
1{ config, ... }:
2
3{
4 home-manager.users.minijackson = { ... }:
5 {
6 programs.htop = {
7 enable = true;
8
9 fields = [
10 "PID" "USER"
11 "PRIORITY" "NICE"
12 "STATE"
13 "IO_PRIORITY" "IO_READ_RATE" "IO_WRITE_RATE"
14 "PERCENT_CPU" "PERCENT_MEM"
15 "TIME"
16 "COMM"
17 ];
18
19 hideThreads = true;
20 hideUserlandThreads = true;
21 showThreadNames = true;
22 shadowOtherUsers = true;
23
24 highlightBaseName = true;
25
26 # On NixOS? NO.
27 showProgramPath = false;
28
29 treeView = true;
30
31 meters = {
32 left = [ "LeftCPUs2" "Memory" "Swap" "Blank" { kind = "Battery"; mode = 1; } ];
33 right = [ "RightCPUs2" "Blank" "Tasks" "LoadAverage" "Uptime" ];
34 };
35 };
36 };
37
38 home-manager.users.root = { ... }:
39 {
40 programs.htop = config.home-manager.users.minijackson.programs.htop // {
41 shadowOtherUsers = false;
42 };
43 };
44}
diff --git a/common/commandline/tmux.nix b/common/commandline/tmux.nix
new file mode 100644
index 0000000..aa4de9c
--- /dev/null
+++ b/common/commandline/tmux.nix
@@ -0,0 +1,79 @@
1{ config, pkgs, ... } :
2
3let
4 # Thanks: https://github.com/DanielFGray/dotfiles/blob/master/tmux.remote.conf
5 remoteConf = builtins.toFile "tmux.remote.conf" ''
6 unbind C-q
7 unbind q
8 set-option -g prefix C-s
9 bind s send-prefix
10 bind C-s last-window
11 set-option -g status-position top
12 '';
13in {
14 programs.tmux = {
15 enable = true;
16 shortcut = "q";
17 escapeTime = 10;
18 keyMode = "vi";
19 terminal = "tmux-256color";
20 historyLimit = 50000;
21
22 extraConfig = with config.theme; with pkgs.tmuxPlugins;
23 ''
24 # Plugins
25 run-shell '${copycat}/share/tmux-plugins/copycat/copycat.tmux'
26 run-shell '${sensible}/share/tmux-plugins/sensible/sensible.tmux'
27 run-shell '${urlview}/share/tmux-plugins/urlview/urlview.tmux'
28
29 bind-key R run-shell ' \
30 tmux source-file /etc/tmux.conf > /dev/null; \
31 tmux display-message "sourced /etc/tmux.conf"'
32
33 if -F "$SSH_CONNECTION" "source-file '${remoteConf}'"
34
35 set-option -g status-right ' #{prefix_highlight} "#{=21:pane_title}" %H:%M %d-%b-%y'
36 set-option -g status-left-length 20
37 set-option -g @prefix_highlight_fg '${colors.background}'
38 set-option -g @prefix_highlight_bg '${colors.dominant}'
39 run-shell '${prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux'
40
41 # Be faster switching windows
42 bind C-n next-window
43 bind C-p previous-window
44
45 set-option -g set-titles on
46
47 bind C-y run-shell ' \
48 ${pkgs.tmux}/bin/tmux show-buffer > /dev/null 2>&1 \
49 && ${pkgs.tmux}/bin/tmux show-buffer | ${pkgs.xsel}/bin/xsel -ib'
50
51 # Force true colors
52 set-option -ga terminal-overrides ",*:Tc"
53
54 set-option -g mouse on
55 set-option -g focus-events on
56
57 # Stay in same directory when split
58 bind % split-window -h -c "#{pane_current_path}"
59 bind '"' split-window -v -c "#{pane_current_path}"
60
61 # Colorscheme
62 set-option -g status-style 'fg=${colors.dimForeground}, bg=${colors.background}'
63
64 set-option -g window-status-current-style 'fg=${colors.dominant}'
65
66 set-option -g pane-border-style 'fg=${colors.background}'
67 set-option -g pane-active-border-style 'fg=${colors.dominant}'
68
69 set-option -g message-style 'fg=${colors.background}, bg=${colors.dimForeground}'
70
71 set-option -g mode-style 'fg=${colors.background}, bg=${colors.dominant}'
72
73 set-option -g display-panes-active-colour '${colors.dominant}'
74 set-option -g display-panes-colour '${colors.dimForeground}'
75
76 set-option -g clock-mode-colour '${colors.dominant}'
77 '';
78 };
79}
diff --git a/common/commandline/zsh.nix b/common/commandline/zsh.nix
new file mode 100644
index 0000000..3376321
--- /dev/null
+++ b/common/commandline/zsh.nix
@@ -0,0 +1,59 @@
1{ config, lib, pkgs, ... }:
2
3with import ../../lib/theme.nix { inherit lib; };
4let
5 dominantEscapeCode = fgEscapeCode config.theme.colors.dominant;
6in
7{
8 programs.zsh = {
9 enable = true;
10
11 interactiveShellInit = with lib;
12 ''
13 source "${pkgs.grml-zsh-config}/etc/zsh/zshrc"
14 is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack"
15
16 PATH="${pkgs.pazi}/bin:$PATH"
17 eval "$(pazi init zsh)"
18
19 source "${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh"
20
21 function () {
22 local dominant_escape_code="${dominantEscapeCode}"
23 local dim_fg_escape_code="${fgEscapeCode config.theme.colors.dimForeground}"
24
25 ${builtins.readFile ../../dotfiles/zshrc}
26 }
27
28 # Grml's ZSH config overrides less variables
29 export ${concatStringsSep " "
30 (mapAttrsToList
31 (variable: value: "${variable}=\"${value}\"")
32 config.programs.less.envVariables)}
33
34 #eval "$(${pkgs.starship}/bin/starship init zsh)"
35 '';
36
37 # otherwise it'll override the grml prompt
38 promptInit = "";
39 # Grml handles that, and supports cache (faster!!!)
40 enableGlobalCompInit = false;
41
42 syntaxHighlighting = {
43 enable = true;
44 highlighters = [ "main" "brackets" "line" ];
45 };
46
47 shellAliases = {
48 e = "\${(z)EDITOR}";
49 };
50
51 setOptions = [
52 "HIST_IGNORE_DUPS" "SHARE_HISTORY" "HIST_FCNTL_LOCK"
53 "NO_CLOBBER"
54 "NO_CASE_GLOB"
55 ];
56 };
57
58 users.defaultUserShell = pkgs.zsh;
59}