An open API service indexing awesome lists of open source software.

https://github.com/marcusbuffett/zsh-force-alias

Forces the use of aliases in a zsh shell
https://github.com/marcusbuffett/zsh-force-alias

Last synced: 11 months ago
JSON representation

Forces the use of aliases in a zsh shell

Awesome Lists containing this project

README

          

## Force zsh aliases

This is a program that will force you to use your zsh aliases. It works by installing a hook that executes before any commands. It uses a client-server architecture, each client being invidual shells and the server running in the background on port 5571.

## Usage

https://asciinema.org/a/81955

## Installation

First, install cargo, rust, and the binaries in this package (through cargo).
```bash
curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
git clone https://github.com/marcusbuffett/zsh-force-alias force_alias
pushd force_alias
cargo install --path .
popd
rm -rf force_alias
```

Then, add the following snippet to the bottom of your zsh file.

```bash
#####################
## ZSH force alias ##
(force-alias-server > /dev/null &) > /dev/null 2>&1
if [[ -z "$NO_CHECK" ]]; then force-alias-client --init --pid $$; fi
function force_alias_hook() {
if [[ -n "$NO_CHECK" ]]; then zle accept-line; return; fi
force-alias-client --pid $$ -- $BUFFER
if [[ $? -eq 1 ]]; then BUFFER=""; fi
zle accept-line
}
autoload -U add-zsh-hook; zle -N force_alias_hook;
bindkey '^J' force_alias_hook; bindkey '^M' force_alias_hook;
## End ZSH force alias ##
#########################
```

Now open a new shell and test it out by using a command that you have aliased, it should prevent you from executing it.