Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating zshrc to using antigen #90

Closed
orschiro opened this issue Sep 23, 2014 · 2 comments
Closed

Migrating zshrc to using antigen #90

orschiro opened this issue Sep 23, 2014 · 2 comments

Comments

@orschiro
Copy link

Hi there,

By Shrikant Sharat I was advised to open an issue for my question. I discovered antigen and want to move my zshrc completely to using antigen.

I followed several introductions and now my zshrc looks as follows:

~ cat .zshrc
# Configuration largely inspired by
# http://danryan.co/using-antigen-for-zsh.html
[ -e "${HOME}/.zsh_aliases" ] && source "${HOME}/.zsh_aliases"
export PATH=$HOME/bin:/usr/local/bin:$PATH

source /usr/share/zsh/scripts/antigen/antigen.zsh 

antigen use oh-my-zsh

# bundles from oh-my-zsh
antigen bundle git
antigen bundle rupa/z
antigen bundle zsh-users/zsh-syntax-highlighting

antigen-theme zhann
antigen-apply

# keybindings
# https://wiki.archlinux.org/index.php/Zsh#Key_bindings
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key

key[Home]=${terminfo[khome]}

key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"     ]]  && bindkey  "${key[Home]}"     beginning-of-line
[[ -n "${key[End]}"      ]]  && bindkey  "${key[End]}"      end-of-line
[[ -n "${key[Insert]}"   ]]  && bindkey  "${key[Insert]}"   overwrite-mode
[[ -n "${key[Delete]}"   ]]  && bindkey  "${key[Delete]}"   delete-char
[[ -n "${key[Up]}"       ]]  && bindkey  "${key[Up]}"       up-line-or-history
[[ -n "${key[Down]}"     ]]  && bindkey  "${key[Down]}"     down-line-or-history
[[ -n "${key[Left]}"     ]]  && bindkey  "${key[Left]}"     backward-char
[[ -n "${key[Right]}"    ]]  && bindkey  "${key[Right]}"    forward-char
[[ -n "${key[PageUp]}"   ]]  && bindkey  "${key[PageUp]}"   beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]]  && bindkey  "${key[PageDown]}" end-of-buffer-or-history

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
    function zle-line-init () {
        printf '%s' "${terminfo[smkx]}"
    }
    function zle-line-finish () {
        printf '%s' "${terminfo[rmkx]}"
    }
    zle -N zle-line-init
    zle -N zle-line-finish
fi

# Zsh rehash automatically
# Tab completion after installation/removal
# http://www.ephexeve.com/2012/10/zsh-rehash-automatically.html
# TRAPUSR1() { rehash}; precmd() { [[ $history[$[ HISTCMD -1 ]] == *(pacman|yaourt)* ]] && killall -USR1 zsh }
# https://bbs.archlinux.org/viewtopic.php?pid=1369287#p1369287
zstyle ':completion:*' rehash true

# Zsh: Smart autocompletion feature?
# http://stackoverflow.com/questions/23404412/zsh-smart-autocompletion-feature
zstyle ':completion:*' matcher-list 'l:|=* r:|=*'

# Search history up and down arrows
# http://superuser.com/questions/585003/searching-through-history-with-up-and-down-arrow-in-zsh
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search

As you can see, the whole bunch of code lines starting with the keybindings is bloating up my zshrc.

Thus, I am wondering, can this be simplified when using antigen?

Are there any plugins available that provide the same functionality to polish my zshrc?

Thanks a lot for your advice!

@sharat87
Copy link
Member

Antigen itself doesn't provide any shortcuts specific to help with keybinding, but perhaps there's an extension that helps with this? Sorry, I'm not aware of one.

@orschiro
Copy link
Author

@sharat87

Thank you for your response. To summarise, my current zshrc cannot be further simplified.

That's good to know as I had the feeling that I have overcomplicated my source file.

@sharat87 sharat87 closed this as completed Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants