From 6c4636290a7bec3864fe8af017d2ed6ddb7edf8c Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Thu, 1 Aug 2024 11:08:14 +0800 Subject: 2024-08-01 snapshot --- .vimrc | 33 ++++++++++++- .zshrc | 140 +++++++++++++++++++++++++++---------------------------- kitty/kitty.conf | 2 +- nvim/init.vim | 1 - sync.sh | 2 - 5 files changed, 100 insertions(+), 78 deletions(-) diff --git a/.vimrc b/.vimrc index 14bd21d..57731d5 100644 --- a/.vimrc +++ b/.vimrc @@ -21,7 +21,9 @@ Plugin 'nvim-lua/plenary.nvim' Plugin 'nvim-telescope/telescope.nvim' Plugin 'tpope/vim-surround' Plugin 'puremourning/vimspector' +Plugin 'ilyachur/cmake4vim' " File types +Plugin 'rust-lang/rust.vim' Plugin 'neovimhaskell/haskell-vim' Plugin 'peterhoeg/vim-qml' Plugin 'lervag/vimtex' @@ -72,11 +74,19 @@ autocmd FileType python set ts=4 sw=4 sts=4 expandtab autocmd FileType markdown set ts=4 sw=4 sts=4 expandtab autocmd FileType tex set ts=4 sw=4 sts=4 expandtab autocmd FileType haskell set ts=4 sw=4 sts=4 expandtab +autocmd FileType rust set ts=4 sw=4 sts=4 expandtab autocmd FileType qml set ts=4 sw=4 sts=4 expandtab autocmd FileType c,cpp,asm set ts=8 sw=8 sts=8 noexpandtab +autocmd FileType javascript set ts=8 sw=8 sts=8 noexpandtab set autoindent smartindent +" Force 2 spaces, 4 spaces or 1 tab +nnoremap 2 :set ts=2 sw=2 sts=2 expandtab +nnoremap 4 :set ts=4 sw=4 sts=4 expandtab +nnoremap 8 :set ts=8 sw=8 sts=8 noexpandtab + set background=dark +colorscheme vim let g:airline_theme='onedark' " Popup menu colors @@ -87,8 +97,11 @@ highlight PmenuSel guibg=#61AFEF " Generic shortcuts inoremap :wa nnoremap \ :noh + +" Autoformat autocmd FileType python nnoremap b :!black %:e autocmd FileType c,cpp nnoremap b :pyf /usr/share/clang/clang-format.py +autocmd FileType rust nnoremap b :!rustfmt %:e " ale nnoremap a :ALEToggle @@ -116,6 +129,22 @@ let g:NERDCommentEmptyLines = 1 let g:NERDTrimTrailingWhitespace = 1 let g:NERDToggleCheckAllLines = 1 +" Vimspector +nmap VimspectorToggleBreakpoint +nmap VimspectorStop +nmap VimspectorRestart +nmap VimspectorContinue +nmap VimspectorPause +nmap VimspectorUpFrame +nmap VimspectorDownFrame +nmap VimspectorStepOver +nmap VimspectorStepInto +nmap VimspectorStepOut +nmap di VimspectorBalloonEval +xmap di VimspectorBalloonEval +nmap B VimspectorBreakpoints +nmap D VimspectorDisassemble + " vimtex let g:vimtex_view_general_viewer = 'okular' let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex' @@ -135,8 +164,8 @@ let g:pencil#map#suspend_af = 'K' let g:pencil#textwidth = 74 augroup pencil autocmd! - " autocmd FileType markdown,mkd call pencil#init() - autocmd FileType text call pencil#init() + autocmd FileType markdown,mkd call pencil#init() + " autocmd FileType text call pencil#init() augroup END " vim-workspace diff --git a/.zshrc b/.zshrc index 168ffa1..af8d7b3 100644 --- a/.zshrc +++ b/.zshrc @@ -1,4 +1,4 @@ -export ZSH="/usr/share/oh-my-zsh" +export ZSH="/home/fkfd/.oh-my-zsh" ZSH_THEME="fkfd" @@ -15,46 +15,38 @@ source $ZSH/oh-my-zsh.sh export EDITOR=/usr/bin/nvim export BROWSER=/usr/bin/firefox export PROJECT_PATHS=(~/Projects/ ~/Projects/_cloned/ ~/Projects/_archive/) -export GOPROXY=https://proxy.golang.com.cn,direct -export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/.local/bin:$HOME/.local/texlive/2024/bin/x86_64-linux:$PATH" # utilities mc () { - mkdir $1 && cd $1 + mkdir $1 && cd $1 } -share () { - src=$1 - if [[ $2 == '' ]]; then - dst=$(basename $1) - else - dst=$2 - fi - scp -r $src www@fkfd.me:www/static/$dst - echo "https://fkfd.me/static/$(urlencode $dst)" -} - -bright () { - if [[ $1 == 10 ]]; then - xrandr --output HDMI-A-0 --brightness 1 - return 0 - fi - xrandr --output HDMI-A-0 --brightness "0.$1" +# look at anything +k () { + if [[ -d $1 ]]; then + ls $1 + elif [[ -f $1 ]]; then + $EDITOR $1 + fi } -mnt-cryfs () { - cryfs "/data/Vaults/$1.enc" "$HOME/Vaults/$1" -} - -umnt-cryfs () { - cryfs-unmount "$HOME/Vaults/$1" +share () { + src=$1 + if [[ $2 == '' ]]; then + dst=$(basename $1) + else + dst=$2 + fi + scp -r $src www@fkfd.me:www/static/$dst + echo "https://fkfd.me/static/$(urlencode $dst)" } # make aliases accessible in sudo alias sudo="sudo " alias incognito="unset HISTFILE" -alias proxy="export SOCKS5_PROXY=localhost:1080; export HTTP_PROXY=http://localhost:1081; export HTTPS_PROXY=http://localhost:1081" +alias proxy="export SOCKS5_PROXY=127.0.0.1:1080; export HTTP_PROXY=http://127.0.0.1:1081; export HTTPS_PROXY=http://127.0.0.1:1081" # SSH alias mrf="mosh root@fkfd.me" @@ -66,27 +58,31 @@ alias gimme="sudo chown -R $USER ./ && sudo chmod -R +rw ./*" alias lemme="sudo chmod +x" # embedded -alias ard="arduino-cli" +alias espenv="source ~/p/esp/esp-idf/export.sh" +alias mmu="make && make upload" # python alias py="python" alias venv="source ./venv/bin/activate" # tools -alias ytdl="youtube-dl --proxy socks5://localhost:1080/" alias ytdlp="yt-dlp --proxy socks5://localhost:1080/" alias v="nvim" alias c="cat" alias ls="eza" -alias dormshare="sudo python -m http.server -b 192.168.8.2 80" -alias scanto="scanimage -d 'hpaio:/usb/HP_LaserJet_Professional_M1219nf_MFP?serial=000000000QJA9XJFPR1a' --source Flatbed --format=jpeg --mode=Gray --resolution=200 -x 210 -y 297 -o " - -alias tlmgr="/usr/share/texmf-dist/scripts/texlive/tlmgr.pl --usermode" +PRINTER="hpaio:/usb/HP_LaserJet_Professional_M1219nf_MFP?serial=000000000QJA9XJFPR1a" +alias scan="scanimage -d '$PRINTER' --source Flatbed --format=jpeg" +alias scanto="scanimage -d '$PRINTER' --source Flatbed --format=jpeg --mode=Gray --resolution=200 -x 210 -y 297 -o " alias catpic="montage -tile 1x -geometry +0+0" +alias prc="perf record -F 1000 --call-graph=dwarf -e cycles:u" +alias prp="perf report" + # fun -alias rickroll="vlc -f '/data/Videos/Rick Astley - Never Gonna Give You Up (Official Music Video).mkv'" +alias rickroll="vlc -f '~/Videos/Rick Astley - Never Gonna Give You Up (Official Music Video).mkv'" + +alias neofetch="if [[ $TERM == 'xterm-kitty' ]]; then neofetch --kitty ~/Pictures/branding/logos/arch.png --size 420px; else neofetch; fi" # disable beep in x11 set -B 0 @@ -99,52 +95,52 @@ alias accel="killall kglobalaccel5 && kglobalaccel5&" # TA work alias gccc="gcc -pedantic -std=c11 -Wall -Wextra -Werror -Wno-unused-result -Wconversion -Wvla" -# auto-generated by kdesrc-build initial setup: do not remove! -# Add the kdesrc-build directory to the path -# export PATH="$HOME/kde/src/kdesrc-build:$PATH" -# Create alias for running software built with kdesrc-build -kdesrc-run () -{ - source "$HOME/kde/build/$1/prefix.sh" && "$HOME/kde/usr/bin/$1" +# SJTU VPN +vpn () { + if ! systemctl is-active --quiet strongswan; then + sudo systemctl start strongswan + fi + if [[ $1 == "on" ]]; then + sudo swanctl -i --child vpn-student + elif [[ $1 == "off" ]]; then + sudo swanctl -t --ike vpn-student + else + echo "Usage: $0 [on|off]" + fi } - # kdesrc-build ################################################################# ## Add kdesrc-build to PATH -export PATH="$HOME/kde/src/kdesrc-build:$PATH" +export PATH="/home/fkfd/kde/src/kdesrc-build:$PATH" ## Autocomplete for kdesrc-run -function _comp-kdesrc-run -{ - local cur - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - - # Complete only the first argument - if [[ $COMP_CWORD != 1 ]]; then - return 0 - fi - - # Retrieve build modules through kdesrc-run - # If the exit status indicates failure, set the wordlist empty to avoid - # unrelated messages. - local modules - if ! modules=$(kdesrc-run --list-installed); - then - modules="" - fi - - # Return completions that match the current word - COMPREPLY=( $(compgen -W "${modules}" -- "$cur") ) - - return 0 +function _comp_kdesrc_run { + local cur + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + + # Complete only the first argument + if [[ $COMP_CWORD != 1 ]]; then + return 0 + fi + + # Retrieve build modules through kdesrc-run + # If the exit status indicates failure, set the wordlist empty to avoid + # unrelated messages. + local modules + if ! modules=$(kdesrc-run --list-installed); + then + modules="" + fi + + # Return completions that match the current word + COMPREPLY=( $(compgen -W "${modules}" -- "$cur") ) + + return 0 } ## Register autocomplete function -# complete -o nospace -F _comp-kdesrc-run kdesrc-run - +complete -o nospace -F _comp_kdesrc_run kdesrc-run ################################################################################ -# opam configuration -[[ ! -r /home/fkfd/.opam/opam-init/init.zsh ]] || source /home/fkfd/.opam/opam-init/init.zsh > /dev/null 2> /dev/null diff --git a/kitty/kitty.conf b/kitty/kitty.conf index e1aabf6..0e3f718 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1,5 +1,5 @@ font_family Fira Code -font_size 12 +font_size 13 cursor_blink_interval 0 diff --git a/nvim/init.vim b/nvim/init.vim index cddc0aa..aa408a7 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -39,7 +39,6 @@ require('nvim-tree').setup({ }, view = { width = 30, - hide_root_folder = false, side = 'left', number = false, relativenumber = false, diff --git a/sync.sh b/sync.sh index 83f9cc3..6e8da4d 100755 --- a/sync.sh +++ b/sync.sh @@ -3,7 +3,5 @@ # cp ~/.gitconfig ./ cp ~/.vimrc ./ cp ~/.zshrc ./ -cp -r ~/.config/sway/ ./ -cp -r ~/.config/i3status/ ./ cp -r ~/.config/kitty/ ./ cp -r ~/.config/nvim/ ./ -- cgit v1.2.3