GithubHelp home page GithubHelp logo

michaelaquilina / zsh-you-should-use Goto Github PK

View Code? Open in Web Editor NEW
1.4K 8.0 41.0 490 KB

๐Ÿ“Ž ZSH plugin that reminds you to use existing aliases for commands you just typed

License: GNU General Public License v3.0

Shell 100.00%
zsh zsh-plugin aliases productivity alias reminders

zsh-you-should-use's Introduction

You Should Use

CircleCI Version GPLv3

Simple zsh plugin that reminds you that you should use one of your existing aliases for a command you just typed.

Also supports detection of global and git aliases.

Customization

Advanced Features

Contributing

You can also view the CHANGELOG for a history of changes.

Usage

You dont need to do anything. Once it's installed, zsh-you-should-use will let you know if you wrote a command with an existing alias.

image

you-should-use also detects global aliases:

image

and Git aliases:

image

Requirements

you-should-use officially supports zsh versions 5.1 onwards.

It is possible the plugin might work on even older versions. However they would not have been tested as part of the CI test process.

Installation

Add one of the following to your .zshrc file depending on your package manager:

ZPlug

zplug "MichaelAquilina/zsh-you-should-use"

Antigen

antigen bundle "MichaelAquilina/zsh-you-should-use"

Zgen

zgen load "MichaelAquilina/zsh-you-should-use"

Fig

Install zsh-you-should-use with Fig in just one click.

Install with Fig

oh-my-zsh

Clone this repository into $ZSH_CUSTOM/custom/plugins:

git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use

$ZSH_CUSTOM is oh-my-zshโ€™s customization directory (docs).

Then add you-should-use to the plugins array in your .zshrc:

plugins=(
    # ...
    you-should-use
    # ...
)

Arch Linux

Install the zsh-you-should-use (AUR) package:

yay -S zsh-you-should-use

Then add this line to your .zshrc:

source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh

Message Position

By default, you-should-use will display its reminder message before a command has executed. However, you can choose to display the mesasge after a command has executed by setting the value of YSU_MESSAGE_POSITION.

export YSU_MESSAGE_POSITION="after"

Displaying Results

By default, you-should-use will display the best match from any matching aliases found. However, you can change this behaviour so that it displays all matches found by setting the value of YSU_MODE.

  • To only display best match (default): export YSU_MODE=BESTMATCH
  • To display all matches: export YSU_MODE=ALL

Customising Messages

By default, the following message is displayed in bold when an alias is found:

Found existing %alias_type for "%command". You should use: "%alias"

Where the following variables represent:

  • %alias_type - the type of alias detected (alias, git alias, global alias)
  • %command - the command that was typed by the user
  • %alias - the matching alias that was found

This default message can be customised by setting the YSU_MESSAGE_FORMAT environment variable.

If for example, you wish to display your own custom message in red, you can add the following to your ~/.zshrc:

export YSU_MESSAGE_FORMAT="$(tput setaf 1)Hey! I found this %alias_type for %command: %alias$(tput sgr0)"

$(tput setaf 1) generates the escape code terminals use for red foreground text. $(tput sgr0) sets the text back to a normal color.

You can read more about how you can use tput and terminal escape codes here: http://wiki.bash-hackers.org/scripting/terminalcodes

Hardcore Mode

For the brave and adventerous only :godmode:

You can enable Hardcore mode to enforce the use of aliases. Enabling this will cause zsh to refuse to execute commands you have entered if an alternative alias for it exists. This is a handy way of forcing you to use your aliases and help you turn those aliases into muscle memory.

Enable hardcore mode by setting the variable YSU_HARDCORE to 1.

export YSU_HARDCORE=1

Now if you type a command that has an alias defined and you didnt use it, zsh will refuse to execute that command:

