diff --git a/hosts/PW05CH3L/configuration.nix b/hosts/PW05CH3L/configuration.nix index 56fa8359..7a095863 100644 --- a/hosts/PW05CH3L/configuration.nix +++ b/hosts/PW05CH3L/configuration.nix @@ -10,6 +10,7 @@ ../../modules/mixins/phpactor ../../modules/mixins/starship.nix ../../modules/mixins/tmux.nix + ../../modules/mixins/zsh ../common ../../users/opdavies diff --git a/hosts/lemp11/configuration.nix b/hosts/lemp11/configuration.nix index 2e567a66..45553941 100644 --- a/hosts/lemp11/configuration.nix +++ b/hosts/lemp11/configuration.nix @@ -7,6 +7,8 @@ ./programs.nix ./services.nix + ../../modules/mixins/zsh + ../common ../../users/opdavies ../../users/eric diff --git a/hosts/nixedo/configuration.nix b/hosts/nixedo/configuration.nix index efb7f3ec..1a7a9efc 100644 --- a/hosts/nixedo/configuration.nix +++ b/hosts/nixedo/configuration.nix @@ -11,6 +11,7 @@ ./services.nix ../../modules/mixins/docker.nix + ../../modules/mixins/zsh ./modules/acme.nix ./modules/audiobookshelf.nix diff --git a/hosts/t480/configuration.nix b/hosts/t480/configuration.nix index 82770a5a..fe7f0615 100644 --- a/hosts/t480/configuration.nix +++ b/hosts/t480/configuration.nix @@ -23,6 +23,7 @@ ../../modules/mixins/starship.nix ../../modules/mixins/thunar.nix ../../modules/mixins/tmux.nix + ../../modules/mixins/zsh ../../modules/profiles/dwm ../../modules/profiles/xbanish.nix diff --git a/modules/home-manager/cli/default.nix b/modules/home-manager/cli/default.nix index a833e666..ca9a84dd 100644 --- a/modules/home-manager/cli/default.nix +++ b/modules/home-manager/cli/default.nix @@ -3,6 +3,5 @@ { imports = [ ./bin - ./zsh ]; } diff --git a/modules/home-manager/cli/zsh/default.nix b/modules/home-manager/cli/zsh/default.nix deleted file mode 100644 index dc110f74..00000000 --- a/modules/home-manager/cli/zsh/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ config, pkgs, ... }: - -{ - programs.zsh = { - enable = true; - enableCompletion = true; - syntaxHighlighting.enable = true; - - zsh-abbr = { - enable = true; - - abbreviations = import ./abbreviations.nix; - globalAbbreviations = import ./global-abbreviations.nix; - }; - - dotDir = ".config/zsh"; - - shellAliases = (import ./aliases.nix { inherit config; }); - - localVariables = { - ABBR_SET_EXPANSION_CURSOR = 1; - }; - - initExtra = '' - if [[ -z "$DISPLAY" ]] && [[ "$(tty)" == "/dev/tty1" ]]; then - exec startx &>/dev/null - fi - - # suffix - alias -s gz="tar -tf" - alias -s {html,HTML}="background firefox" - alias -s {jpg,JPG,png,PNG}="background okular" - alias -s {pdf,PDF}="background okular" - alias -s {zip,ZIP}="unzip -l" - - git() { - case "$1" in - clone) - shift - - local repo_url="$1" - local repo_path="''${2:-}" - - if [ -n "$TARGET_DIR" ]; then - command git clone "$repo_url" "$repo_path" - else - command git clone "$repo_url" - repo_path=$(basename "$repo_url" .git) - fi - - ${pkgs.tmux-sessionizer}/bin/tmux-sessionizer "$repo_path" - ;; - - root) - shift - - local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)" - - if [[ $# == 0 ]]; then - cd "''${ROOT}" - else - (cd "''${ROOT}" && eval "''${@}") - fi - ;; - - *) - ${pkgs.git}/bin/git "''${@}" - ;; - esac - } - - mbsync() { - ${pkgs.isync}/bin/mbsync --config "${config.xdg.configHome}/isync/mbsyncrc" "''${@}" - } - - ttyper() { - command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}" - } - - yt-dlp() { - command yt-dlp --paths ~/Videos "$@" - } - - bindkey -s ^f "tmux-sessionizer\n" - bindkey -s ^v "nvim\n" - - setopt auto_cd - setopt auto_pushd - setopt pushd_ignore_dups - setopt pushdminus - ''; - }; -} diff --git a/modules/home-manager/cli/zsh/abbreviations.nix b/modules/mixins/zsh/abbreviations.nix similarity index 100% rename from modules/home-manager/cli/zsh/abbreviations.nix rename to modules/mixins/zsh/abbreviations.nix diff --git a/modules/home-manager/cli/zsh/aliases.nix b/modules/mixins/zsh/aliases.nix similarity index 100% rename from modules/home-manager/cli/zsh/aliases.nix rename to modules/mixins/zsh/aliases.nix diff --git a/modules/mixins/zsh/default.nix b/modules/mixins/zsh/default.nix new file mode 100644 index 00000000..88b36098 --- /dev/null +++ b/modules/mixins/zsh/default.nix @@ -0,0 +1,95 @@ +{ + home-manager.users.opdavies = + { config, pkgs, ... }: + { + programs.zsh = { + enable = true; + enableCompletion = true; + syntaxHighlighting.enable = true; + + zsh-abbr = { + enable = true; + + abbreviations = import ./abbreviations.nix; + globalAbbreviations = import ./global-abbreviations.nix; + }; + + dotDir = ".config/zsh"; + + shellAliases = (import ./aliases.nix { inherit config; }); + + localVariables = { + ABBR_SET_EXPANSION_CURSOR = 1; + }; + + initExtra = '' + if [[ -z "$DISPLAY" ]] && [[ "$(tty)" == "/dev/tty1" ]]; then + exec startx &>/dev/null + fi + + # suffix + alias -s gz="tar -tf" + alias -s {html,HTML}="background firefox" + alias -s {jpg,JPG,png,PNG}="background okular" + alias -s {pdf,PDF}="background okular" + alias -s {zip,ZIP}="unzip -l" + + git() { + case "$1" in + clone) + shift + + local repo_url="$1" + local repo_path="''${2:-}" + + if [ -n "$TARGET_DIR" ]; then + command git clone "$repo_url" "$repo_path" + else + command git clone "$repo_url" + repo_path=$(basename "$repo_url" .git) + fi + + ${pkgs.tmux-sessionizer}/bin/tmux-sessionizer "$repo_path" + ;; + + root) + shift + + local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)" + + if [[ $# == 0 ]]; then + cd "''${ROOT}" + else + (cd "''${ROOT}" && eval "''${@}") + fi + ;; + + *) + ${pkgs.git}/bin/git "''${@}" + ;; + esac + } + + mbsync() { + ${pkgs.isync}/bin/mbsync --config "${config.xdg.configHome}/isync/mbsyncrc" "''${@}" + } + + ttyper() { + command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}" + } + + yt-dlp() { + command yt-dlp --paths ~/Videos "$@" + } + + bindkey -s ^f "tmux-sessionizer\n" + bindkey -s ^v "nvim\n" + + setopt auto_cd + setopt auto_pushd + setopt pushd_ignore_dups + setopt pushdminus + ''; + }; + }; +} diff --git a/modules/home-manager/cli/zsh/global-abbreviations.nix b/modules/mixins/zsh/global-abbreviations.nix similarity index 100% rename from modules/home-manager/cli/zsh/global-abbreviations.nix rename to modules/mixins/zsh/global-abbreviations.nix