home-manager: add edit command
With this change, running home-manager edit opens `$HOME_MANAGER_CONFIG` in `$EDITOR`. This is mainly for convenience. Users should not have to remember the exact location of the Home Manager configuration.
This commit is contained in:
parent
797fbbf826
commit
571e17410a
|
@ -129,6 +129,17 @@ function presentNews() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doEdit() {
|
||||||
|
if [[ ! -v EDITOR || -z $EDITOR ]]; then
|
||||||
|
errorEcho "Please set the \$EDITOR environment variable"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
setConfigFile
|
||||||
|
|
||||||
|
exec "$EDITOR" "$HOME_MANAGER_CONFIG"
|
||||||
|
}
|
||||||
|
|
||||||
function doBuild() {
|
function doBuild() {
|
||||||
if [[ ! -w . ]]; then
|
if [[ ! -w . ]]; then
|
||||||
errorEcho "Cannot run build in read-only directory";
|
errorEcho "Cannot run build in read-only directory";
|
||||||
|
@ -354,6 +365,8 @@ function doHelp() {
|
||||||
echo
|
echo
|
||||||
echo " help Print this help"
|
echo " help Print this help"
|
||||||
echo
|
echo
|
||||||
|
echo " edit Open the home configuration in \$EDITOR"
|
||||||
|
echo
|
||||||
echo " build Build configuration into result directory"
|
echo " build Build configuration into result directory"
|
||||||
echo
|
echo
|
||||||
echo " switch Build and activate configuration"
|
echo " switch Build and activate configuration"
|
||||||
|
@ -430,6 +443,9 @@ cmd="$1"
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
|
edit)
|
||||||
|
doEdit
|
||||||
|
;;
|
||||||
build)
|
build)
|
||||||
doBuild
|
doBuild
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue