summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2023-08-16 20:12:35 +0200
committerAlan Pearce2023-08-16 20:58:08 +0200
commit7f3e574437879f97ca606b29f7a914bc04f32fbb (patch)
tree79a866d8b778505f9436fa7a2cd072cb1519f614 /user
parent62e1af7c507917673ed5299478c27d341089a544 (diff)
downloadnixfiles-7f3e574437879f97ca606b29f7a914bc04f32fbb.tar.lz
nixfiles-7f3e574437879f97ca606b29f7a914bc04f32fbb.tar.zst
nixfiles-7f3e574437879f97ca606b29f7a914bc04f32fbb.zip
Make shell aliases shell-agnostic
Diffstat (limited to 'user')
-rw-r--r--user/settings/base.nix3
-rw-r--r--user/settings/darwin.nix2
-rw-r--r--user/settings/development/javascript.nix2
-rw-r--r--user/settings/nixos.nix12
-rw-r--r--user/settings/satoshipay.nix12
-rw-r--r--user/settings/shell.nix132
-rw-r--r--user/settings/zsh.nix116
7 files changed, 147 insertions, 132 deletions
diff --git a/user/settings/base.nix b/user/settings/base.nix
index 69d86efe..c3691c53 100644
--- a/user/settings/base.nix
+++ b/user/settings/base.nix
@@ -5,6 +5,7 @@
 }: {
   imports = [
     ./neovim.nix
+    ./shell.nix
   ];
   # Let Home Manager install and manage itself.
   programs.home-manager.enable = true;
@@ -26,7 +27,7 @@
     stateHome = "${config.home.homeDirectory}/.local/state";
   };
 
