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
- Host: GitHub
- URL: https://github.com/marcusbuffett/zsh-force-alias
- Owner: marcusbuffett
- Created: 2016-08-06T20:55:00.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-07-21T03:06:15.000Z (almost 8 years ago)
- Last Synced: 2024-05-01T13:08:29.835Z (about 2 years ago)
- Language: Rust
- Size: 30.3 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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.