$ export YSU_HARDCORE=1
$ ls -lh
Found existing alias for "ls -lh". You should use: "ll"
You Should Use hardcore mode enabled. Use your aliases!
$ ll
total 8.0K
-rw-r--r-- 1 michael users 2.4K Jun 19 20:46 README.md
-rw-r--r-- 1 michael users  650 Jun 19 20:42 you-should-use.plugin.zsh

Check your Alias usage

It's often useful to check how often we use our aliases so that we have an idea of which ones we could probably get rid of (or remind ourselves of them if we forgot). zsh-you-should-use provides a convenience function check_alias_usage which you can run to analyse your alias usage.

$ check_alias_usage
924: curl='curl --silent'
652: gco='git checkout'
199: json='jq '.' -C'
157: less='less -R'
100: ll='ls -lh --group-directories-first'
93: vim='nvim'
76: watch='watch '
61: v='vim'
60: md='mkdir'
39: gr='git rebase'
38: dc='docker-compose'
35: ls='ls --color=auto'
33: h='history'
28: dcr='docker-compose

check_alias_usage analyses your history to generate this data for you. If your history is disabled or if you limit your history to a certain amount of time, then the alias report generated will be a reflection of the limited data available.

Optionally, you can limit how far check_alias_usage looks back in history by providing an optional numeric parameter. This parameter specifies how many entries in the history to check when generating the report. In the example below, history is limited to the last 200 entries when generating the alias report.

$ check_alias_usage 200
9: h='history'
3: gpoh='git push -u origin HEAD'
3: gco='git checkout'
2: v='vim'
2: ll='ls -lh --group-directories-first'
2: gpohw='gpoh && git web --pull-request'
2: gc='git commit'
2: gap='git add -p'
2: ap='ansible-playbook'
1: xopen='GDK_BACKEND=wayland xdg-open'
1: t='tig'
1: gw='git web'
1: gs='git status'

Disable Hints for specific Aliases

You can tell you-should-use to permanently ignore certain aliases by including them in the YSU_IGNORED_ALIASES variable (which is an array):

$ ls -l
Found existing alias for "ls -l". You should use: "ll"

$ export YSU_IGNORED_ALIASES=("g" "ll")
$ ls -l

If you want to ignore global aliases, use the YSU_IGNORED_GLOBAL_ALIASES environment variable.

$ cd ../..
Found existing global alias for "../..". You should use: "..."

$ export YSU_IGNORED_GLOBAL_ALIASES=("...")
$ cd ../..

Temporarily Disabling Messages

You can temporarily disable you should use by running the command disable_you_should_use.

When you want to re-enable messages, run the command enable_you_should_use.

Contributing

Pull requests and Feedback are welcome! ๐ŸŽ‰

I have tried to cater for as many use cases that I can think of. However, they are naturally tailored to to my own workflow and I could be missing many others.

Because of this if there is a specific use case that does not work as you would expect or if you have any suggestions to how the plugin should behave, feel free to open an issue

Running Tests

Install zunit. Run zunit in the root directory of the repo.

$ zunit
Launching ZUnit
ZUnit: 0.8.2
ZSH:   zsh 5.3.1 (x86_64-suse-linux-gnu)

โœ” ysu message correct output
โœ” ysu global message correct output
โœ” ysu git message correct output

NOTE: It is required that you use a minimum zunit version of 0.8.2

NOTE: The tests that run move your git configuration to a temporary location during the test process so that your user configuration does not interfere with tests. This will be restored at the end of each test so there is no risk in losing your settings. If for some strange reason zunit crashes or does not restore your git configuration automatically, all you need to do is run mv ~/.gitconfig.bak ~/.gitconfig

zsh-you-should-use's People

Contributors

abridgett avatar adamchainz avatar architector4 avatar benwaffle avatar brendanfalk avatar chrisgrieser avatar crater2150 avatar hultberg avatar jkomoroski avatar kaykayehnn avatar kenekanem avatar michaelaquilina avatar n1amr avatar sumnerevans avatar xpmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zsh-you-should-use's Issues

Print to stdout can mess plugins

