From 3f0e83cb4816e637d8c916fb77217e1c5824dbe5 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 3 Dec 2020 16:45:06 +0100 Subject: initial commit: most of previous configuration reworked --- common/commandline/dircolors.nix | 74 +++++++++++++++++++++++++++++++++++++ common/commandline/git.nix | 58 +++++++++++++++++++++++++++++ common/commandline/htop.nix | 44 ++++++++++++++++++++++ common/commandline/tmux.nix | 79 ++++++++++++++++++++++++++++++++++++++++ common/commandline/zsh.nix | 59 ++++++++++++++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 common/commandline/dircolors.nix create mode 100644 common/commandline/git.nix create mode 100644 common/commandline/htop.nix create mode 100644 common/commandline/tmux.nix create mode 100644 common/commandline/zsh.nix (limited to 'common/commandline') 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 @@ +{ config, ... }: + +{ + home-manager.users.minijackson = { ... }: + { + programs.dircolors = { + enable = true; + settings = { + # Enable on the alacritty terminal + TERM = "alacritty*"; + + DIR = "01;94"; + EXEC = "01;92"; + + FIFO = "93"; # pipe" + BLK = "93;01"; # block device driver" + CHR = "93;01"; # character device driver" + + # archives or compressed (yellow) + ".tar" = "01;33"; + ".tgz" = "01;33"; + ".arc" = "01;33"; + ".arj" = "01;33"; + ".taz" = "01;33"; + ".lha" = "01;33"; + ".lz4" = "01;33"; + ".lzh" = "01;33"; + ".lzma" = "01;33"; + ".tlz" = "01;33"; + ".txz" = "01;33"; + ".tzo" = "01;33"; + ".t7z" = "01;33"; + ".zip" = "01;33"; + ".z" = "01;33"; + ".dz" = "01;33"; + ".gz" = "01;33"; + ".lrz" = "01;33"; + ".lz" = "01;33"; + ".lzo" = "01;33"; + ".xz" = "01;33"; + ".zst" = "01;33"; + ".tzst" = "01;33"; + ".bz2" = "01;33"; + ".bz" = "01;33"; + ".tbz" = "01;33"; + ".tbz2" = "01;33"; + ".tz" = "01;33"; + ".deb" = "01;33"; + ".rpm" = "01;33"; + ".jar" = "01;33"; + ".war" = "01;33"; + ".ear" = "01;33"; + ".sar" = "01;33"; + ".rar" = "01;33"; + ".alz" = "01;33"; + ".ace" = "01;33"; + ".zoo" = "01;33"; + ".cpio" = "01;33"; + ".7z" = "01;33"; + ".rz" = "01;33"; + ".cab" = "01;33"; + ".wim" = "01;33"; + ".swm" = "01;33"; + ".dwm" = "01;33"; + ".esd" = "01;33"; + }; + }; + }; + + home-manager.users.root = { ... }: + { + programs.dircolors = config.home-manager.users.minijackson.programs.dircolors; + }; +} 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 @@ +{ config, pkgs, ... }: + +{ + # TODO: add signing + home-manager.users.minijackson = { ... }: + { + programs.git = { + enable = true; + package = pkgs.gitAndTools.gitFull; + userEmail = "minijackson@riseup.net"; + userName = "Minijackson"; + + extraConfig = let + deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta"; + in { + core = { + whitespace = "trailing-space,space-before-tab"; + pager = deltaCommand; + interactive.diffFilter = "${deltaCommand} --color-only"; + }; + merge = { tool = "nvimdiff"; }; + "mergetool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; }; + + delta = with config.theme.colors; { + features = "line-numbers decorations"; + whitespace-error-style = "22 reverse"; + decorations = { + minus-style = "normal red"; + minus-non-emph-style = "normal red"; + minus-emph-style = "normal brightred"; + minus-empty-line-marker-style = "normal red"; + + plus-style = "reverse green"; + plus-non-emph-style = "reverse green"; + plus-emph-style = "reverse brightgreen"; + plus-empty-line-marker-style = "reverse green"; + + whitespace-error-style = "reverse green"; + + line-numbers-minus-style = "brightred"; + line-numbers-zero-style = "brightblack"; + line-numbers-plus-style = "brightgreen"; + + file-style = "bright${dominantName}"; + line-numbers-left-style = dominantName; + line-numbers-right-style = dominantName; + }; + }; + + }; + }; + }; + + home-manager.users.root = { ... }: + { + programs.git = config.home-manager.users.minijackson.programs.git; + }; +} 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 @@ +{ config, ... }: + +{ + home-manager.users.minijackson = { ... }: + { + programs.htop = { + enable = true; + + fields = [ + "PID" "USER" + "PRIORITY" "NICE" + "STATE" + "IO_PRIORITY" "IO_READ_RATE" "IO_WRITE_RATE" + "PERCENT_CPU" "PERCENT_MEM" + "TIME" + "COMM" + ]; + + hideThreads = true; + hideUserlandThreads = true; + showThreadNames = true; + shadowOtherUsers = true; + + highlightBaseName = true; + + # On NixOS? NO. + showProgramPath = false; + + treeView = true; + + meters = { + left = [ "LeftCPUs2" "Memory" "Swap" "Blank" { kind = "Battery"; mode = 1; } ]; + right = [ "RightCPUs2" "Blank" "Tasks" "LoadAverage" "Uptime" ]; + }; + }; + }; + + home-manager.users.root = { ... }: + { + programs.htop = config.home-manager.users.minijackson.programs.htop // { + shadowOtherUsers = false; + }; + }; +} 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 @@ +{ config, pkgs, ... } : + +let + # Thanks: https://github.com/DanielFGray/dotfiles/blob/master/tmux.remote.conf + remoteConf = builtins.toFile "tmux.remote.conf" '' + unbind C-q + unbind q + set-option -g prefix C-s + bind s send-prefix + bind C-s last-window + set-option -g status-position top + ''; +in { + programs.tmux = { + enable = true; + shortcut = "q"; + escapeTime = 10; + keyMode = "vi"; + terminal = "tmux-256color"; + historyLimit = 50000; + + extraConfig = with config.theme; with pkgs.tmuxPlugins; + '' + # Plugins + run-shell '${copycat}/share/tmux-plugins/copycat/copycat.tmux' + run-shell '${sensible}/share/tmux-plugins/sensible/sensible.tmux' + run-shell '${urlview}/share/tmux-plugins/urlview/urlview.tmux' + + bind-key R run-shell ' \ + tmux source-file /etc/tmux.conf > /dev/null; \ + tmux display-message "sourced /etc/tmux.conf"' + + if -F "$SSH_CONNECTION" "source-file '${remoteConf}'" + + set-option -g status-right ' #{prefix_highlight} "#{=21:pane_title}" %H:%M %d-%b-%y' + set-option -g status-left-length 20 + set-option -g @prefix_highlight_fg '${colors.background}' + set-option -g @prefix_highlight_bg '${colors.dominant}' + run-shell '${prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux' + + # Be faster switching windows + bind C-n next-window + bind C-p previous-window + + set-option -g set-titles on + + bind C-y run-shell ' \ + ${pkgs.tmux}/bin/tmux show-buffer > /dev/null 2>&1 \ + && ${pkgs.tmux}/bin/tmux show-buffer | ${pkgs.xsel}/bin/xsel -ib' + + # Force true colors + set-option -ga terminal-overrides ",*:Tc" + + set-option -g mouse on + set-option -g focus-events on + + # Stay in same directory when split + bind % split-window -h -c "#{pane_current_path}" + bind '"' split-window -v -c "#{pane_current_path}" + + # Colorscheme + set-option -g status-style 'fg=${colors.dimForeground}, bg=${colors.background}' + + set-option -g window-status-current-style 'fg=${colors.dominant}' + + set-option -g pane-border-style 'fg=${colors.background}' + set-option -g pane-active-border-style 'fg=${colors.dominant}' + + set-option -g message-style 'fg=${colors.background}, bg=${colors.dimForeground}' + + set-option -g mode-style 'fg=${colors.background}, bg=${colors.dominant}' + + set-option -g display-panes-active-colour '${colors.dominant}' + set-option -g display-panes-colour '${colors.dimForeground}' + + set-option -g clock-mode-colour '${colors.dominant}' + ''; + }; +} 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 @@ +{ config, lib, pkgs, ... }: + +with import ../../lib/theme.nix { inherit lib; }; +let + dominantEscapeCode = fgEscapeCode config.theme.colors.dominant; +in +{ + programs.zsh = { + enable = true; + + interactiveShellInit = with lib; + '' + source "${pkgs.grml-zsh-config}/etc/zsh/zshrc" + is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack" + + PATH="${pkgs.pazi}/bin:$PATH" + eval "$(pazi init zsh)" + + source "${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh" + + function () { + local dominant_escape_code="${dominantEscapeCode}" + local dim_fg_escape_code="${fgEscapeCode config.theme.colors.dimForeground}" + + ${builtins.readFile ../../dotfiles/zshrc} + } + + # Grml's ZSH config overrides less variables + export ${concatStringsSep " " + (mapAttrsToList + (variable: value: "${variable}=\"${value}\"") + config.programs.less.envVariables)} + + #eval "$(${pkgs.starship}/bin/starship init zsh)" + ''; + + # otherwise it'll override the grml prompt + promptInit = ""; + # Grml handles that, and supports cache (faster!!!) + enableGlobalCompInit = false; + + syntaxHighlighting = { + enable = true; + highlighters = [ "main" "brackets" "line" ]; + }; + + shellAliases = { + e = "\${(z)EDITOR}"; + }; + + setOptions = [ + "HIST_IGNORE_DUPS" "SHARE_HISTORY" "HIST_FCNTL_LOCK" + "NO_CLOBBER" + "NO_CASE_GLOB" + ]; + }; + + users.defaultUserShell = pkgs.zsh; +} -- cgit v1.2.3