provide-module sane-scroll %~ define-command -docstring %{ sane-scroll [] : Scroll cursor up/down. Supports . Switches: -center Center screen after cursor move. -win Scroll by half-window height. } -params 1..3 sane-scroll %{ execute-keys %sh{ while [ "$#" -gt 0 ]; do case "$1" in -center) center=true shift ;; -win) win=true shift ;; -*) echo ":fail Unknown switch $1" exit 1 ;; *) break ;; esac done if [ "$win" = true ]; then count=$((kak_window_height / 2)) else count="$kak_count" fi case $1 in up) dir="k" ;; down) dir="j" ;; *) echo ":fail Invalid scroll direction" ;; esac echo "${count}${dir}" if [ "$center" = true ]; then echo "vv" else echo "${count}v${dir}" fi } } ~