Best use case:
zsh plugin git which we all use cannot complete branch names, because it does git branch --all, and the output from you-should-use will mess the output.

If there was a way to test current context and know if the user didn't type in the command, the text can be hidden.

Plugin Request

Similar to you-should-use, I'd really use a plugin that would remind you of best practices.
You could set this plugin to show a message in color8 from .Xresources on the right side of the command line to show a best practicy command. for instance, I could set:

% git branch |                                                                                                                                    ysu git checkout -b

this wouldn't fire after command execution in you-should-use fashion because you can have true intentions of using the command you typed.

This was intended as an email, but I couldn't find your email. Sorry.

Question/suggestion: printing alias content before execution

Issue Details

Operating System (uname -a)

Linux NivG-T490 5.4.0-104-generic #118~18.04.1-Ubuntu SMP Thu Mar 3 13:53:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

zsh version (zsh --version)

zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Question/Suggestion

I have an idea that I wanted to document in an issue, in order to:

  1. Ask if the idea is feasible at all.
  2. If it is, then maybe take up on it when I can.

Would it be possible to use the existing framework to check if a command that has been entered is an alias, and if so, also print the full command before running it?

So an example execution would look something like this:

$ git pull
Found existing alias for "git pull". You should use: "gl"

$ gl
Running an aliased command: "git pull"
Already up to date.

Global aliases detected incorrectly in substrings

Linux manjaro 5.3.18-1-MANJARO #1 SMP PREEMPT Wed Dec 18 18:34:35 UTC 2019 x86_64 GNU/Linux
zsh 5.7.1 (x86_64-pc-linux-gnu)
you-should-use version 1.6.0 installed through https://github.com/zdharma/zplugin

Steps to reproduce the issue

% alias -g n="nvim" # I make it a global alias to use it with sudo
% nvimkaowjqwe # nvim followed by gibberish or an actual command starting with nvim (I have a nvimrc alias for ~/nvim/init.vim)
Found existing global alias for "nvim". You should use: "n"

gist link to your zshrc

I tried it with zsh -f, sourced zplugin and loaded you-should-use and the problem persisted; my zshrc in dotfiles repo is outdated, spare me.

Not useful when aliased to 'command <command>'

Issue Details

To avoid aliasing based on other aliases, most of my zsh aliases are aliased to 'command ' like
alias ls='command ls' and alias g='command git'. (command is a zsh builtin.)
zsh-you-should-use doesn't work well with these aliases.

For example,
I have cmd='command' and sas='command SwitchAudioSource ' in my aliases:
image

Please provide the following details when opening an issue:

Operating System (uname -a)

Darwin me 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64 i386 MyMacBook Darwin

(macOS Catalina 10.15.7)

zsh version (zsh --version)

zsh 5.8 (x86_64-apple-darwin19.3.0)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

unalias git && alias g='command git'
git

gist link to your zshrc

My zshrc is not useful for this issue.

Git alias matching ignores parameters

The matching for git aliases ignores parameters that may be included in the alias. This causes YSU to recommend aliases that do something different (and in my case even are longer than the command I typed). YSU should only recommend aliases, that do not contain parameters not included in the command.

Example:

I have an alias, that allows me to redo the last commit with git recommit:

alias.recommit commit --amend --reuse-message=HEAD

Now, for any git-commit command the alias is suggested, even though using it would do something different:

% git commit -m 'Add stuff'
Found existing git alias for "commit". You should use: "git recommit"

Only show one result for overlapping aliases

I get the following output for git status:

$ git status
Found existing alias for "git". You should use: "g"
Found existing alias for "git status". You should use: "gs"

It would be nice if it only showed the longest matching alias, rather than all of them.

Support whitelist for ignoring certain commands

My use case for this is that I have ls aliased to fix a common typo, but I don't want to be reminded of that every time I run it.

$ ls
Found existing alias for "ls". You should use: "sl"

Some shorter aliases are not detected

Issue Details

Please provide the following details when opening an issue:

Operating System (uname -a)

