Skip to content

Instantly share code, notes, and snippets.

@dvirsky dvirsky/redis-bashcomplete
Last active Jul 20, 2017

Embed
What would you like to do?
Bash completion for redis server and cli
# bash completion for redis-cli and redis-server
have redis-server &&
_redisserver()
{
local cur prev split=false
COMPREPLY=()
_get_comp_words_by_ref cur prev
_split_longopt && split=true
$split && return 0
COMPREPLY=( $( compgen -W "--activerehashing --always-show-logo --aof-load-truncated --aof-rewrite-incremental-fsync\
--aof-use-rdb-preamble --appendfilename --appendfsync --appendonly --auto-aof-rewrite-min-size\
--auto-aof-rewrite-percentage --bind --client-output-buffer-limit --daemonize --databases\
--dbfilename --dir --hash-max-ziplist-entries --hash-max-ziplist-value --hll-sparse-max-bytes\
--hz --latency-monitor-threshold --lazyfree-lazy-eviction --lazyfree-lazy-expire\
--lazyfree-lazy-server-del --list-compress-depth --list-max-ziplist-size --logfile\
--loglevel --lua-time-limit --no-appendfsync-on-rewrite --notify-keyspace-events\
--pidfile --port --protected-mode --rdbchecksum --rdbcompression --repl-disable-tcp-nodelay\
--repl-diskless-sync --repl-diskless-sync-delay --save --set-max-intset-entries\
--slave-lazy-flush --slave-priority --slave-read-only --slave-serve-stale-data\
--slowlog-log-slower-than --slowlog-max-len --stop-writes-on-bgsave-error\
--supervised --tcp-backlog --tcp-keepalive --timeout --zset-max-ziplist-entries\
--zset-max-ziplist-value" -- "$cur" ) )
} &&
complete -F _redisserver redis-server
have redis-cli &&
_rediscli()
{
local cur prev split=false
COMPREPLY=()
_get_comp_words_by_ref cur prev
_split_longopt && split=true
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-s)
_filedir sock
return 0
;;
esac
$split && return 0
COMPREPLY=( $( compgen -W "$( redis-cli --help 2>&1 | tr '\t' ' ' | sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | sort -u )" -- "$cur" ) )
} &&
complete -F _rediscli redis-cli
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.