dotfiles/pkgs/edit-config/default.nix
2025-04-22 21:14:51 +02:00

35 lines
570 B
Nix

{
writeShellApplication,
fd,
fzf,
}:
writeShellApplication {
name = "edit-config";
runtimeInputs = [
fd
fzf
];
text = ''
if [[ $# == 0 ]]; then
QUERY=""
else
QUERY="$1"
fi
FILE=$(fd -H -t f . ~/.dotfiles | fzf --query "$QUERY")
if [[ "$FILE" != "" ]]; then
$EDITOR "$FILE"
else
exit 1
fi
read -rp 'Run "home-manager switch"? [Yn]: ' yn
case $yn in
Y | y | Yes | yes | "" ) home-manager switch;;
* ) echo "Not switching home-manager configuration";;
esac
'';
}