Darwin MacBook-Pro 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

zsh version (zsh --version)

zsh 5.7.1 (x86_64-apple-darwin18.2.0)

you-should-use version (echo "$YSU_VERSION")

1.3.0

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

  1. Make sure oh-my-zsh is installed
  2. Run gd --word-diff
  3. See that gdw is not recommended

Based on alias gd='git diff' and alias gdw='git diff --word-diff', I think that running gd --word-diff should recommend gdw.

"Best Match" should take into account all alias types

image

While here I typed a bad command anyway (my ignorance using autocomplete), I'd expect to only see the first suggestion, I'll never want to type git s because then I should see the gst suggestion, so even display it?

This may not be a feature suited for all, but I'd love it as a config option.

Error : maximum nested function level reached

zsh --version
zsh 5.3.1 (x86_64-apple-darwin15.6.0)

I am using zplug to manage zsh plugins. I used zplug to install this plugin about a week ago and have had success with it. I updated all my installed plugins ( about 9 in total including this one ) and found that I got this error when trying to run any command in the terminal.

local:6: maximum nested function level reached

The number varies and the message appears at the start and end of output in the terminal.

Removed zplug, uninstalling everything and then installed each plugin one by one and narrowed the issue down to this plugin.

I can reproduce the issue by starting from scratch with a fresh install of zplug and this plugin only.

Here is the part of my .zshrc that produces the error :

# Check if zplug is installed
if [[ ! -d ~/.zplug ]]; then
    curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh
fi

source ~/.zplug/init.zsh

# zplug "zplug/zplug"                                # Have zplug manage its self
# zplug "zsh-users/zsh-syntax-highlighting", defer:2 # Use colour to show acutal commands
# zplug "urbainvaes/fzf-marks"                       # Bookmarking with fzf filtering
#
# zplug "b4b4r07/zsh-gomi"                           # Move things to system trash
# zplug "zsh-users/zsh-completions"

zplug "MichaelAquilina/zsh-you-should-use"

# zplug "mafredri/zsh-async", from:github
# zplug "sindresorhus/pure", use:pure.zsh, from:github, as:theme
#
# zplug "pimterry/notes", \
#     as:command, \
#     use:notes
#
# zplug "paulirish/git-open"
# #
# zplug "witt3rd/894c9e0b9ca4e24e5574", \
#     from:gist, \
#     as:command, \
#     use:brew-sync.sh                               # Keep homebrew in sync with dropbox

Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
    printf "Install? [y/N]: "
    if read -q; then
        echo; zplug install
    fi
fi

# Then, source plugins and add commands to $PATH
zplug load --verbose

Happy to clarify anything that I have not made clear, happy to provide any information needed to further debug the issue.

show the original full cmd when use alias

This plugin helps to get full usage of aliases, but after using alias for a long time, it's easy to forget the original actually running cmd, especially some detailed arguments.
I wonder if we could have this feature in this plugin.
ps: set -x show verbose output in zsh.

Request: Option to match only typed command without path

Issue Details

It would be very helpful to have the option to ignore the path typed when searching for existing aliases for the input.

E.g. supposed this alias is configured:

alias gc="git commit"

These inputs should all be mached:

git commit              # works
/usr/bin/git commit # does NOT work
./git commit            # does NOT work

This behaviour could be made optional and will help to make the plugin useful for "hardcoded" binaries that might not be in $PATH.

Apart form binaries that the user might not want to have in $PATH for whatever reason, this would fix the usage on nixOS where it is common practice to have shell configs and scripts generated like alias gc="${pkgs.git}/bin/git commit" (pkgs.git gets expanded to wherever the binary might be in the packge)

Operating System (uname -a)

Linux kartoffel 5.4.70 #1-NixOS SMP Wed Oct 7 06:01:31 UTC 2020 x86_64 GNU/Linux

zsh version (zsh --version)

zsh 5.8 (x86_64-pc-linux-gnu)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)
    Via nixOS configuration.

