parent
a282cf4d63
commit
8789a2a83e
33 changed files with 37 additions and 24 deletions
2
cli/.config/bat/config
Normal file
2
cli/.config/bat/config
Normal file
|
@ -0,0 +1,2 @@
|
|||
--theme=gruvbox-dark
|
||||
--italic-text=always
|
49
cli/.config/fish/config.fish
Normal file
49
cli/.config/fish/config.fish
Normal file
|
@ -0,0 +1,49 @@
|
|||
if status is-interactive
|
||||
set prompt_sep_a \ue0b0
|
||||
set prompt_bang \n\U1f41f\
|
||||
set git_sign \ue0a0
|
||||
set color_fg brwhite
|
||||
set color_git_branch 3c3c3c
|
||||
set color_git yellow blue red purple
|
||||
function prompt.add
|
||||
set color $argv[1]
|
||||
set text $argv[2]
|
||||
if test -z "$prompt_string"
|
||||
set prompt_string (set_color -b $color)(set_color $color_fg) $text
|
||||
else
|
||||
set -a prompt_string (set_color -b $color)(set_color $prev_color)$prompt_sep_a(set_color $color_fg) $text
|
||||
end
|
||||
set prev_color $color
|
||||
end
|
||||
function prompt.git
|
||||
git rev-parse 2>/dev/null || return
|
||||
git status --porcelain -bu | while read line
|
||||
if string match -qr "^##" "$line"
|
||||
set git_branch (string match -r "\ (.+)\.\.\." "$line")[2]
|
||||
string match -qr "\[behind" $line && set git_branch "$git_branch?"
|
||||
string match -qr "\[ahead" $line && set git_branch "$git_branch!"
|
||||
prompt.add "$color_git_branch" "$git_sign $git_branch"
|
||||
else
|
||||
string match -qr "^.[MD]" "$line" && set git_count[1] (math $git_count[1] + 1)
|
||||
string match -qr "^[MDARC]." "$line" && set git_count[2] (math $git_count[2] + 1)
|
||||
string match -qr "^\?\?" "$line" && set git_count[3] (math $git_count[3] + 1)
|
||||
string match -qr "^[ADU]{2}" "$line" && set git_count[4] (math $git_count[4] + 1)
|
||||
end
|
||||
end
|
||||
test -n "$git_count[1]" && prompt.add "$color_git[1]" "~$git_count[1]"
|
||||
test -n "$git_count[2]" && prompt.add "$color_git[2]" "+$git_count[2]"
|
||||
test -n "$git_count[3]" && prompt.add "$color_git[3]" "!$git_count[3]"
|
||||
test -n "$git_count[4]" && prompt.add "$color_git[4]" "*$git_count[4]"
|
||||
end
|
||||
function fish_prompt
|
||||
set -g prompt_string
|
||||
set -g prev_color
|
||||
prompt.add blue (pwd)
|
||||
prompt.git
|
||||
prompt.add normal $prompt_bang
|
||||
|
||||
echo $prompt_string
|
||||
set -e prompt_string
|
||||
end
|
||||
# Commands to run in interactive sessions can go here
|
||||
end
|
3
cli/.config/nvim/init.lua
Normal file
3
cli/.config/nvim/init.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require('settings')
|
||||
require('maps')
|
||||
require('plugins')
|
31
cli/.config/nvim/lua/maps.lua
Normal file
31
cli/.config/nvim/lua/maps.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
vim.g.mapleader = ' '
|
||||
|
||||
function unmap(key)
|
||||
vim.api.nvim_set_keymap('', key, '', {})
|
||||
end
|
||||
function map(mode, key, action)
|
||||
vim.api.nvim_set_keymap(mode, key, action, {noremap = true})
|
||||
end
|
||||
|
||||
-- some unmaps
|
||||
unmap(' ')
|
||||
unmap('q')
|
||||
unmap('<F1>')
|
||||
|
||||
-- option control
|
||||
map('n', '<Leader>c', ':setlocal cursorline!<CR>')
|
||||
map('n', '<Leader>l', ':setlocal list!<CR>')
|
||||
map('n', '<Leader>w', ':setlocal wrap!<CR>')
|
||||
|
||||
-- search
|
||||
map('n', '<Leader>/', ':noh<CR>')
|
||||
|
||||
-- copy / paste
|
||||
map('n', '<Leader>y', '"+y')
|
||||
map('n', '<Leader>d', '"+d')
|
||||
map('n', '<Leader>p', '"+p')
|
||||
map('n', '<Leader>P', '"+P')
|
||||
|
||||
-- keymap switch
|
||||
map('!', '<C-Space>', '<C-^>')
|
||||
map('!', '<C-@>', '<C-^>')
|
23
cli/.config/nvim/lua/packer_init.lua
Normal file
23
cli/.config/nvim/lua/packer_init.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
local packer_init = {}
|
||||
|
||||
packer_init.init = function(plugins)
|
||||
local ensure_packer = function()
|
||||
local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||
vim.fn.system {'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local packer_bootstrap = ensure_packer()
|
||||
require('packer').startup(plugins)
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return packer_init
|
43
cli/.config/nvim/lua/plugins.lua
Normal file
43
cli/.config/nvim/lua/plugins.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
-- [[ plugins list ]]
|
||||
local function plugins(use)
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
use 'lifepillar/vim-gruvbox8'
|
||||
use 'hoob3rt/lualine.nvim'
|
||||
use 'hashivim/vim-terraform'
|
||||
use 'mhinz/vim-signify'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rsi'
|
||||
use 'tpope/vim-vinegar'
|
||||
use 'nvim-lua/plenary.nvim'
|
||||
use 'nvim-telescope/telescope.nvim'
|
||||
use {
|
||||
'w0rp/ale',
|
||||
ft = { 'sh', 'zsh', 'lua', 'python' },
|
||||
cmd = 'ALEEnable'
|
||||
}
|
||||
end
|
||||
|
||||
--[[ init plugins and install packer if missing ]]
|
||||
if require('packer_init').init(plugins) then return end
|
||||
|
||||
--[[ plugins config ]]
|
||||
require('lualine').setup{
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
component_separators = { left = '\u{2022}', right = '\u{2022}' }
|
||||
}
|
||||
}
|
||||
|
||||
--[[ telescope maps ]]
|
||||
map('n', '<Leader>.', '<cmd>Telescope find_files<CR>')
|
||||
map('n', '<Leader>,', '<cmd>Telescope buffers<CR>')
|
||||
|
||||
--[[ theme ]]
|
||||
vim.o.bg = 'dark'
|
||||
vim.o.termguicolors = true
|
||||
|
||||
vim.g.gruvbox_plugin_hi_groups = 1
|
||||
vim.g.gruvbox_filetype_hi_groups = 1
|
||||
|
||||
vim.cmd [[colorscheme gruvbox8]]
|
34
cli/.config/nvim/lua/settings.lua
Normal file
34
cli/.config/nvim/lua/settings.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
local fsize = '11'
|
||||
if vim.loop.os_uname().sysname == 'Darwin' then fsize = '14' end
|
||||
|
||||
vim.o.modeline = false
|
||||
vim.o.foldmethod = 'marker'
|
||||
vim.o.cursorline = true
|
||||
vim.o.colorcolumn = '80'
|
||||
vim.o.relativenumber = true
|
||||
vim.o.breakindent = true
|
||||
vim.o.clipboard = 'unnamedplus'
|
||||
|
||||
vim.o.list = true
|
||||
vim.o.listchars = 'tab:==>,nbsp:x,trail:*'
|
||||
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
|
||||
vim.o.scrolloff = 3
|
||||
vim.o.sidescrolloff = 15
|
||||
|
||||
vim.o.tabstop = 3
|
||||
vim.o.softtabstop = 4
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.expandtab = true
|
||||
|
||||
vim.o.keymap = 'russian-jcukenwintype'
|
||||
vim.o.iminsert = 0
|
||||
vim.o.imsearch = 0
|
||||
|
||||
vim.o.title = true
|
||||
vim.o.titlestring = '[%{hostname()}] %t - neovim'
|
||||
vim.o.statusline = '[%F] %R%H%W%M %=[%{&fenc}/%{&ff}] %y [%4l/%L:%3v]'
|
||||
|
||||
vim.o.guifont = 'vcascadia:h' .. fsize
|
102
cli/.config/zsh/functions.zsh
Normal file
102
cli/.config/zsh/functions.zsh
Normal file
|
@ -0,0 +1,102 @@
|
|||
# Fuck default aliases
|
||||
unalias -a
|
||||
|
||||
testbin() { whence $@ > /dev/null }
|
||||
|
||||
termcompat() {
|
||||
typeset term=$TERM
|
||||
case $term in
|
||||
(alacritty*) ;&
|
||||
(kitty*) ;&
|
||||
(wezterm) ;&
|
||||
(xterm-*)
|
||||
term=xterm;;
|
||||
(rxvt-unicode*)
|
||||
term=rxvt-unicode;;
|
||||
(tmux*)
|
||||
term=screen.xterm-new;;
|
||||
esac
|
||||
TERM=$term command $@
|
||||
}
|
||||
|
||||
addpath() {
|
||||
typeset newpath=$1
|
||||
if [[ ! $PATH =~ $newpath ]]; then
|
||||
PATH+=:$newpath
|
||||
export PATH
|
||||
fi
|
||||
}
|
||||
|
||||
fsf() {
|
||||
typeset host prompt="SSH Remote > "
|
||||
host=$(cut -d\ -f1 $HOME/.ssh/known_hosts | sort -u | fzf --prompt=$prompt) || return 1
|
||||
|
||||
termcompat ssh $host $@
|
||||
}
|
||||
|
||||
beep() { printf $'\007' }
|
||||
fixterm() { printf $'c' }
|
||||
|
||||
diff() { command diff --color $@ }
|
||||
tailf() { command less +F $@ }
|
||||
grep() { command grep --color=auto }
|
||||
rgrep() { grep --color=auto --exclude-dir=\.git -R $@ }
|
||||
fwcmd() { command firewall-cmd $@ }
|
||||
sush() { command sudo -Es }
|
||||
s() { termcompat ssh $@ }
|
||||
|
||||
if testbin nvim; then
|
||||
vi() { command nvim $@ }
|
||||
vim() { command nvim $@ }
|
||||
fi
|
||||
|
||||
tmux() { command tmux -2 $@ }
|
||||
atmux() { tmux attach || tmux }
|
||||
|
||||
g() { command lazygit $@ }
|
||||
tig() { termcompat tig $@ }
|
||||
gsi() { tig status }
|
||||
gci() { command git commit $@ }
|
||||
gsl() { command git stash list $@ }
|
||||
gss() { command git status -sbu $@ }
|
||||
gsw() { command git switch $@ }
|
||||
gup() { command git pull $@ }
|
||||
gwt() { command git worktree $@ }
|
||||
groot() { cd $(command git rev-parse --show-toplevel) || return 1 }
|
||||
ggrep() { command git grep $@ }
|
||||
gdiff() { command git diff --color $@; }
|
||||
greset() {
|
||||
echo "OK to reset and clean teh repo?"
|
||||
read -sq _
|
||||
(( $? )) && return 1
|
||||
/usr/bin/git clean -fd
|
||||
/usr/bin/git reset --hard
|
||||
}
|
||||
|
||||
if testbin diff-so-fancy; then
|
||||
gdf() { gdiff $@ | command diff-so-fancy | command less --tabs=4 -RSFX }
|
||||
else
|
||||
gdf() { gdiff $@ }
|
||||
fi
|
||||
|
||||
if testbin exa; then
|
||||
ls() { command exa --group-directories-first $@ }
|
||||
ll() { ls -alg $@ }
|
||||
ld() { ls -dlg $@ }
|
||||
else
|
||||
ls() { command ls --color=auto --group-directories-first $@ }
|
||||
ll() { ls -alh $@ }
|
||||
ld() { ls -dlh $@ }
|
||||
fi
|
||||
|
||||
# grc
|
||||
if testbin grc; then
|
||||
cmds=(\
|
||||
cc configure cvs df dig gcc gmake id ip last lsof make mount \
|
||||
mtr netstat ping ping6 ps tcpdump traceroute traceroute6 \
|
||||
)
|
||||
for cmd in $cmds[@]; do
|
||||
alias $cmd="command grc -es --colour=auto $cmd"
|
||||
done
|
||||
unset cmds cmd
|
||||
fi
|
158
cli/.config/zsh/powerline.zsh
Normal file
158
cli/.config/zsh/powerline.zsh
Normal file
|
@ -0,0 +1,158 @@
|
|||
prompt_fmtn='[ %%{\e[2;3m%%}%s%%{\e[0m%%} ] '
|
||||
printf -v PROMPT2 $prompt_fmtn '%_'
|
||||
printf -v PROMPT3 $prompt_fmtn '?#'
|
||||
printf -v PROMPT4 $prompt_fmtn '+%N:%i'
|
||||
|
||||
prompt_wt="$USERNAME@$HOST"
|
||||
prompt_fifo=~/.zsh_gitstatus_$$
|
||||
prompt_blimit=12
|
||||
typeset -A prompt_symbols=(
|
||||
sep_a $'\ue0b0'
|
||||
ellipsis $'\u2026'
|
||||
git $'\ue0a0'
|
||||
git_unstaged '~'
|
||||
git_staged $'\u2713'
|
||||
git_untracked '!'
|
||||
git_unmerged '*'
|
||||
bang $'\n %F{202}\u266a%f'
|
||||
)
|
||||
|
||||
typeset -A prompt_colors=(
|
||||
fg '15'
|
||||
root '1'
|
||||
ssh '0'
|
||||
cwd '4'
|
||||
git_branch '237'
|
||||
git_unstaged '3'
|
||||
git_staged '6'
|
||||
git_untracked '1'
|
||||
git_unmerged '5'
|
||||
)
|
||||
|
||||
precmd.is_git_repo() {
|
||||
typeset prompt_git_dir
|
||||
prompt_git_dir=$(git rev-parse --git-dir 2>/dev/null) || return 1
|
||||
[[ ! -e $prompt_git_dir/nozsh ]]
|
||||
}
|
||||
|
||||
precmd.prompt.init() {
|
||||
typeset -g prompt_string= prev_color=
|
||||
}
|
||||
|
||||
precmd.prompt.add() {
|
||||
(( $# < 2 )) && return 1
|
||||
typeset data=$1 color=$2
|
||||
if [[ -z $prompt_string ]]; then
|
||||
prompt_string+="%K{$color}%F{$prompt_colors[fg]} $data "
|
||||
else
|
||||
prompt_string+="%F{$prev_color}%K{$color}$prompt_symbols[sep_a]%F{$prompt_colors[fg]} $data "
|
||||
fi
|
||||
prev_color=$color
|
||||
}
|
||||
|
||||
precmd.prompt.bang() {
|
||||
prompt_string+="%F{$prev_color}%k$prompt_symbols[sep_a]%f$prompt_symbols[bang] "
|
||||
}
|
||||
|
||||
precmd.prompt.apply() {
|
||||
PROMPT=$prompt_string
|
||||
unset prompt_string
|
||||
}
|
||||
|
||||
precmd.prompt.user() {
|
||||
(( UID )) || precmd.prompt.add '#' $prompt_colors[root]
|
||||
}
|
||||
|
||||
precmd.prompt.cwd() {
|
||||
precmd.prompt.add %~ $prompt_colors[cwd]
|
||||
}
|
||||
|
||||
precmd.prompt.ssh() {
|
||||
[[ -n $SSH_CONNECTION ]] || return 0
|
||||
precmd.prompt.add %n@%m $prompt_colors[ssh]
|
||||
}
|
||||
|
||||
precmd.prompt.pre_git() {
|
||||
precmd.prompt.add "$prompt_symbols[git] $prompt_symbols[ellipsis]" $prompt_colors[git_branch]
|
||||
}
|
||||
|
||||
precmd.prompt.git() {
|
||||
typeset raw_status IFS=
|
||||
raw_status=$(git status --porcelain -bu 2>/dev/null) || return 0
|
||||
|
||||
typeset -A count
|
||||
while read line; do
|
||||
case $line[1,2] in
|
||||
('##')
|
||||
typeset branch_status=${line[4,-1]%%...*}
|
||||
((${#branch_status}>prompt_blimit)) && \
|
||||
branch_status=$branch_status[1,$prompt_blimit]$prompt_symbols[ellipsis]
|
||||
[[ $line =~ behind ]] && branch_status+=?
|
||||
[[ $line =~ ahead ]] && branch_status+=!
|
||||
precmd.prompt.add "$prompt_symbols[git] $branch_status" $prompt_colors[git_branch]
|
||||
;;
|
||||
(?[MD]) (( ++count[git_unstaged] )) ;|
|
||||
([MDARC]?) (( ++count[git_staged] )) ;|
|
||||
('??') (( ++count[git_untracked] )) ;|
|
||||
([ADU][ADU]) (( ++count[git_unmerged] ))
|
||||
esac
|
||||
done <<< $raw_status
|
||||
|
||||
for i in git_untracked git_unmerged git_unstaged git_staged; do
|
||||
(( count[$i] )) && precmd.prompt.add "$count[$i]$prompt_symbols[$i]" $prompt_colors[$i]
|
||||
done
|
||||
}
|
||||
|
||||
precmd.prompt() {
|
||||
precmd.prompt.init
|
||||
precmd.prompt.user
|
||||
precmd.prompt.ssh
|
||||
precmd.prompt.cwd
|
||||
}
|
||||
|
||||
precmd.git_update() {
|
||||
precmd.prompt
|
||||
precmd.prompt.git
|
||||
precmd.prompt.bang
|
||||
[[ ! -p $prompt_fifo ]] && mkfifo -m 0600 $prompt_fifo
|
||||
echo -n $prompt_string > $prompt_fifo &!
|
||||
kill -s USR1 $$
|
||||
}
|
||||
|
||||
precmd.prompt.update() {
|
||||
typeset -g prompt_string=$(<$prompt_fifo)
|
||||
precmd.prompt.apply
|
||||
zle && zle reset-prompt
|
||||
}
|
||||
|
||||
precmd.window_title() {
|
||||
printf '\033]0;%s\007' $prompt_wt
|
||||
}
|
||||
|
||||
precmd() {
|
||||
precmd.window_title
|
||||
precmd.prompt
|
||||
if precmd.is_git_repo; then
|
||||
precmd.prompt.pre_git
|
||||
precmd.git_update &!
|
||||
fi
|
||||
precmd.prompt.bang
|
||||
precmd.prompt.apply
|
||||
}
|
||||
|
||||
TRAPUSR1() {
|
||||
precmd.prompt.update
|
||||
}
|
||||
|
||||
TRAPEXIT() {
|
||||
[[ -p $prompt_fifo ]] && rm $prompt_fifo
|
||||
}
|
||||
|
||||
function zle-line-init zle-keymap-select {
|
||||
local seq=$'\e[2 q'
|
||||
[[ $KEYMAP == vicmd ]] && seq=$'\e[4 q'
|
||||
printf $seq
|
||||
}
|
||||
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
43
cli/.config/zsh/settings.zsh
Normal file
43
cli/.config/zsh/settings.zsh
Normal file
|
@ -0,0 +1,43 @@
|
|||
# disable the bloody ^S / ^Q, I use tmux all the time anyway
|
||||
stty -ixon
|
||||
setopt APPEND_HISTORY EXTENDED_HISTORY HIST_IGNORE_DUPS EXTENDED_GLOB AUTO_CD AUTO_PUSHD PRINT_EXIT_VALUE
|
||||
unsetopt BEEP NO_MATCH NOTIFY MENU_COMPLETE AUTO_MENU
|
||||
|
||||
SAVEHIST=1000
|
||||
HISTSIZE=1000
|
||||
HISTFILE=$HOME/.histfile.$UID
|
||||
|
||||
export LESS='i M R'
|
||||
export PAGER=less
|
||||
export EDITOR=vim
|
||||
export TIME_STYLE=long-iso
|
||||
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
|
||||
export ALTERNATE_EDITOR=
|
||||
|
||||
bindkey -e
|
||||
bindkey $terminfo[kdch1] delete-char
|
||||
bindkey $terminfo[khome] beginning-of-line
|
||||
bindkey $terminfo[kend] end-of-line
|
||||
bindkey '^[' vi-cmd-mode
|
||||
|
||||
# autocompletion
|
||||
autoload -Uz compinit
|
||||
|
||||
compinit
|
||||
zstyle ':completion:*' completer _list _complete _ignored
|
||||
zstyle ':completion:*' insert-unambiguous true
|
||||
zstyle ':completion:*' file-sort name
|
||||
zstyle ':completion:*' format 'Completing %d'
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*' list-colors ''
|
||||
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
|
||||
zstyle ':completion:*' list-suffixes true
|
||||
zstyle ':completion:*' original true
|
||||
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
|
||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}'
|
||||
zstyle ':completion:*' rehash true
|
||||
zstyle ':completion:*:kill:*:processes' command 'ps --forest -A -o pid,user,cmd'
|
||||
zstyle ':completion:*:processes-names' command 'ps axho command'
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
|
||||
unalias ld ls ll &>/dev/null
|
Loading…
Add table
Add a link
Reference in a new issue