DEV Community

Cover image for Manage your aliases with z-alias
Benjamin CARADEUC
Benjamin CARADEUC

Posted on • Edited on

Manage your aliases with z-alias

French version HERE


Haven't you ever wanted to use a your CLI like a pro, but never been able to remember that specific command you need ?

That happens to me all the time.

Haven't you been bored of writing that very long command in your terminal when you could have made it only 1 character ?

Everyday...

Don't you want to replace an existing command with one that makes the output finally readable ?

Hell, yeah!

Aren't you tired of always forgetting how to create new aliases and make them permanent ?

Guilty 😇️


 Here is your solution

GitHub logo benavern / z-alias

Edit your bash aliases the funny way

Z-ALIAS

Edit your bash aliases the funny way

npm

About

This project provides an easy solution for using aliases from your command line. z-alias solves the hassle of remembering how to create / edit / delete your aliases.

Install

npm i -g z-alias

Usage

z-alias -h
  Usage
    $ z-alias [options] [arguments]
    Options
    --list, -l    List all aliases
    --open, -o    Open aliases file in your favorite editor
    --search, -s  Search in aliases
    --add, -a     Add an alias
    --edit, -e    Edit an alias
    --remove, -r  Remove an alias

    --help, -h    Display help
    --version, -v Print z-alias version

  Examples:
    $ z-alias -l
    $ z-alias -o
    $ z-alias -s [<searchTerm> <searchTerm2> ...]
    $ z-alias -a [<aliasName> "<aliasCommand>"]
    $ z-alias -e [<aliasName> "<aliasCommand>"]
    $ z-alias -r [<aliasName> <aliasName2> ...]

  Configuration:  
    * To change the path of the aliases file, paste and adapt this line
      at the end of your .bashrc file.

      export Z_ALIAS_FILE=~/.bash_aliases
  
    * To make

(pronounced ði ˈeɪliəs, like "The alias")

It is a little CLI app that I made in 1 day. It helps me manage my aliases, edit them, delete them, and it also works with Zsh!


How to

Install

First, install it globally

npm i -g z-alias

Usage

Then you can use it. You can find some help by typing

z-alias -h
  Usage:
    $ z-alias [options] [arguments]

    Options:
    --list, -l    List all aliases
    --open, -o    Open aliases file in your favorite editor
    --search, -s  Search in aliases
    --add, -a     Add an alias
    --edit, -e    Edit an alias
    --remove, -r  Remove an alias

    --help, -h    Display help
    --version, -v Print z-alias version

  Examples:
    $ z-alias -l
    $ z-alias -o
    $ z-alias -s [<searchTerm> <searchTerm2> ...]
    $ z-alias -a [<aliasName> "<aliasCommand>"]
    $ z-alias -e [<aliasName> "<aliasCommand>"]
    $ z-alias -r [<aliasName> <aliasName2> ...]

  Configuration:  
    * To change the path of the aliases file, paste and adapt this line
      at the end of your .bashrc file.

      export Z_ALIAS_FILE=~/.bash_aliases

    * To make your aliases available in all new shells paste this line
      at the end of your .bashrc file (adapt if above line has been added).

      if [ -f ~/.bash_aliases ]; then source ~/.bash_aliases; fi

The search option can take more than one search term.

The add, edit, remove options take optional parameters, you will be able to change your mind once you've hit ENTER.

Settings

You can change the path to the file where the aliases are stored by exporting a Z_ALIAS_FILE environment variable in your .bashrc.

You can make it work with Zsh and other alternative shells by adding these lines to the end of your .zshrc for example

if [ -f ~/.bash_aliases ]; then
    source ~/.bash_aliases
fi;

Contribute

Feel free to contribute to the project. I'll be glad to read your issues and help, to review your merge-requests.

If you find that tool usefull, you can buy me a beer too here

Top comments (0)