add: vimrc hybrid line numbers

fix: zsh cursor
move: vimrc, viminfo, zsh_history
This commit is contained in:
Tobias Reisinger 2019-12-20 14:06:42 +01:00
parent 10fb0073e5
commit 5a76ba59fe
4 changed files with 30 additions and 43 deletions

24
.config/vimrc Normal file
View file

@ -0,0 +1,24 @@
set number relativenumber
augroup numbertoggle
autocmd!
autocmd WinEnter * set relativenumber
autocmd WinLeave * set norelativenumber
augroup END
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set encoding=utf-8
set nowrap
set viminfo+=n~/.cache/viminfo
" Save cursor position. I don't understand this part :)
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif

View file

@ -5,7 +5,7 @@ PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magent
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
HISTFILE=~/.cache/zsh_history
# Basic auto/tab complete:
autoload -U compinit
@ -25,38 +25,13 @@ bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
echo -ne "\e[1 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Use lf to switch directories and bind it to ctrl-o
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
bindkey -s '^o' 'lfcd\n'
echo -ne '\e[1 q' # Use beam shape cursor on startup.
# preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line

View file

@ -1,3 +1,5 @@
export VIMINIT='source ~/.config/vimrc'
# set PATH so it includes user's private bin if it exists
[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH"

14
.vimrc
View file

@ -1,14 +0,0 @@
set number
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set encoding=utf-8
set nowrap
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif