logout-user.plugin.zsh is a custom plugin for oh-my-zsh
that provides a function to log out another macOS user
session. Below is a brief documentation for the script:
The logout-user function allows you to terminate another
macOS user's session with`sudo launchctl bootout gui/suid].
logout-user [options] [username)-h, |--help : Displays help information about the command.
-n: Dry run mode. Displays the command that would be executed without actually running it.Display help:
logout-user -hLog out a user named steve:
logout-user stevePerform a dry run for the user steve:
logout-user -n steve- Validates the provided username.
- Prevents logging out the root user.
- Prompts for confirmation before executing the
logoutcommand. - Supports username auto-completion via
compdef.
Clone the repository to your custom plugins directory:
cd $ZSH_CUSTOM/plugins
git clone https://github.com/pressdarling/logout-user.git logout-userAdd the plugin to your .zshrc file:
plugins=(... logout-user)Reload your shell or restart your terminal.
# with oh-my-zsh
omz reload
# without oh-my-zsh, silly way
source ~/.zshrc
# without oh-my-zsh, proper way
exec zshThis plugin should work with most plugin managers, including zplug, zinit, antibody, zgen, antigen, zgenom, and prezto.
# with antibody
antibody bundle < ~/.zsh_plugins.txt > ~/.zsh_plugins.sh
# with antidote
antidote update
# with antigen
antigen reset && antigen apply
# with prezto
prezto-update
# with zgenom
zgenom reset && zgenom save
# with zim
zimfw install
# with zinit
zinit update && zinit creinstall
# with custom plugin manager
<custom-plugin-manager> reload- Download the
logout-user.plugin.zshfile from the repository. - Save the script to your
$ZSH_CUSTOM/plugins/logout-userdirectory:~/.oh-my-zsh/custom/plugins/logout-user/logout-user-plugin.zsh - Add the plugin to your
.zshrcfile:plugins=(... logout-user)
Save the script to your $CUSTOM/plugins/logout-user directory:
Add the plugin to your zshre file:
plugins=(... logout-user)
Reload
your shell or restart your terminal.