Update 30.01.2022
This commit is contained in:
1
zsh/plugins/aliases/.gitignore
vendored
Normal file
1
zsh/plugins/aliases/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__
|
||||
@@ -1,21 +1,22 @@
|
||||
## Aliases Cheatsheet
|
||||
# Aliases cheatsheet
|
||||
|
||||
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
|
||||
|
||||
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
|
||||
that are currently available based on the plugins you have enabled.
|
||||
|
||||
Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
To use it, add `aliases` to the plugins array in your zshrc file:
|
||||
|
||||
```
|
||||
plugins=(aliases)
|
||||
```
|
||||
```zsh
|
||||
plugins=(aliases)
|
||||
```
|
||||
|
||||
Requirements: Python needs to be installed.
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
|
||||
```
|
||||
acs: group all alias
|
||||
acs $keywordquickly filter alias & highlight
|
||||
```
|
||||
- `acs`: show all aliases by group.
|
||||
|
||||
- `acs <keyword>`: filter aliases by `<keyword>` and highlight.
|
||||
|
||||

|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#
|
||||
# - acs: alias cheatsheet
|
||||
# group alias by command, pass addition argv to grep.
|
||||
ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
|
||||
function acs(){
|
||||
which python >>/dev/null
|
||||
[[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return
|
||||
alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@
|
||||
(( $+commands[python] )) || {
|
||||
echo "[error] No python executable detected"
|
||||
return
|
||||
}
|
||||
alias | python ${functions_source[$0]:h}/cheatsheet.py $@
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@ def cheatsheet(lines):
|
||||
target_aliases.extend(group_list)
|
||||
return cheatsheet
|
||||
|
||||
def pretty_print_group(key, aliases, hightlight=None):
|
||||
def pretty_print_group(key, aliases, highlight=None):
|
||||
if len(aliases) == 0:
|
||||
return
|
||||
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
|
||||
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
|
||||
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
|
||||
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
|
||||
if hightlight and len(hightlight)>0:
|
||||
print (group_hl_formatter(key, hightlight))
|
||||
print ('\n'.join([alias_hl_formatter(alias, hightlight) for alias in aliases]))
|
||||
if highlight and len(highlight)>0:
|
||||
print (group_hl_formatter(key, highlight))
|
||||
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
|
||||
else:
|
||||
print (group_formatter(key))
|
||||
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#
|
||||
# Author: Konstantin Lepa <konstantin.lepa@gmail.com>
|
||||
|
||||
"""ANSII Color formatting for output in terminal."""
|
||||
"""ANSI Color formatting for output in terminal."""
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
|
||||
Reference in New Issue
Block a user