From 880efe7fc4ba40ef704cc2de88d120c6ae4c6a6b Mon Sep 17 00:00:00 2001 From: Shun Kakinoki Date: Mon, 12 Jan 2026 00:15:18 +0900 Subject: [PATCH] feat(fish): add global dev command for nix devshell Add a `dev` fish abbreviation that enters a Nix development shell from anywhere. The function searches for the nearest flake.nix in parent directories and uses that devshell, or falls back to ~/dotfiles if no flake is found. --- home-manager/programs/fish/default.nix | 2 ++ .../fish/functions/_dev_function.fish | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 home-manager/programs/fish/functions/_dev_function.fish diff --git a/home-manager/programs/fish/default.nix b/home-manager/programs/fish/default.nix index af1856f61..7147f438a 100644 --- a/home-manager/programs/fish/default.nix +++ b/home-manager/programs/fish/default.nix @@ -65,6 +65,7 @@ coxeh = "_coxeh_function"; coxel = "_coxel_function"; coxelh = "_coxelh_function"; + dev = "_dev_function"; ocxe = "_ocxe_function"; ocxeh = "_ocxeh_function"; gco = "_gco_function"; @@ -137,6 +138,7 @@ "_coxeh_function" "_coxel_function" "_coxelh_function" + "_dev_function" "_ocxe_function" "_ocxeh_function" "_fish_shortcuts" diff --git a/home-manager/programs/fish/functions/_dev_function.fish b/home-manager/programs/fish/functions/_dev_function.fish new file mode 100644 index 000000000..08708a344 --- /dev/null +++ b/home-manager/programs/fish/functions/_dev_function.fish @@ -0,0 +1,23 @@ +function _dev_function --description "Enter Nix development shell" + # Find the nearest directory with flake.nix, or use dotfiles + set -l target_dir "" + + # Check if current directory or any parent has flake.nix + set -l check_dir (pwd) + while test "$check_dir" != "/" + if test -f "$check_dir/flake.nix" + set target_dir $check_dir + break + end + set check_dir (dirname $check_dir) + end + + # Fallback to dotfiles if no flake found + if test -z "$target_dir" + set target_dir "$HOME/dotfiles" + end + + # Enter the devshell + echo "Entering devshell in $target_dir" + DEVENV_ROOT=$target_dir nix develop $target_dir $argv +end