Compare commits
5 Commits
58478b9b15
...
21e5d0ac86
Author | SHA1 | Date |
---|---|---|
Hektor Misplon | 21e5d0ac86 | |
Hektor Misplon | 0ce01efd46 | |
Hektor Misplon | 5a29b672a2 | |
Hektor Misplon | 2f4ed6cc51 | |
Hektor Misplon | a6a85d1ea5 |
|
@ -0,0 +1,19 @@
|
|||
#!/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}"
|
|
@ -8,14 +8,18 @@
|
|||
# `systemctl --user enable save-passwddb.service`
|
||||
# `systemctl --user enable save-passwddb.timer`
|
||||
|
||||
# https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard
|
||||
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>
|
||||
if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then
|
||||
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx"
|
||||
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx.key"
|
||||
echo "Saving KeePassXC databases and database keys"
|
||||
rclone copyto \
|
||||
"$HOME/doc/" "$RCLONE_REMOTE:doc"/ \
|
||||
--progress \
|
||||
--include "/*.{kdbx,kdbx.key}"
|
||||
else
|
||||
echo "No password database found, use the following commands to restore"
|
||||
echo ""
|
||||
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx\""
|
||||
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx.key\""
|
||||
echo "rclone copy $RCLONE_REMOTE:doc \"$HOME/doc\" --include \"*.{kdbx,kdbx.key}\""
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
" 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
|
|
@ -0,0 +1,3 @@
|
|||
" JSONC (see https://github.com/neoclide/jsonc.vim/pull/9")
|
||||
au BufNewFile,BufRead */.vscode/*.json setlocal filetype=jsonc
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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
|
|
@ -0,0 +1,5 @@
|
|||
augroup Vim
|
||||
au!
|
||||
" Reload vim config when ~/.vimrc is changed
|
||||
au BufWritePost $HOME/.vimrc so $MYVIMRC | redraw | echo "Reloaded vimrc"
|
||||
augroup END
|
|
@ -0,0 +1,7 @@
|
|||
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%*
|
|
@ -0,0 +1,20 @@
|
|||
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
79
.vimrc
|
@ -32,6 +32,12 @@ set thesaurus+=~/.vim/thesaurus/mthesaur.txt
|
|||
|
||||
" }}}
|
||||
|
||||
" Colorscheme {{{
|
||||
set termguicolors
|
||||
set bg=light
|
||||
hi Normal ctermbg=none guibg=none
|
||||
" }}}
|
||||
|
||||
" Mappings {{{
|
||||
"
|
||||
|
||||
|
@ -223,90 +229,17 @@ 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
|
||||
|
|
|
@ -197,6 +197,8 @@ 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
|
||||
|
@ -260,6 +262,9 @@ 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}'"
|
||||
|
|
Loading…
Reference in New Issue