Compare commits

..

No commits in common. "b3c9d02ca5c32014f28c5b35fb841fa57e629b86" and "72629f5b989650dd0ac04ccef0e7943ad7d8216a" have entirely different histories.

10 changed files with 78 additions and 98 deletions

View File

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# Backup existing password databases and
# database keys (using date in filename date -u
# +%Y-%m-%d_%H-%M-%S)
RCLONE_REMOTE="proton-drive"
for f in "$HOME/doc"/*.{kdbx,kdbx.key}; do
[ -e "$f" ] || continue
echo "Backing up $f to $f-$(date -u +%Y-%m-%d_%H-%M-%S)"
cp "$f" "$f-$(date -u +%Y-%m-%d_%H-%M-%S)"
done
echo "Restoring KeePassXC databases and database keys"
rclone copyto \
"$RCLONE_REMOTE:doc"/ "$HOME/doc/" \
--progress \
--include "/*.{kdbx,kdbx.key}"

View File

@ -8,18 +8,14 @@
# `systemctl --user enable save-passwddb.service`
# `systemctl --user enable save-passwddb.timer`
RCLONE_REMOTE="proton-drive"
# Reference: <https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard>
# https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard
if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then
echo "Saving KeePassXC databases and database keys"
rclone copyto \
"$HOME/doc/" "$RCLONE_REMOTE:doc"/ \
--progress \
--include "/*.{kdbx,kdbx.key}"
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx"
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx.key"
else
echo "No password database found, use the following commands to restore"
echo ""
echo "rclone copy $RCLONE_REMOTE:doc \"$HOME/doc\" --include \"*.{kdbx,kdbx.key}\""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx\""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx.key\""
exit 1
fi

View File

@ -1,14 +0,0 @@
" Taken from /usr/share/vim/vim90/defaults.vim
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END

View File

@ -1,3 +0,0 @@
" JSONC (see https://github.com/neoclide/jsonc.vim/pull/9")
au BufNewFile,BufRead */.vscode/*.json setlocal filetype=jsonc

View File

@ -1,10 +0,0 @@
fu! Compile()
if expand('%:e') == "md"
:silent exec "!pandoc % -s -o /tmp/op.pdf &"
endif
endfu
fu! Preview()
:call Compile()
:silent exec "!zathura /tmp/op.pdf &"
endfu

View File

@ -1,5 +0,0 @@
augroup Vim
au!
" Reload vim config when ~/.vimrc is changed
au BufWritePost $HOME/.vimrc so $MYVIMRC | redraw | echo "Reloaded vimrc"
augroup END

View File

@ -1,7 +0,0 @@
se ls=2
se stl=\ %0*%n
se stl+=\ %m
se stl+=\ %y%0*
se stl+=\ %<%F
se stl+=\ %0*%=%5l%*
se stl+=%0*/%L%*

View File

@ -1,20 +0,0 @@
let s:zk_preview_enabled = 0
let s:live_server_job = -1
au BufEnter /home/h/.zk/*.md silent exe '!echo "%" > /home/h/.zk/current-zettel.txt'
function! ToggleZKPreview()
if s:zk_preview_enabled == 1
let s:zk_preview_enabled = 0
call jobstop(s:live_server_job)
au! ZKPreview
else
let s:zk_preview_enabled = 1
let s:live_server_job = jobstart('live-server --watch=/home/h/.zk/current-zettel-content.html --open=current-zettel-content.html --port=8080')
augroup ZKPreview
au BufEnter /home/h/.zk/*.md silent exe '!cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
au BufWritePost /home/h/.zk/*.md silent exe '!make && cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
augroup END
endif
endfunction
command! ToggleZKPreview call ToggleZKPreview()
nn <leader>o :ToggleZKPreview<cr> :!xdg-open http://localhost:8080/%:t:r.html & <cr>

79
.vimrc
View File

@ -32,12 +32,6 @@ set thesaurus+=~/.vim/thesaurus/mthesaur.txt
" }}}
" Colorscheme {{{
set termguicolors
set bg=light
hi Normal ctermbg=none guibg=none
" }}}
" Mappings {{{
"
@ -229,17 +223,90 @@ au Filetype supercollider packadd scvim
" }}}
" }}}
" Color theme & statusline {{{
"
se ls=2
se stl=\ %0*%n
se stl+=\ %m
se stl+=\ %y%0*
se stl+=\ %<%F
se stl+=\ %0*%=%5l%*
se stl+=%0*/%L%*
colo yang
" }}}
" Quick hacks {{{
"
fu! Compile()
if expand('%:e') == "md"
:silent exec "!pandoc % -s -o /tmp/op.pdf &"
endif
endfu
fu! Preview()
:call Compile()
:silent exec "!zathura /tmp/op.pdf &"
endfu
" VIM config hot reload
" TODO: separate to filetype specific files
" JS
" Jump between `=` and `;`
au FileType javascript set mps+==:;
" JSONC (see https://github.com/neoclide/jsonc.vim/pull/9")
au BufNewFile,BufRead */.vscode/*.json setlocal filetype=jsonc
let s:zk_preview_enabled = 0
let s:live_server_job = -1
au BufEnter /home/h/.zk/*.md silent exe '!echo "%" > /home/h/.zk/current-zettel.txt'
function! ToggleZKPreview()
if s:zk_preview_enabled == 1
let s:zk_preview_enabled = 0
call jobstop(s:live_server_job)
au! ZKPreview
else
let s:zk_preview_enabled = 1
let s:live_server_job = jobstart('live-server --watch=/home/h/.zk/current-zettel-content.html --open=current-zettel-content.html --port=8080')
augroup ZKPreview
au BufEnter /home/h/.zk/*.md silent exe '!cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
au BufWritePost /home/h/.zk/*.md silent exe '!make && cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
augroup END
endif
endfunction
command! ToggleZKPreview call ToggleZKPreview()
nn <leader>o :ToggleZKPreview<cr> :!xdg-open http://localhost:8080/%:t:r.html & <cr>
highlight QuickScopeSecondary cterm=underline
highlight QuickScopePrimary ctermbg=253 ctermfg=232 cterm=none
highlight Pmenu ctermfg=232
" Taken from /usr/share/vim/vim90/defaults.vim
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
augroup Vim
au!
" Reload vim config when ~/.vimrc is changed
au BufWritePost $HOME/.vimrc so $MYVIMRC | redraw | echo "Reloaded vimrc"
augroup END

View File

@ -197,8 +197,6 @@ myKeys =
("<F8>", spawnKeepassXC),
("M-z", spawnZettelkasten),
("M-p", spawnLauncher),
("M-w", spawnWindowSwitcher),
("M-S-w", spawnWifiMenu),
("<Insert>", pasteSelection),
("<Print>", printScreen),
("<XF86AudioRaiseVolume>", raiseVol), -- Audio volume & playback
@ -262,9 +260,6 @@ spawnKeepassXC = spawn "keepassxc"
fullscreenBrowser :: X ()
fullscreenBrowser = spawn "firefox --fullscreen"
spawnWindowSwitcher = spawn "rofi -show window -show-icons"
spawnWifiMenu = spawn "rofi -show wifi -modi \"wifi:iwdrofimenu\""
spawnLauncher, spawnClipManager, spawnCalculator :: X ()
spawnLauncher = spawn "rofi -show drun -show-icons"
spawnClipManager = spawn "rofi -modi 'clipboard:greenclip print' -show clipboard -run-command '{cmd}'"