Merge branch 'master' of gitee.com:klesh/dotfiles
This commit is contained in:
commit
a451673509
|
@ -1,98 +1,45 @@
|
||||||
#!/usr/bin/env fish
|
#!/bin/fish
|
||||||
|
|
||||||
# datetime in filename format
|
|
||||||
function dt
|
|
||||||
date "+%Y%m%d-%H%M%S"
|
|
||||||
end
|
|
||||||
|
|
||||||
function clean-taobao-link
|
|
||||||
xsel -ob | sed 's/^\(.*\)?\(.*&\)\?\(id=[^&]\+\).*$/\1?\3/g' | xsel -b
|
|
||||||
end
|
|
||||||
|
|
||||||
# for WSL
|
|
||||||
function sync-ssh-config
|
|
||||||
# sshconfig has a restricted file permission requirement which normally hard to
|
|
||||||
# be met on Window (i.e., syncing your config by Nextcloud on drive D).
|
|
||||||
# this function pours contents of files within ~/.ssh/config.d to ~/.ssh/config
|
|
||||||
if test -d ~/.ssh/config.d
|
|
||||||
rm -rf ~/.ssh/config
|
|
||||||
for cfg in (ls ~/.ssh/config.d)
|
|
||||||
cat ~/.ssh/config.d/$cfg >> ~/.ssh/config
|
|
||||||
end
|
|
||||||
chmod 600 ~/.ssh/config
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function swap-caps-esc
|
|
||||||
setxkbmap -option caps:swapescape
|
|
||||||
end
|
|
||||||
|
|
||||||
function caps-to-grave
|
|
||||||
xmodmap -e "clear Lock"
|
|
||||||
xmodmap -e "keycode 66 = grave asciitilde"
|
|
||||||
end
|
|
||||||
|
|
||||||
# print out all colors with their index
|
|
||||||
function show-colors
|
|
||||||
bash -c '(x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)'
|
|
||||||
end
|
|
||||||
|
|
||||||
if status is-interactive
|
if status is-interactive
|
||||||
|
# === default programs
|
||||||
set -gx EDITOR nvim
|
set -gx EDITOR nvim
|
||||||
|
|
||||||
# enable fzf completion hotkey
|
# === fzf configuration
|
||||||
set -gx FZF_DEFAULT_COMMAND 'ag -g ""'
|
set -gx FZF_DEFAULT_COMMAND 'ag -g ""'
|
||||||
set -U FZF_COMPLETE 0
|
set -U FZF_COMPLETE 0
|
||||||
set -U FZF_FIND_FILE_COMMAND 'ag -g ""'
|
set -U FZF_FIND_FILE_COMMAND 'ag -g ""'
|
||||||
set -U FZF_OPEN_COMMAND 'ag -g ""'
|
set -U FZF_OPEN_COMMAND 'ag -g ""'
|
||||||
|
|
||||||
|
# === less configuration
|
||||||
# no line-wrapping, good for `docker ps`
|
# no line-wrapping, good for `docker ps`
|
||||||
set -gx LESS "-SRXF"
|
set -gx LESS "-SRXF"
|
||||||
# nvm plugin
|
|
||||||
|
# === nvm configuration
|
||||||
set -gx nvm_mirror http://npm.taobao.org/mirrors/node
|
set -gx nvm_mirror http://npm.taobao.org/mirrors/node
|
||||||
|
|
||||||
|
# === `ls` configuration
|
||||||
# change OTHER-WRITABLE color for `ls` command
|
# change OTHER-WRITABLE color for `ls` command
|
||||||
set -gx LS_COLORS 'ow=34;42;40'
|
set -gx LS_COLORS 'ow=34;42;40'
|
||||||
|
|
||||||
|
# === ranger configuration
|
||||||
# ranger highlighting color theme
|
# ranger highlighting color theme
|
||||||
set -gx HIGHLIGHT_OPTIONS --style=solarized-dark
|
set -gx HIGHLIGHT_OPTIONS --style=solarized-dark
|
||||||
# dict.sh
|
|
||||||
|
# === dict.sh configuration
|
||||||
set -gx D_SELECTOR 'plainsel'
|
set -gx D_SELECTOR 'plainsel'
|
||||||
|
|
||||||
|
# === fish git prompt configuration
|
||||||
# tune git icon for nerdfont
|
# tune git icon for nerdfont
|
||||||
set -g __fish_git_prompt_char_upstream_ahead '>'
|
set -g __fish_git_prompt_char_upstream_ahead '>'
|
||||||
set -g __fish_git_prompt_char_upstream_behind '<'
|
set -g __fish_git_prompt_char_upstream_behind '<'
|
||||||
set -g __fish_git_prompt_char_upstream_prefix ''
|
set -g __fish_git_prompt_char_upstream_prefix ''
|
||||||
|
|
||||||
set -g __fish_git_prompt_char_stagedstate '●'
|
set -g __fish_git_prompt_char_stagedstate '●'
|
||||||
set -g __fish_git_prompt_char_dirtystate '*'
|
set -g __fish_git_prompt_char_dirtystate '*'
|
||||||
set -g __fish_git_prompt_char_untrackedfiles '+'
|
set -g __fish_git_prompt_char_untrackedfiles '+'
|
||||||
set -g __fish_git_prompt_char_conflictedstate 'x'
|
set -g __fish_git_prompt_char_conflictedstate 'x'
|
||||||
set -g __fish_git_prompt_char_cleanstate '✔ '
|
set -g __fish_git_prompt_char_cleanstate '✔ '
|
||||||
|
|
||||||
function append-path-if-exists
|
# === alias
|
||||||
if test -e $argv
|
|
||||||
set -gx PATH $argv $PATH
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function source-file-if-exists
|
|
||||||
for f in $argv
|
|
||||||
test -e $f && source $f && return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function r --description='sync ranger pwd to shell when exit'
|
|
||||||
set tempfile (mktemp -t tmp.XXXXXX)
|
|
||||||
command ranger --choosedir=$tempfile $argv
|
|
||||||
if test -s $tempfile
|
|
||||||
set ranger_pwd (cat $tempfile)
|
|
||||||
if test -n $ranger_pwd -a -d $ranger_pwd
|
|
||||||
builtin cd -- $ranger_pwd
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
command rm -f -- $tempfile
|
|
||||||
end
|
|
||||||
|
|
||||||
append-path-if-exists ~/.yarn/bin
|
|
||||||
alias k="kubectl"
|
alias k="kubectl"
|
||||||
alias kcc="k config get-contexts"
|
alias kcc="k config get-contexts"
|
||||||
alias kcu="k config use-context"
|
alias kcu="k config use-context"
|
||||||
|
@ -102,8 +49,14 @@ if status is-interactive
|
||||||
alias kl="k logs -f --all-containers"
|
alias kl="k logs -f --all-containers"
|
||||||
alias issh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
alias issh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
||||||
alias iscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
alias iscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
||||||
|
alias dt='date "+%Y%m%d-%H%M%S"'
|
||||||
|
|
||||||
|
# === PATH and file sourcing
|
||||||
|
append_paths ~/.yarn/bin
|
||||||
|
source_files /usr/share/autojump/autojump.fish /usr/local/share/autojump/autojump.fish \
|
||||||
|
~/.profile.fish
|
||||||
|
|
||||||
|
# === auto cd into last activated directory
|
||||||
cd $last_pwd
|
cd $last_pwd
|
||||||
source-file-if-exists /usr/share/autojump/autojump.fish /usr/local/share/autojump/autojump.fish
|
|
||||||
source-file-if-exists ~/.profile.fish
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
6
fish/config/functions/append_paths.fish
Normal file
6
fish/config/functions/append_paths.fish
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
function append_paths
|
||||||
|
for f in $argv
|
||||||
|
test -e $f && set -gx PATH $f $PATH
|
||||||
|
end
|
||||||
|
end
|
4
fish/config/functions/clean_taobao_link.fish
Normal file
4
fish/config/functions/clean_taobao_link.fish
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
function clean_taobao_link -d 'keep only id parameter for taobao merchandise detail page link'
|
||||||
|
xsel -ob | sed 's/^\(.*\)?\(.*&\)\?\(id=[^&]\+\).*$/\1?\3/g' | xsel -b
|
||||||
|
end
|
8
fish/config/functions/print_colors.fish
Normal file
8
fish/config/functions/print_colors.fish
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
function print_colors -d 'print out all terminal colors'
|
||||||
|
set x (tput op)
|
||||||
|
set y (printf '%76s')
|
||||||
|
for i in (seq 256)
|
||||||
|
printf "%3s %s%s%s%s\n" $i (tput setaf $i) (tput setab $i) $y $x
|
||||||
|
end
|
||||||
|
end
|
13
fish/config/functions/r.fish
Normal file
13
fish/config/functions/r.fish
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
function r --description='sync ranger pwd to shell when exit'
|
||||||
|
set tempfile (mktemp -t tmp.XXXXXX)
|
||||||
|
command ranger --choosedir=$tempfile $argv
|
||||||
|
if test -s $tempfile
|
||||||
|
set ranger_pwd (cat $tempfile)
|
||||||
|
if test -n $ranger_pwd -a -d $ranger_pwd
|
||||||
|
builtin cd -- $ranger_pwd
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
command rm -f -- $tempfile
|
||||||
|
end
|
6
fish/config/functions/source_files.fish
Normal file
6
fish/config/functions/source_files.fish
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
function source_files
|
||||||
|
for f in $argv
|
||||||
|
test -e $f && source $f && return
|
||||||
|
end
|
||||||
|
end
|
13
fish/config/functions/sync_ssh_config.fish
Normal file
13
fish/config/functions/sync_ssh_config.fish
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
function sync_ssh_config -d 'sync ssh config file for wsl'
|
||||||
|
# sshconfig has a restricted file permission requirement which normally hard to
|
||||||
|
# be met on Window (i.e., syncing your config by Nextcloud on drive D).
|
||||||
|
# this function pours contents of files within ~/.ssh/config.d to ~/.ssh/config
|
||||||
|
if test -d ~/.ssh/config.d
|
||||||
|
rm -rf ~/.ssh/config
|
||||||
|
for cfg in (ls ~/.ssh/config.d)
|
||||||
|
cat ~/.ssh/config.d/$cfg >> ~/.ssh/config
|
||||||
|
end
|
||||||
|
chmod 600 ~/.ssh/config
|
||||||
|
end
|
||||||
|
end
|
|
@ -47,6 +47,9 @@ lnsf "$DIR/config/config.fish" "$XDG_CONFIG_HOME/fish/config.fish"
|
||||||
lnsf "$DIR/config/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish"
|
lnsf "$DIR/config/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish"
|
||||||
lnsf "$DIR/config/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish"
|
lnsf "$DIR/config/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish"
|
||||||
lnsf "$DIR/config/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish"
|
lnsf "$DIR/config/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish"
|
||||||
|
lnsf "$DIR/config/functions/r.fish" "$XDG_CONFIG_HOME/fish/functions/r.fish"
|
||||||
|
lnsf "$DIR/config/functions/append_paths.fish" "$XDG_CONFIG_HOME/fish/functions/append_paths.fish"
|
||||||
|
lnsf "$DIR/config/functions/source_files.fish" "$XDG_CONFIG_HOME/fish/functions/source_files.fish"
|
||||||
|
|
||||||
# install plugins
|
# install plugins
|
||||||
# for better keybinding: C-o open file with $EDITOR / C-r search history / C-g open with xdg-open
|
# for better keybinding: C-o open file with $EDITOR / C-r search history / C-g open with xdg-open
|
||||||
|
|
|
@ -22,6 +22,7 @@ set signcolumn=yes
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
set fillchars=vert:\ ,fold:-
|
set fillchars=vert:\ ,fold:-
|
||||||
set clipboard=unnamedplus " system clipboard as default register. for vim to work need installing gvim package
|
set clipboard=unnamedplus " system clipboard as default register. for vim to work need installing gvim package
|
||||||
|
set mouse=a
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
syntax on
|
syntax on
|
||||||
au! BufWritePost $MYVIMRC source %
|
au! BufWritePost $MYVIMRC source %
|
||||||
|
@ -65,12 +66,14 @@ nmap <leader>' ysiw'
|
||||||
nmap <leader>`` ysiW`
|
nmap <leader>`` ysiW`
|
||||||
nmap <leader>` ysiw`
|
nmap <leader>` ysiw`
|
||||||
|
|
||||||
nmap <leader>sb :set scrollbind<CR>
|
nmap <leader>sb :windo set scrollbind<CR>:windo set cursorbind<CR>:set mouse=a<CR>
|
||||||
nmap <leader>nsb :set noscrollbind<CR>
|
nmap <leader>nsb :windo set noscrollbind<CR>:windo set nocursorbind<CR>:set mouse=<CR>
|
||||||
|
|
||||||
inoremap <C-w> <esc><C-w>
|
inoremap <C-w> <esc><C-w>
|
||||||
nmap <silent> <leader>ss :syntax sync fromstart<CR>
|
nmap <silent> <leader>ss :syntax sync fromstart<CR>
|
||||||
|
|
||||||
|
" // to search highlighted text
|
||||||
|
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
|
||||||
|
|
||||||
" trailing spaces
|
" trailing spaces
|
||||||
highlight ExtraWhitespace ctermbg=red guibg=red
|
highlight ExtraWhitespace ctermbg=red guibg=red
|
||||||
|
@ -121,7 +124,8 @@ Plug 'tpope/vim-fugitive' " git 功能
|
||||||
Plug 'scrooloose/nerdcommenter'
|
Plug 'scrooloose/nerdcommenter'
|
||||||
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
|
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
|
||||||
Plug 'morhetz/gruvbox'
|
Plug 'morhetz/gruvbox'
|
||||||
Plug 'dag/vim-fish', { 'for': 'fish' }
|
Plug 'klesh/vim-fish', { 'for': 'fish' }
|
||||||
|
"Plug 'aliva/vim-fish', { 'for': 'fish' }
|
||||||
Plug 'alvan/vim-closetag', { 'for': ['vue', 'html', 'xml'] }
|
Plug 'alvan/vim-closetag', { 'for': ['vue', 'html', 'xml'] }
|
||||||
"Plug 'airblade/vim-gitgutter'
|
"Plug 'airblade/vim-gitgutter'
|
||||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||||
|
|
|
@ -4,19 +4,13 @@
|
||||||
|
|
||||||
|
|
||||||
xrandr | awk '
|
xrandr | awk '
|
||||||
BEGIN {
|
$2 == "connected" && $3 == "primary" {
|
||||||
MIN_DPI=99999999
|
if (match($0, / ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) (left|right)?/, m1) &&
|
||||||
}
|
|
||||||
$2 == "connected" {
|
|
||||||
if (match($0, / ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) /, m1) &&
|
|
||||||
match($0, / ([0-9]+)mm x ([0-9]+)mm$/, m2)) {
|
match($0, / ([0-9]+)mm x ([0-9]+)mm$/, m2)) {
|
||||||
DPI=m1[1]*25.4/m2[1]
|
DPI=m1[1]*25.4/m2[m1[5]?2:1]
|
||||||
if (DPI < MIN_DPI) MIN_DPI=DPI
|
printf "Xft.dpi: %i", DPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END {
|
|
||||||
printf "Xft.dpi: %i", MIN_DPI+0.5
|
|
||||||
}
|
|
||||||
' | xrdb -merge
|
' | xrdb -merge
|
||||||
|
|
||||||
nitrogen --restore
|
nitrogen --restore
|
||||||
|
|
Loading…
Reference in New Issue
Block a user