Steps to reproduce the issue

alias e="/bin/echo"
echo "something"

gist link to your zshrc

https://gist.github.com/pinpox/87e1b4e2d2cbeff2c26c1aa6177294ff

Allow ignoring global aliases

Issue Details

Please provide the following details when opening an issue:

Operating System (uname -a)

Linux nawordar-H81M-S1 5.3.0-26-generic #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

zsh version (zsh --version)

zsh 5.7.1 (x86_64-ubuntu-linux-gnu)

you-should-use version (echo "$YSU_VERSION")

1.6.0

How is zsh-you-should-use installed?

Just FYI I am using both oh-my-zsh and zplug, but I installed zsh-you-should-use with zplug.

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

  1. Add a global alias to the YSU_IGNORED_ALIASES
  2. you-should-use still notifies about not using the alias

gist link to your zshrc

https://github.com/nawordar/dotfiles/blob/a62356198c9998adbf0f6e2bc0c367df893a3f51/dot_zshrc

I don't use ... alias because it doesn't play well with auto-completion. Because of that, I wanted to disable it through the YSU_IGNORED_ALIASES variable in .zshrc like this:

export YSU_IGNORED_ALIASES=("...")

Unfortunately, while it works for normal aliases, it doesn't work for the global ones, so it still notifies me about this alias.

> YSU_IGNORED_ALIASES=('...')
> ls ../..                   
Found existing global alias for "../..". You should use: "..."

Partial alias use prevents discovery of a better alias

Issue Details

Please provide the following details when opening an issue:

Operating System (uname -a)

Darwin <redacted> 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

zsh version (zsh --version)

zsh 5.9 (x86_64-apple-darwin21.3.0)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

  1. Define two alias:
  • alias g='git'
  • alias gl='git pull'
  1. Try these three examples:
  • $ gl => no YSU output (expected)
  • $ g pull => no YSU output (I expected YSU to suggest gl)
  • $ git pull => YSU suggests gl

gist link to your zshrc

https://gist.github.com/MTCoster/896bb0b57a9d39baab4d83dbca431a7d

Common aliases

Can I add the plugin common-aliases so YSU checks those aliases too? How would I do that? Thanks for creating this very helpful plugin. I think it will transform my workflow.

Partial use of an alias precludes the detection of a better alias

Issue Details

โฏ git remote -v
...

found alias for git remote: gr
found alias for git remote -v: grv
~/Base/_Code/Python/betterborg master*
โฏ g remote -v
...
# No detection

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Antibody

zshrc

antibody bundle "MichaelAquilina/zsh-you-should-use"
export YSU_MESSAGE_POSITION="after"
export YSU_MESSAGE_FORMAT="$(tput setaf 1)found %alias_type for %command: %alias$(tput sgr0)"
export YSU_MODE=ALL #BESTMATCH or ALL
export YSU_IGNORED_ALIASES=("g" "ll")

Update README

Some functionality is missing on the README

  • enable/disable functions

per-directory-history breaks you-should-use

I'm using oh-my-zsh on Ubuntu 16.04. Whenever I enable the bundled per-directory-history plugin, you-should-use breaks. There is no output from it at all. Let me know if you need additional info.

Escape sequences and printf placeholders get expanded in "Found..." message

Issue Details

Operating System (uname -a)

Linux soba 5.4.39-1-MANJARO #1 SMP PREEMPT Wed May 6 10:36:44 UTC 2020 x86_64 GNU/Linux

zsh version (zsh --version)

zsh 5.8 (x86_64-pc-linux-gnu)

you-should-use version (echo "$YSU_VERSION")

1.7.0

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (zinit)

Steps to reproduce the issue

  1. Add alias.
alias pf="printf '%s\n'"
  1. Run printf '%s\n' 1 2 3.

  2. Get unexpected output.

$ printf '%s\n' 1 2 3
Found existing alias for "printf '
'". You should use: "pf"
1
2
3

Minimal reproducible example .zshrc

