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 -h
Log out a user named steve
:
logout-user steve
Perform 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
logout
command. - 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-user
Add 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 zsh
This 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.zsh
file from the repository. - Save the script to your
$ZSH_CUSTOM/plugins/logout-user
directory:~/.oh-my-zsh/custom/plugins/logout-user/logout-user-plugin.zsh
- Add the plugin to your
.zshrc
file: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.