ohmyzsh / ohmyzsh

🙃 A delightful community-driven (with 2,400+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool that makes it easy to keep up with the latest updates from the community.
https://ohmyz.sh
MIT License
173.07k stars 25.87k forks source link

Why add the line alias, failure #5595

Closed wpecker closed 7 years ago

wpecker commented 7 years ago

Why add the following line alias: Alias -g rm = 'rm -i' It will affect the docker, because when running docker rm, on-my-zsh will resolve into docker rm -i, resulting in the implementation of failure.

$ docker rm 5afb994baf78
unknown shorthand flag: 'i' in -i
See 'docker rm --help'.
mcornella commented 7 years ago

I can't find that anywhere in the code. You must have an external dependency that does that.

wpecker commented 7 years ago

Do it dependency on zsh, non-oh-my-zsh?

mcornella commented 7 years ago

You must have some non-standard commands in your zshrc file. Please post it so that I can advise you on a solution.

wpecker commented 7 years ago

My zshrc as following:

export UPDATE_ZSH_DAYS=30

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

export ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# export ZSH_THEME="xiong-chiamiov-plus"
export ZSH_THEME="anwar"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git autojump sudo last-working-dir docker docker-compose encode64 urltools  extract)

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

#***********************************
export GOROOT="/mnt/shared/go"
export GOARCH="amd64"
export GOOS="linux"
export GOBIN="$GOROOT/bin"
export GOTOOLS=$GOROOT/pkg/tool/linux_amd64

export GOPATH="/mnt/shared/go-T"
export GOPKGBIN="$GOPATH/bin"
export PATH=$GOBIN:$GOPKGBIN:$GOTOOLS:$PATH
#***********************************

setopt INC_APPEND_HISTORY SHARE_HISTORY
setopt APPEND_HISTORY   # If this is set, zsh sessions will append their history list to the history file, rather than overwrite it.
unsetopt BG_NICE            # Run all background jobs at a lower priority. This option is set by default.
setopt MENUCOMPLETE   # Very good to select option for commands,etc. ls -

# Set/unset  shell options
setopt   autoresume histignoredups pushdsilent 
setopt   autopushd pushdminus extendedglob rcquotes mailwarning
unsetopt bgnice autoparamslash

# Autoload zsh modules when they are referenced
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile

alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias lla='ls -al --color=auto'
alias f=finger
alias -g cp='cp -i'
alias -g mv='mv -i'
alias -g rm='rm -i'
alias -g grep='grep --color=auto'
alias -g tmc='source $ZSH/themes/simple.zsh-theme'
alias -g tmn='tmux new -d -s'
alias -g tml='tmux ls'
alias -g tma='tmux attach -t'
alias -g tmk='tmux kill-session -t'
alias -g rtm='retmux '
alias -g py='bpython'
alias -g uterm='/usr/bin/rxvt-unicode'
alias -g mterm='/usr/local/bin/mlterm'
alias man="pinfo -m"
alias -g gt='gnome-terminal'
alias -g pcz='proxychains'
#alias go=colorgo

sudo-command-line() {
    [[ -z $BUFFER ]] && zle up-history
    [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
    zle end-of-line           
}
zle -N sudo-command-line

bindkey "\e\e" sudo-command-line
#}}}

setopt HIST_IGNORE_DUPS

zstyle ':completion:*:ping:*' hosts 192.168.128.1{38,} www.g.cn \
       192.168.{1,0}.1{{7..9},}

my_accounts=(
{r00t,root}@{192.168.1.1,192.168.0.1}
kardinal@linuxtoy.org
123@211.148.131.7
)
zstyle ':completion:*:my-accounts' users-hosts $my_accounts
#}}}

eval "`dircolors ~/.dircolors`"
ulimit -c unlimited

export LC_ALL=en_US.UTF-8  
export LANG=en_US.UTF-8
wpecker commented 7 years ago

For example, I look forward to prompt before every removal, So I add alias -g rm='rm -i', but this s alias conflicts with the docker rm, On My input docker rm, on-my-zsh is interpreted as docker rm -i; The resulting in the docker rm command can not be used, but I do not want to give up this alias.

mcornella commented 7 years ago

You have these aliases defined in your zshrc file:

alias -g cp='cp -i'
alias -g mv='mv -i'
alias -g rm='rm -i'

My guess is that you mistakenly added the -g part which makes it global. Delete the -g part and you'll be fine.

wpecker commented 7 years ago

Nice, very good, It is ok for your method. @mcornella Thanks you very much.