source "$HOME/.zinit/bin/zinit.zsh"
zinit wait lucid for MichaelAquilina/zsh-you-should-use
alias pf="printf '%s\n'"

Allow temporary disabling

Feature request

I'd like to be able to temporarily disable this plugin (eg when generating text to copy / paste when lodging bug reports).

If using:

export YSU_MESSAGE_FORMAT=''

I simply get the default message format.

Could you support something like:

export YSU_DISABLE=1  # any non-null value perhaps

Consider support function aliases

Issue Details

Right now, you-should-use only recognizes aliases if command given well: alias gs='git status. But this not works for function aliases. It should better if it recognize this type of aliases: alias my_alias='my_custom_function [COMMANDS] [FLAGS] [OPTIONS]

Operating System (uname -a)

Darwin XXX 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64

zsh version (zsh --version)

zsh 5.8 (x86_64-apple-darwin20.1.0)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

  1. Create a function.zsh file
  2. Create an alias function:
_my_git() {
  # my some other special stuffs here
  git "$@"
}
  1. Define an alias to that function in your aliases.zsh file:
alias gs='_my_git status --short --branch --show-stash'
  1. Source the .zsh files in your .zshrc file
  2. $ git status

Actual:

Found existing alias for "git status". You should use: "gst"
Found existing git alias for "status". You should use: "git st"

Expected:

Found existing alias for "git status". You should use: "gs"
Found existing alias for "git status". You should use: "gst"
Found existing git alias for "status". You should use: "git st"

You Should Use reminder fires even when I use the correct alias

Issue Details

Please provide the following details when opening an issue:

Operating System (uname -a)

Windows WSL
Linux Goffe 4.4.0-17763-Microsoft #379-Microsoft Wed Mar 06 19:16:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

zsh version

zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

you-should-use version (echo "$YSU_VERSION")

1.5.0

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify): added as a git submodule to my dotfiles and the directly sourced by my .zshrc

Steps to reproduce the issue

โ”Œโ”€ ๏Œ› ๎‚ผ ๏€• ~ ๎‚ผ                                                                                                                             ๎‚บ ๏€Œ 
โ””โ”€โžค .. 
Found existing alias for "cd ..". You should use: ".." 
aslan 

โ”Œโ”€ ๏Œ› ๎‚ผ ๏€ฃ | ๏ป /home ๎‚ผ                                                                                                                     ๎‚บ ๏€Œ 
โ””โ”€โžค .. 
Found existing alias for "cd ..". You should use: ".." 
bin  boot  dev  etc  home  init  lib  lib64  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var 

โ”Œโ”€ ๏Œ› ๎‚ผ ๏€ฃ | ๏ป / ๎‚ผ                                                                                                                         ๎‚บ ๏€Œ 
โ””โ”€โžค 

gist link to your zshrc

https://github.com/jcklpe/configs/blob/master/zsh/.zshrc

Getting prompted when using an alias

Operating System (uname -a)

Darwin Adityas-MacBook-Pro.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64

zsh version (zsh --version)

zsh 5.7.1 (x86_64-apple-darwin19.0.0)

you-should-use version (echo "$YSU_VERSION")

1.5.0

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

Use any shorthand alias:

ls
Found existing alias for "ls -G". You should use: "ls"
back
Found existing alias for "cd ..". You should use: "back"
vsc
Found existing alias for "code .". You should use: "vsc"

gist link to your zshrc

https://github.com/epk/dotify/blob/master/.zshrc

RFE: Make project's name less error prone "zsh-"

Issue Details

Different names you-should-use vs. zsh-you-should-use can cause issues in other projects. It is error prone.

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

I guess a oh-my-zsh wrongly added zsh-you-should-use in the list of plugin. Anyway the issue is that other projects were confused with the prefix zsh- ...

It is more of an RFE, to make it more straightforward for others to install zsh's you-should-use or zsh-you-should-use, should you use zsh ...

