summaryrefslogtreecommitdiff
path: root/users/seth/module/shell
diff options
context:
space:
mode:
Diffstat (limited to 'users/seth/module/shell')
-rw-r--r--users/seth/module/shell/bash.nix34
-rw-r--r--users/seth/module/shell/default.nix40
-rw-r--r--users/seth/module/shell/fish.nix52
-rw-r--r--users/seth/module/shell/nu.nix43
-rw-r--r--users/seth/module/shell/zsh.nix128
5 files changed, 297 insertions, 0 deletions
diff --git a/users/seth/module/shell/bash.nix b/users/seth/module/shell/bash.nix
new file mode 100644
index 0000000..09a78a3
--- /dev/null
+++ b/users/seth/module/shell/bash.nix
@@ -0,0 +1,34 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.seth.shell.bash;
+in {
+ options.seth.shell.bash = {
+ enable = lib.mkEnableOption "Bash configuration" // {default = true;};
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs.bash = {
+ enable = true;
+ # TODO: find out if i need this anymore with standalone HM
+ bashrcExtra = ''
+ nixfile=${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.sh
+ [ -e "$nixfile" ] && source "$nixfile"
+ '';
+ historyFile = "${config.xdg.stateHome}/bash/history";
+ historyFileSize = 1000;
+ historySize = 100;
+ shellOptions = [
+ "cdspell"
+ "checkjobs"
+ "checkwinsize"
+ "dirspell"
+ "globstar"
+ "histappend"
+ "no_empty_cmd_completion"
+ ];
+ };
+ };
+}
diff --git a/users/seth/module/shell/default.nix b/users/seth/module/shell/default.nix
new file mode 100644
index 0000000..050cb0c
--- /dev/null
+++ b/users/seth/module/shell/default.nix
@@ -0,0 +1,40 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.seth.shell;
+in {
+ options.seth.shell = {
+ aliases.enable = lib.mkEnableOption "Shell aliases" // {default = true;};
+ variables.enable = lib.mkEnableOption "Shell variables" // {default = true;};
+ };
+
+ imports = [
+ ./bash.nix
+ ./fish.nix
+ ./nu.nix
+ ./zsh.nix
+ ];
+
+ config = {
+ home = lib.mkMerge [
+ (lib.mkIf cfg.variables.enable {
+ sessionVariables = rec {
+ EDITOR = "nvim";
+ VISUAL = EDITOR;
+ CARGO_HOME = "${config.xdg.dataHome}/cargo";
+ LESSHISTFILE = "${config.xdg.stateHome}/less/history";
+ };
+ })
+
+ (lib.mkIf cfg.aliases.enable {
+ shellAliases = {
+ diff = "diff --color=auto";
+ g = "git";
+ gs = "g status";
+ };
+ })
+ ];
+ };
+}
diff --git a/users/seth/module/shell/fish.nix b/users/seth/module/shell/fish.nix
new file mode 100644
index 0000000..6dfebb9
--- /dev/null
+++ b/users/seth/module/shell/fish.nix
@@ -0,0 +1,52 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}: let
+ cfg = config.seth.shell.fish;
+in {
+ options.seth.shell.fish = {
+ enable = lib.mkEnableOption "Fish configuration" // {default = true;};
+ withPlugins = lib.mkEnableOption "Fish plugins" // {default = true;};
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs.fish = lib.mkMerge [
+ {
+ enable = true;
+ catppuccin.enable = true;
+
+ interactiveShellInit = ''
+ set -l nixfile ${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.fish
+ if test -e $nixfile
+ source $nixfile
+ end
+
+ ${lib.getExe pkgs.nix-your-shell} fish | source
+
+ abbr -a !! --position anywhere --function last_history_item
+ '';
+
+ functions = {
+ last_history_item.body = "echo $history[1]";
+ };
+
+ shellAbbrs = {
+ nixgc = "sudo nix-collect-garbage -d && nix-collect-garbage -d";
+ };
+ }
+ (lib.mkIf cfg.withPlugins {
+ plugins = let
+ mkFishPlugins = builtins.map (plugin: {
+ name = plugin;
+ inherit (pkgs.fishPlugins.${plugin}) src;
+ });
+ in
+ mkFishPlugins [
+ "autopair"
+ ];
+ })
+ ];
+ };
+}
diff --git a/users/seth/module/shell/nu.nix b/users/seth/module/shell/nu.nix
new file mode 100644
index 0000000..b5b1529
--- /dev/null
+++ b/users/seth/module/shell/nu.nix
@@ -0,0 +1,43 @@
+{
+ config,
+ lib,
+ inputs,
+ ...
+}: let
+ cfg = config.seth.shell.nushell;
+ theme = "catppuccin-${config.catppuccin.flavour}";
+in {
+ options.seth.shell.nushell = {
+ enable = lib.mkEnableOption "Nushell configuration";
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs = {
+ nushell = {
+ enable = true;
+
+ configFile.text = ''
+ def "nixgc" [] {
+ sudo nix-collect-garbage -d; nix-collect-garbage -d
+ }
+ '';
+
+ envFile.text = ''
+ use ${inputs.nu-scripts}/themes/nu-themes/${theme}.nu
+ $env.config.color_config = (${theme})
+ '';
+
+ inherit (config.home) shellAliases;
+ };
+
+ bash.initExtra = lib.mkAfter ''
+ if [[ $(ps --no-header --pid=$PPID --format=comm) != "nu" && -z ''${BASH_EXECUTION_STRING} ]]; then
+ exec ${lib.getExe config.programs.nushell.package}
+ fi
+ '';
+
+ # builtin `ls` is good here!
+ eza.enable = lib.mkForce false;
+ };
+ };
+}
diff --git a/users/seth/module/shell/zsh.nix b/users/seth/module/shell/zsh.nix
new file mode 100644
index 0000000..b3f31b9
--- /dev/null
+++ b/users/seth/module/shell/zsh.nix
@@ -0,0 +1,128 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}: let
+ cfg = config.seth.shell.zsh;
+in {
+ options.seth.shell.zsh = {
+ enable = lib.mkEnableOption "Zsh configuration";
+ withPlugins = lib.mkEnableOption "Zsh plugins" // {default = true;};
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs.zsh = lib.mkMerge [
+ {
+ enable = true;
+ enableAutosuggestions = true;
+
+ completionInit = ''
+ autoload -Uz bashcompinit compinit
+ local zdump="${config.xdg.cacheHome}/zsh/zdump"
+ bashcompinit
+ compinit -d "$zdump"
+ if [[ ! "$zdump.zwc" -nt "$zdump" ]]
+ then
+ zcompile "$zdump"
+ fi
+ unset zdump
+ '';
+
+ defaultKeymap = "emacs";
+ dotDir = ".config/zsh";
+
+ initExtra = ''
+ if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-*.zsh" ]]; then
+ source "$XDG_CACHE_HOME/p10k-instant-prompt-*.zsh"
+ fi
+ autoload -Uz promptinit colors
+ promptinit
+ colors
+
+ ${lib.getExe pkgs.nix-your-shell} zsh | source /dev/stdin
+
+ zmodload zsh/zutil
+ zmodload zsh/complist
+ zstyle ":completion::*" group-name ""
+ zstyle ":completion:*" menu "select"
+ zstyle ":completion:*" squeeze-slashes "true"
+ zstyle ":completion::*" use-cache "true"
+ zstyle ":completion::*" cache-path "$zdump"
+
+ unsetopt beep
+ unsetopt hist_beep
+ unsetopt ignore_braces
+ unsetopt list_beep
+ setopt always_to_end
+ setopt prompt_subst
+ setopt share_history
+
+ # clear backbuffer with ctrl-l
+ function clear-screen-and-scrollback() {
+ echoti civis >"$TTY"
+ printf '%b' '\e[H\e[2J' >"$TTY"
+ zle .reset-prompt
+ zle -R
+ printf '%b' '\e[3J' >"$TTY"
+ echoti cnorm >"$TTY"
+ }
+
+ zle -N clear-screen-and-scrollback
+ bindkey '^L' clear-screen-and-scrollback
+
+ [[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
+ '';
+
+ history = {
+ expireDuplicatesFirst = true;
+ path = "${config.xdg.stateHome}/zsh/zsh_history";
+ save = 1000;
+ size = 100;
+ };
+ }
+
+ (lib.mkIf cfg.withPlugins {
+ plugins = [
+ {
+ name = "cattppuccin-zsh-syntax-highlighting";
+ src = pkgs.fetchFromGitHub {
+ owner = "catppuccin";
+ repo = "zsh-syntax-highlighting";
+ rev = "06d519c20798f0ebe275fc3a8101841faaeee8ea";
+ sha256 = "sha256-Q7KmwUd9fblprL55W0Sf4g7lRcemnhjh4/v+TacJSfo=";
+ };
+
+ file = "themes/catppuccin_mocha-zsh-syntax-highlighting.zsh";
+ }
+
+ {
+ name = "nix-zsh-completions";
+ src = pkgs.nix-zsh-completions;
+ file = "share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh";
+ }
+
+ {
+ name = "powerlevel10k";
+ src = pkgs.zsh-powerlevel10k;
+ file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
+ }
+
+ {
+ name = "zsh-autopair";
+ src = pkgs.zsh-autopair;
+ file = "share/zsh/zsh-autopair/autopair.zsh";
+ }
+
+ {
+ name = "zsh-completions";
+ src = pkgs.zsh-completions;
+ file = "share/zsh-completions/zsh-completions.plugin.zsh";
+ }
+ ];
+
+ enableSyntaxHighlighting = true;
+ })
+ ];
+ };
+}