summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2015-01-06 19:31:39 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2015-01-12 22:08:40 +0100
commit0cc69f13c2355831e8f07962c072c09ca35fd5f3 (patch)
tree68bfc12809da42dc51b59a27b9c3eb694f748106
parentf9a86cbf053a91a387499615bc6930548a51a463 (diff)
downloadnetctl-0cc69f13c2355831e8f07962c072c09ca35fd5f3.tar.gz
netctl-0cc69f13c2355831e8f07962c072c09ca35fd5f3.tar.xz
Add edit subcommand to netctl
-rw-r--r--contrib/bash-completion4
-rw-r--r--contrib/zsh-completion5
-rw-r--r--docs/netctl.1.txt10
-rw-r--r--src/netctl.in5
4 files changed, 16 insertions, 8 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion
index 0e5804f..4f73fab 100644
--- a/contrib/bash-completion
+++ b/contrib/bash-completion
@@ -23,10 +23,10 @@ _netctl()
case $COMP_CWORD in
1)
- COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable is-enabled reenable" -- "$cur") )
+ COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable is-enabled edit" -- "$cur") )
;;
2)
- [[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|status|enable|disable|is-enabled|reenable) ]] &&
+ [[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|status|enable|disable|reenable|is-enabled|edit) ]] &&
mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur")
;;
esac
diff --git a/contrib/zsh-completion b/contrib/zsh-completion
index 8e88437..05c506f 100644
--- a/contrib/zsh-completion
+++ b/contrib/zsh-completion
@@ -11,7 +11,7 @@ _wireless_interfaces() {
(( $+function[_netctl_command] )) ||
_netctl_command() {
- [[ $words[1] = (start|stop|restart|switch-to|status|enable|disable|is-enabled|reenable) ]] &&
+ [[ $words[1] = (start|stop|restart|switch-to|status|enable|disable|reenable|is-enabled|edit) ]] &&
compadd "${(f)$(find -L /etc/netctl -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n")}"
}
@@ -30,8 +30,9 @@ _netctl_commands() {
'status:Show runtime status of a profile'
'enable:Enable the systemd unit for a profile'
'disable:Disable the systemd unit for a profile'
- 'is-enabled:Check whether a profile is enabled'
'reenable:Reenable the systemd unit for a profile'
+ 'is-enabled:Check whether a profile is enabled'
+ 'edit:Edit a profile'
)
_describe "netctl commands" _commands
}
diff --git a/docs/netctl.1.txt b/docs/netctl.1.txt
index 4120bdc..1f8b8cf 100644
--- a/docs/netctl.1.txt
+++ b/docs/netctl.1.txt
@@ -68,13 +68,17 @@ The following commands are understood:
the file created by `*enable*' even if it was customized, so be
careful.
+*reenable [+PROFILE+]*::
+ Reenable the systemd unit for the profile specified. This is
+ effectively a combination of `*disable*' and `*enable*'.
+
*is-enabled [+PROFILE+]*::
Check whether the systemd unit for the specified profile is enabled.
Prints the current enable status.
-*reenable [+PROFILE+]*::
- Reenable the systemd unit for the profile specified. This is
- effectively a combination of `*disable*' and `*enable*'.
+*edit [+PROFILE+]*::
+ Open the file of the specified profile in an editor. This does not
+ reenable or restart any profiles.
EXIT STATUS
diff --git a/src/netctl.in b/src/netctl.in
index b66cf71..2953ecf 100644
--- a/src/netctl.in
+++ b/src/netctl.in
@@ -20,8 +20,9 @@ Commands:
status [PROFILE] Show runtime status of a profile
enable [PROFILE] Enable the systemd unit for a profile
disable [PROFILE] Disable the systemd unit for a profile
- is-enabled [PROFILE] Check whether a profile is enabled
reenable [PROFILE] Reenable the systemd unit for a profile
+ is-enabled [PROFILE] Check whether a profile is enabled
+ edit [PROFILE] Edit a profile
END
}
@@ -180,6 +181,8 @@ case $# in
if sd_booted; then
systemctl daemon-reload
fi;;
+ edit)
+ exec ${EDITOR:-nano} "$PROFILE_DIR/$2";;
*)
exit_error "$(usage)";;
esac;;