From 39d8c87344e827d8d4886d160aed8b191b00e9f3 Mon Sep 17 00:00:00 2001 From: willemml Date: Tue, 11 Apr 2023 00:42:12 -0700 Subject: [PATCH] breakout zsh config --- .../profiles/user/willem/programs/default.nix | 109 ------------------ .../profiles/user/willem/programs/zsh.nix | 102 ++++++++++++++++ 2 files changed, 102 insertions(+), 109 deletions(-) create mode 100644 home-manager/modules/profiles/user/willem/programs/zsh.nix diff --git a/home-manager/modules/profiles/user/willem/programs/default.nix b/home-manager/modules/profiles/user/willem/programs/default.nix index 71ccb73..b3b7aff 100644 --- a/home-manager/modules/profiles/user/willem/programs/default.nix +++ b/home-manager/modules/profiles/user/willem/programs/default.nix @@ -101,115 +101,6 @@ enableZshIntegration = true; }; - zsh = rec { - enable = true; - - autocd = true; - defaultKeymap = "emacs"; - dotDir = ".config/zsh"; - enableAutosuggestions = true; - enableCompletion = true; - enableSyntaxHighlighting = true; - enableVteIntegration = true; - - initExtraBeforeCompInit = '' - fpath+=(${config.home.profileDirectory}/share/zsh/site-functions) - ''; - - history = { - path = "$HOME/.local/zsh/history"; - extended = true; - ignoreDups = true; - }; - - historySubstringSearch.enable = true; - - loginExtra = '' - # -*-sh-*- - export GPG_TTY=$(tty) - eval $(gpg-agent --daemon -q 2>/dev/null) - function s() { - ${shellAliases.web} "https://google.com/search?q=$(echo $@ | sed -e 's/ /%20/g')" - } - nixify() { - if [ ! -e ./.envrc ]; then - echo "use nix" > .envrc - direnv allow - fi - if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then - cat > default.nix <<'EOF' - with import {}; - mkShell { - nativeBuildInputs = [ - bashInteractive - ]; - } - EOF - ${config.home.sessionVariables.EDITOR} default.nix - fi - } - nixifypy() { - if [ ! -e ./.envrc ]; then - echo "use nix" > .envrc - direnv allow - fi - if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then - cat > default.nix <<'EOF' - with import {}; - mkShell { - nativeBuildInputs = [ - bashInteractive - (pkgs.python310.withPackages (p: with p; [ ])) - ]; - } - EOF - ${config.home.sessionVariables.EDITOR} default.nix - fi - } - flakify() { - if [ ! -e flake.nix ]; then - nix flake new -t github:nix-community/nix-direnv . - elif [ ! -e .envrc ]; then - echo "use flake" > .envrc - direnv allow - fi - ${config.home.sessionVariables.EDITOR} flake.nix - } - ''; - - localVariables = { - PROMPT = "\n%B%F{blue}%~\n%F{green}$ %f%b"; - RPROMPT = "%B%F{red}%*%f%b"; - }; - - shellAliases = - rec { - cd = "z"; - discord = "${web} https://discord.com/channels/@me"; - dotd = "cd ${config.home.sessionVariables.DOTDIR} "; - e = "emacsclient -c -nw"; - em = "emacs -nw"; - email = "${ew} -n --eval '(mu4e)'"; - emw = "emacs"; - ew = "emacsclient -c"; - l = "ls -1"; - np = "nix-shell -p"; - org = "cd ${config.home.sessionVariables.ORGDIR} "; - spotify = "${web} https://open.spotify.com/"; - ubc = "cd ${config.home.sessionVariables.UBCDIR} "; - ubcmail = "${web} https://webmail.student.ubc.ca"; - web = "${pkgs.coreutils-full}/bin/nohup ${config.programs.firefox.package}/bin/firefox &> ${config.home.homeDirectory}/.firefox.log"; - } - // ( - if pkgs.stdenv.isLinux - then { - nbs = "sudo nixos-rebuild build --flake ${config.home.sessionVariables.DOTDIR}#"; - nrs = "sudo nixos-rebuild switch --flake ${config.home.sessionVariables.DOTDIR}#"; - } - else {} - ); - }; - home-manager.enable = true; }; } diff --git a/home-manager/modules/profiles/user/willem/programs/zsh.nix b/home-manager/modules/profiles/user/willem/programs/zsh.nix new file mode 100644 index 0000000..1917900 --- /dev/null +++ b/home-manager/modules/profiles/user/willem/programs/zsh.nix @@ -0,0 +1,102 @@ +{ + config, + pkgs, + ... +}: { + programs.zsh = rec { + enable = true; + + autocd = true; + defaultKeymap = "emacs"; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableCompletion = true; + enableSyntaxHighlighting = true; + enableVteIntegration = true; + + initExtraBeforeCompInit = '' + fpath+=(${config.home.profileDirectory}/share/zsh/site-functions) + ''; + + history = { + path = "$HOME/.local/zsh/history"; + extended = true; + ignoreDups = true; + }; + + historySubstringSearch.enable = true; + + loginExtra = + /* + sh + */ + '' + export GPG_TTY=$(tty) + + function s() { + ${shellAliases.web} "https://google.com/search?q=$(echo $@ | sed -e 's/ /%20/g')" + } + + nixifypy() { + if [ ! -e ./.envrc ]; then + echo "use nix" > .envrc + direnv allow + fi + if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then + cat > default.nix <<'EOF' + with import {}; + mkShell { + nativeBuildInputs = [ + bashInteractive + (pkgs.python310.withPackages (p: with p; [ ])) + ]; + } + EOF + ${config.home.sessionVariables.EDITOR} default.nix + fi + } + + flakify() { + if [ ! -e flake.nix ]; then + nix flake new -t github:nix-community/nix-direnv . + elif [ ! -e .envrc ]; then + echo "use flake" > .envrc + direnv allow + fi + ${config.home.sessionVariables.EDITOR} flake.nix + } + ''; + + localVariables = { + PROMPT = "\n%B%F{blue}%~\n%F{green}$ %f%b"; + RPROMPT = "%B%F{red}%*%f%b"; + }; + + shellAliases = + rec { + cd = "z"; + discord = "${web} https://discord.com/channels/@me"; + dotd = "cd ${config.home.sessionVariables.DOTDIR} "; + e = "emacsclient -c -nw"; + em = "emacs -nw"; + email = "${ew} -n --eval '(mu4e)'"; + emw = "emacs"; + ew = "emacsclient -c"; + l = "ls -1"; + np = "nix-shell -p"; + org = "cd ${config.home.sessionVariables.ORGDIR} "; + spotify = "${web} https://open.spotify.com/"; + ubc = "cd ${config.home.sessionVariables.UBCDIR} "; + ubcmail = "${web} https://webmail.student.ubc.ca"; + web = "${pkgs.coreutils-full}/bin/nohup ${config.programs.firefox.package}/bin/firefox &> ${config.home.homeDirectory}/.firefox.log"; + } + // ( + if pkgs.stdenv.isLinux + then { + nbs = "sudo nixos-rebuild build --flake ${config.home.sessionVariables.DOTDIR}#"; + nrs = "sudo nixos-rebuild switch --flake ${config.home.sessionVariables.DOTDIR}#"; + } + else {} + ); + }; +}