Skip to content

Instantly share code, notes, and snippets.

@ericbn
ericbn / .vimrc
Last active March 31, 2024 10:39
Vim Powerline-like status line without the need of any plugin
" Statusline (requires Powerline font)
set statusline=
set statusline+=%(%{&buflisted?bufnr('%'):''}\ \ %)
set statusline+=%< " Truncate line here
set statusline+=%f\ " File path, as typed or relative to current directory
set statusline+=%{&modified?'+\ ':''}
set statusline+=%{&readonly?'\ ':''}
set statusline+=%= " Separation point between left and right aligned items
set statusline+=\ %{&filetype!=#''?&filetype:'none'}
set statusline+=%(\ %{(&bomb\|\|&fileencoding!~#'^$\\\|utf-8'?'\ '.&fileencoding.(&bomb?'-bom':''):'')
getseq () {
trap "stty ${$(stty -g 2>/dev/null):-echo -raw}" 0 1 2 15
stty raw -echo
local k='' seq='' i
for ((i=10; i>0; --i)); do
read -t -k 1 k && break
sleep 1
done
[[ -n $k ]] || return 1
[[ $k = $'\012' || $k = $'\015' || $k = ' ' ]] && return 0
# xterm on Android termux
TERM=xterm-256color
Wait for prompt before pressing each key.
Press SPACE to skip to the next key.
Don't press any key within 10 seconds to abort.
Ready [y/N]? y
) Started application mode
) F1: ^[OP
) F2: ^[OQ
) F3: ^[OR