Add edit-config script to quickly edit dotfiles
This commit is contained in:
parent
f35b2e8304
commit
1627cc51b6
@ -47,6 +47,7 @@ config, ... }: {
|
|||||||
|
|
||||||
# Rust setup
|
# Rust setup
|
||||||
rustc
|
rustc
|
||||||
|
rustfmt
|
||||||
cargo
|
cargo
|
||||||
clippy
|
clippy
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
@ -63,6 +64,7 @@ config, ... }: {
|
|||||||
|
|
||||||
## My scripts
|
## My scripts
|
||||||
pkgs.frajul.deploy-to-pianopi
|
pkgs.frajul.deploy-to-pianopi
|
||||||
|
pkgs.frajul.edit-config
|
||||||
];
|
];
|
||||||
|
|
||||||
home.file = {
|
home.file = {
|
||||||
@ -94,6 +96,7 @@ config, ... }: {
|
|||||||
ls = "ls --color";
|
ls = "ls --color";
|
||||||
la = "ls -Alh --color";
|
la = "ls -Alh --color";
|
||||||
grep = "grep --color";
|
grep = "grep --color";
|
||||||
|
conf = "edit-config";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
31
packages/edit-config/default.nix
Normal file
31
packages/edit-config/default.nix
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
# Snowfall Lib provides a customized `lib` instance with access to your flake's library
|
||||||
|
# as well as the libraries available from your flake's inputs.
|
||||||
|
lib,
|
||||||
|
# You also have access to your flake's inputs.
|
||||||
|
inputs,
|
||||||
|
|
||||||
|
# All other arguments come from NixPkgs. You can use `pkgs` to pull packages or helpers
|
||||||
|
# programmatically or you may add the named attributes as arguments here.
|
||||||
|
pkgs, stdenv, ... }:
|
||||||
|
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "edit-config";
|
||||||
|
|
||||||
|
runtimeInputs = with pkgs; [ fd fzf ];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
FILE=$(fd -H -t f . ~/.dotfiles | fzf --query "$1")
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user