-  programs.zsh.shellAliases = {
+  home.shellAliases = {
     make = "remake";
   };
   programs.htop = {
diff --git a/user/settings/darwin.nix b/user/settings/darwin.nix
index f0dab808..adb69b9f 100644
--- a/user/settings/darwin.nix
+++ b/user/settings/darwin.nix
@@ -137,7 +137,7 @@
   programs.zsh.dirHashes = {
     icloud = "$HOME/Library/Mobile\ Documents/com~apple~CloudDocs";
   };
-  programs.zsh.shellAliases = {
+  home.shellAliases = {
     rb = "darwin-rebuild";
     rbs = "darwin-rebuild switch --flake $(ghq list -p nixfiles)";
 
diff --git a/user/settings/development/javascript.nix b/user/settings/development/javascript.nix
index 56057220..b06f5abd 100644
--- a/user/settings/development/javascript.nix
+++ b/user/settings/development/javascript.nix
@@ -59,7 +59,7 @@ in
     typescript-mode
   ]);
 
-  programs.zsh.shellAliases = {
+  home.shellAliases = {
     ava = "pnpx ava";
     avt = "pnpx ava --tap";
     avat = "pnpx ava --tap";
diff --git a/user/settings/nixos.nix b/user/settings/nixos.nix
index fc8362b9..bae37c56 100644
--- a/user/settings/nixos.nix
+++ b/user/settings/nixos.nix
@@ -4,12 +4,10 @@
     ./nixpkgs.nix
   ];
 
-  programs.zsh = {
-    shellAliases = {
-      srb = "sudo nixos-rebuild";
-      rbs = "sudo nixos-rebuild switch --fast";
-      rbb = "sudo nixos-rebuild boot";
-      rbr = "sudo nixos-rebuild switch --rollback";
-    };
+  home.shellAliases = {
+    srb = "sudo nixos-rebuild";
+    rbs = "sudo nixos-rebuild switch --fast";
+    rbb = "sudo nixos-rebuild boot";
+    rbr = "sudo nixos-rebuild switch --rollback";
   };
 }
diff --git a/user/settings/satoshipay.nix b/user/settings/satoshipay.nix
index 3a5513d5..a71b23b4 100644
--- a/user/settings/satoshipay.nix
+++ b/user/settings/satoshipay.nix
@@ -68,6 +68,12 @@ in
     }
   ];
 
+  home.shellAliases = {
+    kns = "kubens";
+    kx = "kubectx";
+    ks = "echo $(kubectx -c):$(kubens -c)";
+    klot = "kubetail";
+  };
   programs.zsh = {
     plugins = [
       {
@@ -81,12 +87,6 @@ in
         };
       }
     ];
-    shellAliases = {
-      kns = "kubens";
-      kx = "kubectx";
-      ks = "echo $(kubectx -c):$(kubens -c)";
-      klot = "kubetail";
-    };
     initExtra = ''
       if [[ -n $commands[helm] ]]
       then
diff --git a/user/settings/shell.nix b/user/settings/shell.nix
new file mode 100644
index 00000000..6a720894
--- /dev/null
+++ b/user/settings/shell.nix
@@ -0,0 +1,132 @@
+{ config
+, lib
+, pkgs
+, ...
+}:
+let
+  inherit (pkgs) stdenv;
+  lsOptions =
+    if stdenv.isDarwin
+    then "-p"
+    else "-v --group-directories-first --hyperlink=auto";
+  lsIsoDate =
+    if stdenv.isDarwin
+    then ""
+    else "--time-style=long-iso";
+in
+{
+  home = {
+    shellAliases = {
+      l = "ls ${lsOptions} -Bp";
+      l1 = "ls -1";
+      ls = "ls ${lsOptions} -hF";
+      la = "ls ${lsOptions} -hA";
+      ll = "ls ${lsOptions} ${lsIsoDate} -hl";
+      lal = "ll -A";
+      lla = "lal";
+      llr = "ll -t";
+
+      c = "tere";
+      "c," = "cd $(ghq list -p nixfiles)";
+      cg = "cd $(git root)";
+      cdg = "cd $(git root)";
+
+      http = "xh";
+      https = "xh --default-scheme https";
+      xhs = "xh --default-scheme https";
+
+      hist-freq-lines = "fc -l -10000 | cut -d' ' -f4- | sort | uniq -c | sort -gr | head -n100 | less";
+      hist-freq-commands = "fc -l -10000 | cut -d' ' -f4 | sort | uniq -c | sort -gr | head -n10 | less";
+      wprop = "xprop | egrep '^WM_(CLASS|NAME|WINDOW_ROLE|TYPE)'";
+
+      # Enable the following commands to support aliases.
+      sudo = "sudo ";
+      watch = "watch ";
+
+      e = "$EDITOR";
+      se = "sudo -e";
+
+      ip = "ip --color=auto";
+      ip4 = "ip -4";
+      ip6 = "ip -6";
+
+      d = "docker";
+      db = "docker build";
+      dr = "docker run";
+      di = "docker image";
+      dj = "docker pull";
+      dk = "docker push";
+
+      dcb = "dc build";
+      dcd = "dc down";
+      dcj = "dc pull";
+      dck = "dc push";
+      dcl = "dc logs";
+      dclf = "dc logs -f";
+      dcu = "dc up";
+      dcud = "dc up -d";
+      dcr = "dc restart";
+
+      ga = "git add";
+      gs = "git st";
+      gd = "git diff";
+      gdc = "git diff --cached";
+      gf = "git fetch";
+      gk = "git push";
+      gkf = "git push --force-with-lease";
+      gj = "git pull";
+      gl = "git lg";
+      gm = "git merge";
+      ge = "git remote";
+      ges = "git remote -v show";
+      gr = "git rebase";
+      gz = "git stash";
+      gzl = "git stash list";
+      gzp = "git stash pop";
+      gdt = "git difftool";
+      grl = "git reflog";
+      gri = "git rebase --interactive";
+      gfa = "git fetch --all";
+      grs = "git reset";
+      grsh = "git reset --hard";
+      gsh = "git show";
+      gsm = "git submodule";
+      gci = "git commit";
+      gx = "git restore";
+      gb = "git switch";
+      gbr = "git br";
+      gbrc = "git checkout -b";
+      gbrd = "git branch --delete";
+      gbrm = "git branch --move";
+      gmup = "git mup";
+      grup = "git rup";
+
+      ho = "home-manager";
+      hob = "home-manager build";
+      hos = "home-manager switch";
+      hon = "home-manager news";
+      hoh = "home-manager help";
+      hop = "home-manager packages";
+      hol = "home-manager generations";
+      hox = "home-manager expire-generations '-30 days'";
+
+      nish = "nix-shell";
+      nf = "nix flake";
+      nfa = "nix flake archive";
+      nfp = "nix flake prefetch";
+      nfu = "nix flake update";
+      nfl = "nix flake lock";
+      nlg = "nix-env --list-generations";
+      snlg = "sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
+      ngc = "nix-collect-garbage --delete-older-than 30d";
+      sngc = "sudo nix-collect-garbage --delete-older-than 30d";
+    };
+  };
+  programs.zsh = {
+    shellAliases = {
+      history = "fc -l $(( $LINES - 2 ))";
+
+      hor = "$(nix-shell -p home-manager --run 'home-manager generations' | head -n 2 | tail -n 1 | f 7)/activate";
+    };
+  };
+}
diff --git a/user/settings/zsh.nix b/user/settings/zsh.nix
index cd13391a..facd0efa 100644
--- a/user/settings/zsh.nix
+++ b/user/settings/zsh.nix
@@ -5,14 +5,6 @@
 }:
 let
   inherit (pkgs) stdenv;
-  lsOptions =
-    if stdenv.isDarwin
-    then "-p"
-    else "-v --group-directories-first --hyperlink=auto";
-  lsIsoDate =
-    if stdenv.isDarwin
-    then ""
-    else "--time-style=long-iso";
   zshrc = ".config/zsh/.zshrc";
   mkZshPlugin = attrs@{ name, file ? "${name}.plugin.zsh", ... }: {
     inherit name file;
@@ -102,114 +94,6 @@ in
       }
     ];
 
-    shellAliases = {
-      l = "ls ${lsOptions} -Bp";
-      l1 = "ls -1";
-      ls = "ls ${lsOptions} -hF";
-      la = "ls ${lsOptions} -hA";
-      ll = "ls ${lsOptions} ${lsIsoDate} -hl";
-      lal = "ll -A";
-      lla = "lal";
-      llr = "ll -t";
-
-      c = "tere";
-      "c," = "cd $(ghq list -p nixfiles)";
-      cg = "cd $(git root)";
-      cdg = "cd $(git root)";
-
-      http = "xh";
-      https = "xh --default-scheme https";
-      xhs = "xh --default-scheme https";
-
-      history = "fc -l $(( $LINES - 2 ))";
-      hist-freq-lines = "fc -l -10000 | cut -d' ' -f4- | sort | uniq -c | sort -gr | head -n100 | less";
-      hist-freq-commands = "fc -l -10000 | cut -d' ' -f4 | sort | uniq -c | sort -gr | head -n10 | less";
-      wprop = "xprop | egrep '^WM_(CLASS|NAME|WINDOW_ROLE|TYPE)'";
-
-      # Enable the following commands to support aliases.
-      sudo = "sudo ";
-      watch = "watch ";
-
-      e = "$EDITOR";
-      se = "sudo -e";
-
-      ip = "ip --color=auto";
-      ip4 = "ip -4";
-      ip6 = "ip -6";
-
-      d = "docker";
-      db = "docker build";
-      dr = "docker run";
-      di = "docker image";
-      dj = "docker pull";
-      dk = "docker push";
-
-      dcb = "dc build";
-      dcd = "dc down";
-      dcj = "dc pull";
-      dck = "dc push";
-      dcl = "dc logs";
-      dclf = "dc logs -f";
-      dcu = "dc up";
-      dcud = "dc up -d";
-      dcr = "dc restart";
-
-      ga = "git add";
-      gs = "git st";
-      gd = "git diff";
-      gdc = "git diff --cached";
-      gf = "git fetch";
-      gk = "git push";
-      gkf = "git push --force-with-lease";
-      gj = "git pull";
-      gl = "git lg";
-      gm = "git merge";
-      ge = "git remote";
-      ges = "git remote -v show";
-      gr = "git rebase";
-      gz = "git stash";
-      gzl = "git stash list";
-      gzp = "git stash pop";
-      gdt = "git difftool";
-      grl = "git reflog";
-      gri = "git rebase --interactive";
-      gfa = "git fetch --all";
-      grs = "git reset";
-      grsh = "git reset --hard";
-      gsh = "git show";
-      gsm = "git submodule";
-      gci = "git commit";
-      gx = "git restore";
-      gb = "git switch";
-      gbr = "git br";
-      gbrc = "git checkout -b";
-      gbrd = "git branch --delete";
-      gbrm = "git branch --move";
-      gmup = "git mup";
-      grup = "git rup";
-
-      ho = "home-manager";
-      hob = "home-manager build";
-      hos = "home-manager switch";
-      hor = "$(nix-shell -p home-manager --run 'home-manager generations' | head -n 2 | tail -n 1 | f 7)/activate";
-      hon = "home-manager news";
-      hoh = "home-manager help";
-      hop = "home-manager packages";
-      hol = "home-manager generations";
-      hox = "home-manager expire-generations '-30 days'";
-
-      nish = "nix-shell";
-      nf = "nix flake";
-      nfa = "nix flake archive";
-      nfp = "nix flake prefetch";
-      nfu = "nix flake update";
-      nfl = "nix flake lock";
-      nlg = "nix-env --list-generations";
-      snlg = "sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
-      ngc = "nix-collect-garbage --delete-older-than 30d";
-      sngc = "sudo nix-collect-garbage --delete-older-than 30d";
-    };
-
     # Put this in /etc/paths.d/ on Darwin instead
     envExtra = lib.optionalString (!stdenv.isDarwin) ''
       if [[ ''${path[(I)$HOME/.local/bin ]} ]]