[RESOLVED] Hardcore mode won't block execution

Issue Details

Out of thin air, Hardcore mode died on me. I don't believe any specific changes were made in my zshrc that should have broken it.

I have done anything I could think of, including validating my .zshrc, re-installing YSU, etc.

image

This example shows that when in using echo instead of my e alias, YSU does mention that it knows I'm using hardcore mode, but it won't actually block execution.

Please provide the following details when opening an issue:

Operating System

Darwin N-Mac.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

zsh version

zsh 5.7.1 (x86_64-apple-darwin18.2.0)

you-should-use version:

1.6.0

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • Other (please specify)

Steps to reproduce the issue

Type in any long-form of an alias in Hardcore mode.

gist link to your zshrc

Lines directly related to YSU are line numbers 76, 77, 103.

https://gist.github.com/selfish/2140c335c5e7bd1168a077a47afafa8d


JUMP TO SOLUTION


Your help is very very appreciated!!

Using hardcore mode will break cp ../../ with ohmyzsh directory aliases

Summary

This bug is encountered because of an alias built-in to oh-my-zsh. Using cp ... does not work.

How to reproduce

Test directory:

.
โ”œโ”€โ”€ file
โ””โ”€โ”€ start
    โ””โ”€โ”€ level
        โ””โ”€โ”€ level

Configuration:

YSU_MODE=ALL
YSU_HARDCORE=1

Commands to execute

$ cd start/level/level
$ cp ../../../file.txt .
Found existing global alias for "../..". You should use: "..."
Found existing global alias for "../../..". You should use: "...."
You Should Use hardcore mode enabled. Use your aliases!
$  cp ..../file.txt .
cp: cannot stat '..../file.txt': No such file or directory
cp .../../file.txt .
Found existing global alias for "../..". You should use: "..."
You Should Use hardcore mode enabled. Use your aliases!

The aliases for "..." is defined here: https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/directories.zsh

No License

What license is this code under? It would be good to add a LICENSE file to this repository to clarify what this code is released under.

gpsup doesn't trigger you-should-use

I have the following alias setup:

gpsup='git push --set-upstream origin $(git_current_branch)'

I've enabled hardcore mode, but you-should-use doesn't get in the way of this command:

gp --set-upstream origin my-branch-name

check_alias_usage results in a malloc error failing to load counting data

Issue Details

possible bug
check_alias_usage results in a malloc error.
Aliases seem to be listed, however, the counting data is always 0.

Operating System (uname -a)

macOS Catalina 10.15.6 (19G73)

Darwin Andrews-MBP.local 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64

zsh version (zsh --version)

zsh 5.7.1 (x86_64-apple-darwin19.0)

you-should-use version (echo "$YSU_VERSION")

1.7.3

How is zsh-you-should-use installed?

  • zplug
  • oh-my-zsh
  • Antigen
  • [ X] Other (please specify)

Antibody

Steps to reproduce the issue

โฏ ~
โฏ check_alias_usage

tail(23339,0x110ca1dc0) malloc: can't allocate region
:*** mach_vm_map(size=144000000000000000, flags: 100) failed (error code=3)
tail(23339,0x110ca1dc0) malloc: *** set a breakpoint in malloc_error_break to debug
tail: malloc: Cannot allocate memory
0: ~='cd ~'
0: z='_z 2>&1'
0: which-command='whence'
0: sc='source /Users/andrew/.zshrc'
0: run-help='man

Expected

  • no errors
  • increment the count on the alias ~

Should recommend shorter aliases

Example

alias gco='git checkout'
alias gcom='git checkout master'

if I run gco master it should detect that gcom is a shorter alias and recommend that

Convert for use with Fish?

Hello, do you think its possible to convert this for use with Fish? I realize that this isn't really an issue but since git does not have a messaging feature I can't think of another way to ask what you think. It's an awesome concept which I'd totally use all the time except my shell of choice is Fish. Zsh is a little too overly complicated and feature-rich for my taste.

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.