From 2054fe49b81a8567bf8991d2ebed98217a7f6b41 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 18 Jan 2023 15:03:26 -0500 Subject: [PATCH] move wg0 alias to aliases file --- zsh/.config/zsh/config.d/10_aliases.zsh | 15 +++++++++++++++ zsh/.zshrc | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/zsh/.config/zsh/config.d/10_aliases.zsh b/zsh/.config/zsh/config.d/10_aliases.zsh index d541c7f..bd4a958 100644 --- a/zsh/.config/zsh/config.d/10_aliases.zsh +++ b/zsh/.config/zsh/config.d/10_aliases.zsh @@ -25,3 +25,18 @@ function mkcd { mkdir -p $1 && cd $1 } if [ "$TERM_PROGRAM" = "vscode" ]; then alias code='code -r' fi + +# A function which toggles the status of a systemd service +function systemctl_toggle { + if systemctl is-active --quiet $1; then + sudo systemctl stop $1 + else + sudo systemctl start $1 + fi +} + +# Alias `wg0` to toggle the wg0 interface if registered via systemd +if command -v "wg-quick" 2>&1 >/dev/null; then + # User program: make `wg-quick up wg0` less of a pain + alias wg0="systemctl_toggle wg-quick@wg0.service" +fi diff --git a/zsh/.zshrc b/zsh/.zshrc index cc1c87e..7771c33 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -23,13 +23,3 @@ export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" # User program: add 1password SSH utils export PATH="$HOME/.1password-ssh-utils/bin:$PATH" alias ssh="op-ssh-fetch -n && ssh" - -# User program: make `wg-quick up wg0` less of a pain -function systemctl_toggle { - if systemctl is-active --quiet $1; then - sudo systemctl stop $1 - else - sudo systemctl start $1 - fi -} -alias wg0="systemctl_toggle wg-quick@wg0.service"