GithubHelp home page GithubHelp logo

d3labsinc / alias-tips Goto Github PK

View Code? Open in Web Editor NEW

This project forked from djui/alias-tips

0.0 2.0 0.0 21 KB

An oh-my-zsh plugin to help remembering those aliases you defined once

Python 96.02% Shell 3.98%

alias-tips's Introduction

alias-tips

Build Status

A Zsh plugin to help remembering those aliases you once defined.

Works with Oh My Zsh, Antigen, zgen or pure Zsh.

It works by trying to find an alias for the command you are currently executing and printing a help line reminding you about that alias.

The idea is that you might be too afraid to execute aliases defined because you can't remember them correctly, or just have forgotten about some aliases, or that aliases for your daily commands even exist.

Example

$ ls -lh
You know you have an alias for that, right? ll
:

$ git gui
You know you have an alias for that, right? gg
:

$ git rebase --interactive master
You know you have an alias for that, right? gri master
:

Installation

oh-my-zsh

  1. Get it

    Go to your custom plugins folder:

    $ cd ${ZSH_CUSTOM1:-$ZSH/custom}/plugins

    Then either clone:

    $ git clone https://github.com/djui/alias-tips.git

    Or download:

    $ wget https://github.com/djui/alias-tips/archive/master.zip
    $ unzip master.zip && mv alias-tips-master alias-tips && rm master.zip

    Or add it as submodule:

    $ git submodule add https://github.com/djui/alias-tips
    $ git submodule update --init
  2. Include it

    Then add the plugin to your plugin list in oh-my-zsh configuration:

    $ $EDITOR ~/.zshrc
    
    # -plugins=(...)
    # +plugins=(... alias-tips)

antigen

  1. Add antigen bundle djui/alias-tips to your .zshrc with your other antigen bundle commands.

zgen

  1. Add zgen load djui/alias-tips to your .zshrc
  2. Regenerate your init.zsh with zgen save

Zsh

  1. Get it git clone https://github.com/djui/alias-tips.git
  2. Add source alias-tips/alias-tips.plugin.zsh to your .zshrc.

Usage

After installation re-source your .zshrc.

Customizations

Customize the Output

The help string can be configured exporting an environment variable, e.g. in your .zshrc:

:
export ZSH_PLUGINS_ALIAS_TIPS_TEXT="Alias tip: "
:

Exclude some Aliases

A list of aliases to be excluded from being reminded of can be configured exporting an environment variable of space separated aliases, e.g. in your .zshrc:

:
export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="_ ll vi"
:

Expand Command to Get Best Alias

If you have several alias, e.g. for different git commands you can activate the expansion of the command before looking for an alias by setting the environment variable, e.g. in your .zshrc:

:
export ZSH_PLUGINS_ALIAS_TIPS_EXPAND=1
:

Example:

alias gRv='git remote -v'
alias gR='git remote'

Without the expand option gR -v will execute without a tip, with expand, it will suggest gRv.

Limitations

  • Suffix and Global aliases are currently not supported. Only Prefix aliases ("command position") are supported. Check the Zsh manual on alias for their definition.
  • Multiline aliases (aliases which definition span multiple lines) are not supported. Currently their first line only will be used (likely incorrectly)

FAQ

Q: Why only Zsh?

A: This works because of feature in Zsh called preexec. Other shells, e.g. Bash, do not have this feature. There are workarounds[1,2] but integrating these is a task left for the reader.

Contributing

Thanks to the following people for their help:

Testing

$ python  -m unittest test_alias-tips
$ python3 -m unittest test_alias-tips

alias-tips's People

Contributors

djui avatar m42e avatar tomprince avatar unixorn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.