format-aliases

Crates.ioformat-aliases
lib.rsformat-aliases
version0.1.0
sourcesrc
created_at2023-05-16 21:44:47.521313
updated_at2023-05-16 21:44:47.521313
descriptionPrint active shell aliases with nice formatting
homepagehttps://github.com/adam-gaia/format-aliases
repositoryhttps://github.com/adam-gaia/format-aliases
max_upload_size
id866346
size50,724
Adam Gaia (adam-gaia)

documentation

https://github.com/adam-gaia/format-aliases

README

format-aliases

This is a reimplementation of the OhMyZsh alias cheatsheet plugin.

$ alias
[nvim]
  vim='nvim'
  wiki='nvim +VimwikiIndex'

[vim]
  emacs='vim'
  vi='vim'

[ls]
  l='ls -alh'
  ll='ls -l'

[path]
  spath='path --sort'
  tpath='path --tree'

Installation

Cargo

cargo install format-aliases

Nix Flake

This repo is a flake. The derivation with the exec is format-aliases.packages.${system}.default

Setup

Run the format-aliases init sequence in your shell's rc file. A new function will be included in your shell that overrides the alias builtin.

# Posix shell example
alias() {
    if [ $# -eq 0 ]; then
        # Pipe the output of the builtin alias command to be formatted
        builtin alias | format-aliases
    else
        # Pass the arguments to the builtin alias command
        builtin alias ${@}
    fi
}

Init sequences by shell

Zsh

eval "$(format-aliases init zsh)"

Bash

eval "$(format-aliases init bash)"

Bourne Shell (sh)

eval "$(format-aliases init sh)"

Usage

Run the new alias command without any args to display all active aliases. Running with input args will pass args to the shell's alias builtin.

Color control

Printing in color is enabled by default. Set env var NO_COLOR to disable.

NO_COLOR alias
Commit count: 6

cargo fmt