From acde04b61f4791159cac10ddbeecf5f7827007be Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 9 Dec 2015 01:12:30 -0500 Subject: [PATCH] Fix completion for alias functions --- zsh/aliases.zsh | 7 +++++-- zsh/completion.zsh | 1 + zshrc | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 714c1ae7..e2697128 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -15,9 +15,10 @@ alias ln="ln -v" # Verbose ln alias wget='wget -c' # Resume dl if possible alias rsyncd='rsync -va --delete' # Hard sync two directories alias mkdir='mkdir -p' -mkd() { mkdir "$1" && cd "$1"; } -zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; } alias gurl='curl --compressed' +zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; } +take() { mkdir "$1" && cd "$1"; } +compdef take=mkdir alias ip="dig +short myip.opendns.com @resolver1.opendns.com" alias localip="ipconfig getifaddr en0" @@ -96,6 +97,7 @@ alias exe='exercism' # GIT is-callable 'hub' && alias git='hub' g() { [ $# -eq 0 ] && git status --short || git $* } +compdef _git g=git alias gi='git init' alias gs='git status' @@ -163,3 +165,4 @@ alias p='pbpaste' # By default, open cwd o() { open ${@:-.}; } +compdef o=open diff --git a/zsh/completion.zsh b/zsh/completion.zsh index 9b1da7b9..a043eadc 100644 --- a/zsh/completion.zsh +++ b/zsh/completion.zsh @@ -5,6 +5,7 @@ autoload -Uz compinit && compinit -i ## Options +setopt COMPLETE_ALIASES # Complete from both ends of a word. setopt COMPLETE_IN_WORD # Complete from both ends of a word. setopt ALWAYS_TO_END # Move cursor to the end of a completed word. setopt PATH_DIRS # Perform path search even on command names with slashes. diff --git a/zshrc b/zshrc index 11b30919..c62885fd 100644 --- a/zshrc +++ b/zshrc @@ -5,7 +5,6 @@ DOTFILES=$HOME/.dotfiles source $DOTFILES/zsh/functions.zsh -source $DOTFILES/zsh/aliases.zsh # if not running through emacs' shell-command if [ ! $TERM = dumb ]; then @@ -36,6 +35,8 @@ if [ ! $TERM = dumb ]; then cache fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install fi +source $DOTFILES/zsh/aliases.zsh + cache rbenv init - --no-rehash cache pyenv init - --no-rehash