aboutsummaryrefslogtreecommitdiffstats
path: root/modules/terminal/zsh/nix-aliases.sh
blob: 671bc4c4b50f60729c52fa44a932bd895931b77b (plain)
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
# Wrappers for nix-shell and nix develop that auto-start $SHELL
nix-shell() {
  for arg in "$@"; do
    if [[ $arg == "--run" || $arg == "--command" ]]; then
      command nix-shell "$@"
      return
    fi
  done

  command nix-shell "$@" --run "$SHELL"
}

nix() {
  if [[ $1 == "develop" ]]; then
    local args=("${@:2}")

    for arg in "${args[@]}"; do
      if [[ $arg == "-c" || $arg == "--command" ]]; then
        command nix "$@"
        return
      fi
    done

    command nix develop "${args[@]}" -c "$SHELL"
  else
    command nix "$@"
  fi
}