diff options
author | zimbatm <zimbatm@zimbatm.com> | 2018-12-03 11:19:22 +0100 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2018-12-04 23:17:19 +0100 |
commit | 571e17410a173824c5b8c65468da02f7b2b335b8 (patch) | |
tree | 196abe7f8735046d813b7da59d468e72e5ee469c /home-manager | |
parent | 797fbbf826f57165df27911d0cd1413bcb801dfc (diff) |
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.
Diffstat (limited to 'home-manager')
-rw-r--r-- | home-manager/home-manager | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/home-manager/home-manager b/home-manager/home-manager index 88c8a32cda7..65c54c63712 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -129,6 +129,17 @@ function presentNews() { 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() { if [[ ! -w . ]]; then errorEcho "Cannot run build in read-only directory"; @@ -354,6 +365,8 @@ function doHelp() { echo echo " help Print this help" echo + echo " edit Open the home configuration in \$EDITOR" + echo echo " build Build configuration into result directory" echo echo " switch Build and activate configuration" @@ -430,6 +443,9 @@ cmd="$1" shift 1 case "$cmd" in + edit) + doEdit + ;; build) doBuild ;; |