20 releases (5 breaking)

✓ Uses Rust 2018 edition

new 0.6.0 Jul 17, 2019
0.5.0 Jul 10, 2019
0.4.1 Jun 23, 2019
0.3.0 Jun 21, 2019
0.1.1 Oct 18, 2018

#44 in Command line utilities

Download history 2/week @ 2019-04-03 2/week @ 2019-04-10 4/week @ 2019-04-24 1/week @ 2019-05-01 2/week @ 2019-05-08 5/week @ 2019-05-15 8/week @ 2019-05-22 12/week @ 2019-05-29 2/week @ 2019-06-05 119/week @ 2019-06-12 166/week @ 2019-06-19 46/week @ 2019-06-26 70/week @ 2019-07-03 55/week @ 2019-07-10

164 downloads per month

Custom license

2MB
438 lines

slick

async ZSH prompt

example

How to use

Install:

cargo install slick

check your PATH $HOME/.cargo/bin/slick, to install cargo: curl https://sh.rustup.rs -sSf | sh

Then add this to your .zshrc:

zle -N zle-keymap-select
zle -N zle-line-init
zmodload zsh/datetime
autoload -Uz add-zsh-hook
add-zsh-hook precmd slick_prompt_precmd
add-zsh-hook preexec slick_prompt_preexec

typeset -g slick_prompt_data
typeset -g slick_prompt_timestamp

SLICK_PATH=$HOME/.cargo/bin/slick

function slick_prompt_refresh {
    local exit_status=$?
    read -r -u $1 slick_prompt_data
    PROMPT=$($SLICK_PATH prompt -k "$KEYMAP" -r $exit_status -d ${slick_prompt_data:-""} -t ${slick_prompt_timestamp:-$EPOCHSECONDS})
    unset slick_prompt_timestamp

    zle reset-prompt

    # Remove the handler and close the fd
    zle -F $1
    exec {1}<&-
}

function zle-line-init zle-keymap-select {
    PROMPT=$($SLICK_PATH prompt -k "$KEYMAP" -d ${slick_prompt_data:-""})
    zle && zle reset-prompt
}

function slick_prompt_precmd() {
    slick_prompt_data=""
    local fd
    exec {fd}< <($SLICK_PATH precmd)
    zle -F $fd slick_prompt_refresh
}

function slick_prompt_preexec() {
    slick_prompt_timestamp=$EPOCHSECONDS
}

customizations

Set this environment variables to change color/symbols, for example:

export SLICK_PROMPT_CMD_MAX_EXEC_TIME=3
export SLICK_PROMPT_ERROR_COLOR=88
export SLICK_PROMPT_GIT_ACTION_COLOR=1
export SLICK_PROMPT_GIT_BRANCH_COLOR=202
export SLICK_PROMPT_GIT_FETCH=0
export SLICK_PROMPT_GIT_MASTER_BRANCH_COLOR=white
export SLICK_PROMPT_GIT_REMOTE_COLOR=40
export SLICK_PROMPT_GIT_STAGED_COLOR=1
export SLICK_PROMPT_GIT_STATUS_COLOR=cyan
export SLICK_PROMPT_PATH_COLOR=blue
export SLICK_PROMPT_ROOT_COLOR="red"
export SLICK_PROMPT_ROOT_SYMBOL="#"
export SLICK_PROMPT_SSH_COLOR=2
export SLICK_PROMPT_SYMBOL=""
export SLICK_PROMPT_SYMBOL_COLOR=magenta
export SLICK_PROMPT_TIME_ELAPSED_COLOR=1
export SLICK_PROMPT_VICMD_COLOR="yellow"
export SLICK_PROMPT_VICMD_SYMBOL=""

SLICK_PROMPT_GIT_FETCH=0 prevents doing a git fetch


Inspired by:

Dependencies

~11MB
~253K SLoC