naitokosuke · dotfiles

Zsh is the only shell: the login shell for IDE integrations and SSH, and the interactive shell in Ghostty. PATH comes from nix-darwin's /etc/zshenv (hosts/common/nix.nix).

Nix-managed binaries stay out of Homebrew

Exported as HOMEBREW_FORBIDDEN_FORMULAE below, so brew install can never shadow one of these with a Homebrew copy (Homebrew/brew#19939).

lines 14–31
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31  homebrewForbiddenFormulae = [
    "bun"
    "claude"
    "deno"
    "fd"
    "fzf"
    "gh"
    "git"
    "node"
    "npm"
    "pip"
    "pnpm"
    "python"
    "python3"
    "ripgrep"
    "vim"
    "yarn"
  ];

Aliases and helpers

cpwd copies the current directory to the clipboard, mkcd makes a directory and enters it, and a new terminal starts in the ghq directory unless VS Code opened it.

lines 46–63
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63    shellAliases = {
      l = "ls";
      la = "ls -la";
      ll = "ls -l";
      ":q" = "exit";
      cl = "clear";
      cpwd = "pwd | pbcopy";
    };
    initContent = ''
      mkcd() {
        mkdir -p "$1" && cd "$1"
      }

      # A new terminal starts in the ghq directory unless VS Code opened it.
      if [[ -z $VSCODE_GIT_IPC_HANDLE && $TERM_PROGRAM != vscode ]]; then
        cd ${lib.escapeShellArg config.naitokosuke.githubDirectory}
      fi
    '';
View the complete file66 lines · zsh.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66# Zsh is the only shell: the login shell for IDE integrations and SSH, and
# the interactive shell in Ghostty. PATH comes from nix-darwin's /etc/zshenv
# (hosts/common/nix.nix).
{
  config,
  lib,
  ...
}:

let
  ## Nix-managed binaries stay out of Homebrew
  # Exported as HOMEBREW_FORBIDDEN_FORMULAE below, so `brew install` can never
  # shadow one of these with a Homebrew copy (Homebrew/brew#19939).
  homebrewForbiddenFormulae = [
    "bun"
    "claude"
    "deno"
    "fd"
    "fzf"
    "gh"
    "git"
    "node"
    "npm"
    "pip"
    "pnpm"
    "python"
    "python3"
    "ripgrep"
    "vim"
    "yarn"
  ];
in
{
  home.sessionVariables = {
    EDITOR = "vim";
    HOMEBREW_FORBIDDEN_FORMULAE = lib.concatStringsSep " " homebrewForbiddenFormulae;
  };

  programs.zsh = {
    enable = true;

    ## Aliases and helpers
    # `cpwd` copies the current directory to the clipboard, `mkcd` makes a
    # directory and enters it, and a new terminal starts in the ghq directory
    # unless VS Code opened it.
    shellAliases = {
      l = "ls";
      la = "ls -la";
      ll = "ls -l";
      ":q" = "exit";
      cl = "clear";
      cpwd = "pwd | pbcopy";
    };
    initContent = ''
      mkcd() {
        mkdir -p "$1" && cd "$1"
      }

      # A new terminal starts in the ghq directory unless VS Code opened it.
      if [[ -z $VSCODE_GIT_IPC_HANDLE && $TERM_PROGRAM != vscode ]]; then
        cd ${lib.escapeShellArg config.naitokosuke.githubDirectory}
      fi
    '';
  };
}
66 lines·1,490 chars·NIX