Browse Source

buku-fzf function, dmenu with history

red-hat-laptop
Kevin Mok 5 years ago
parent
commit
704fb6665c
Signed by: Kevin-Mok GPG Key ID: AEA75288DC135CF5
  1. 61
      aliases/key_aliases.tmpl
  2. 7
      aliases/key_dirs.tmpl
  3. 1
      aliases/key_files.tmpl
  4. 3
      dot_Xresources.tmpl
  5. 46
      dot_config/fish/completions/buku.fish
  6. 6
      dot_config/fish/config.fish.tmpl
  7. 12
      dot_config/fish/functions/buku-fzf.fish
  8. 7
      dot_config/fish/functions/sudo.fish
  9. 18
      dot_config/i3/config.tmpl
  10. 19
      dot_vimrc.tmpl
  11. 50
      scripts/executable_dmenu-history

61
aliases/key_aliases.tmpl

@ -6,7 +6,7 @@
# clear screen
c "printf '\033c'"
dc "cd ~/Downloads && printf '\033c'"
d "cd ~/Downloads && printf '\033c'"
hst "history"
## nf "printf '\033c' && neofetch | lolcat"
nf "printf '\033c' && neofetch"
@ -39,8 +39,8 @@ xrs "xrandr -s 0"
vgb "sudo nvim /etc/default/grub"
mkgb "sudo grub-mkconfig -o /boot/grub/grub.cfg"
b "bat"
ba "bat *"
ba "bat"
# ba "bat *"
grep "grep --color=auto -n"
grpr "grep -r"
# pk "pkill -f"
@ -67,6 +67,16 @@ nctr "sudo systemctl restart netctl-auto@wlp4s0.service"
# ]]] systemctl #
# ssh [[[ #
cpssh "ssh-copy-id -i ~/.ssh/id_rsa.pub"
xcssh "bat ~/.ssh/id_rsa.pub | xclip -selection clipboard"
ssp "mosh --ssh='ssh -p 8022' 192.168.0.12"
ssd "mosh kevin@165.22.239.234 tmux a"
# ]]] ssh #
wh "watch"
ct "crontab"
cte "crontab -e"
@ -97,7 +107,7 @@ cwd "echo (pwd) | xclip -selection clipboard"
smv "sudo mv"
f "cd"
fz "fzf -e"
fbg "cd ~/Pictures/Backgrounds && fzf -e --delimiter '/' --with-nth -1"
fbg "cd ~/Pictures/Backgrounds && ranger --selectfile (fzf -e --delimiter '/' --with-nth -1)"
fnd "find . -type f -name"
rmr "rm -rf"
@ -225,6 +235,8 @@ dh "sudo dhcpcd"
kdh "sudo killall dhcpcd"
rdh "sudo killall dhcpcd && sudo dhcpcd"
wgt "wget"
# ]]] internet #
id "identify"
@ -239,6 +251,20 @@ id "identify"
# silent="> /dev/null 2>&1& "
a "antimicro"
# buku [[[ #
b "buku"
bd "buku -za ''"
bh "buku -h | bat"
bi "buku --immutable 1 -zu"
bo "buku -o"
br "buku -zd"
brp "buku --replace"
bs "buku --deep -n5 -s"
bsv "bukuserver run --host 127.0.0.1 --port 5001"
bw "buku -zw --immutable 1"
# ]]] buku #
chr "google-chrome"
clc "cloc ."
cv "cava"
@ -275,6 +301,8 @@ rbg "ranger --selectfile (grep wallpaper ~/.cache/wal/colors.sh | cut -d\' -f2)"
rgc "clear && tmux clear-history && rg"
rx "redshift -x"
sn "sudo nvim"
ssh "mosh"
stp "termdown"
# sw "swex"
t "tmux"#[[[
ta "tmux a -t"
@ -282,6 +310,8 @@ tal "tmux a"
tk "tmux kill-server"
tl "tmux ls"
tn "tmux new -s"
tnc "tmux new -s config"
tnj "tmux new -s journal"
#]]]
vmd "vimdiff"
wg "wego"
@ -335,13 +365,12 @@ wt "watson status"
# log/report [[[ #
wl "watson log --day"
wla "watson log --all --tag="
ww "watson log"
# wlm "watson log --project coding --tag mfs"
wr "watson report --day"
wra "watson report --all --tag="
wrw "watson report"
wl "watson log -Gcd"
wla "watson log -Gca -T"
ww "watson log -Gc"
wr "watson report -Gcd"
wra "watson report -Gca -T"
wrw "watson report -Gc"
# ]]] log/report #
@ -373,6 +402,8 @@ gmgt "git mergetool"
gr "git remote -v"
gra "git remote add origin"
grag "git remote add gitea git@ataraxy.tk:Kevin-Mok/.git"
grr "git remote remove origin"
grs "git remote show origin"
gru "git branch --set-upstream-to=origin/master master"
@ -564,12 +595,12 @@ ht "python3 -m http.server"
h "hugo"
he "hugo serve -D --disableFastRender"
# ]]] mfs #
ssb "ssh-bandit"
rt "python ~/coding/rt-scraper/!rt-scraper.py"
# ]]] mfs #
# ada-mario [[[ #
mm "printf '\033c' && bear make clean move_mouse_with_head && ./move_mouse_with_head"
@ -583,6 +614,9 @@ gpsb "git push bitbucket"
sac "source ../../bin/activate.fish"
dea "deactivate"
whe "watch echo"
vst "cp ~/Documents/workout-logs/stretching.md /tmp && nvim /tmp/stretching.md"
# ]]] coding projs #
# games [[[ #
@ -607,7 +641,6 @@ mst "minetestserver --gameid minimal --worldname Test --terminal"
# wlf "watson log --all --tag=final"
# wrf "watson report --all --tag=final"
ssc "mosh mokkar@teach.cs.utoronto.ca"
ssp "mosh --ssh='ssh -p 8022' 192.168.0.11"
# alg course
jc "javac -d out *.java"

7
aliases/key_dirs.tmpl

@ -3,9 +3,10 @@
# sys [[[ #
bg ~/Pictures/Backgrounds
cf ~/.config
cf ~/linux-config/dot_config
cfd ~/.config
cff ~/.config/fish
d ~/Downloads
do ~/Downloads
# dw ~/dwm
D ~/Documents
k ~/
@ -46,7 +47,7 @@ sv ~/coding/spotify-lib-vis/src
svg ~/coding/spotify-lib-vis/src/graphs/static/graphs/scripts
swd ~/coding/swex
tb ~/coding/trapbot/src/trapbot
wo ~/Documents/workout-logs/11
wo ~/Documents/workout-logs
{{ end }}
{{ if eq .chezmoi.fullHostname "x1-carbon" }}

1
aliases/key_files.tmpl

@ -40,6 +40,7 @@ mi ~/coding/mf-site/ideas.md
ne ~/linux-config/configs/neofetch/config.conf
re README.md
td todo.md
tg ~/.config/watson/tags_cache
tt txt/todo.md
tm ~/.vim/plugged/vim-snippets/UltiSnips/texmath.snippets
tp /tmp/

3
dot_Xresources.tmpl

@ -4,7 +4,8 @@
URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=11
! URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=12
{{ else }}
URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=14
URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=15
! URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=14
! URxvt.font: xft:DejaVuSansMono Nerd Font Mono:size=13.5
{{ end }}
! URxvt.font: xft:Hack:size=18

46
dot_config/fish/completions/buku.fish

@ -0,0 +1,46 @@
#
# Fish completion definition for Buku.
#
# Author:
# Arun Prakash Jana <engineerarun@gmail.com>
#
complete -c buku -s a -l add -r --description 'add bookmark'
complete -c buku -l ai --description 'auto-import bookmarks'
complete -c buku -s c -l comment --description 'comment on bookmark'
complete -c buku -l cached -r --description 'visit Wayback Machine cached version'
complete -c buku -l colors -r --description 'set output colors in 5-letter string'
complete -c buku -s d -l delete --description 'delete bookmark'
complete -c buku -l deep --description 'search matching substrings'
complete -c buku -s e -l export -r --description 'export bookmarks'
complete -c buku -l expand -r --description 'expand a tny.im shortened URL'
complete -c buku -s f -l format -r --description 'limit fields in print and JSON output'
complete -c buku -s h -l help --description 'show help'
complete -c buku -s i -l import -r --description 'import bookmarks'
complete -c buku -l immutable -r --description 'disable title update from web'
complete -c buku -s j -l json --description 'show JSON output for print and search'
complete -c buku -s k -l unlock --description 'decrypt database'
complete -c buku -s l -l lock --description 'encrypt database'
complete -c buku -s n -l count -r --description 'results per page'
complete -c buku -l nc --description 'disable color output'
complete -c buku -l np --description 'non-interactive mode'
complete -c buku -s o -l open --description 'open bookmarks in browser'
complete -c buku -l oa --description 'browse all search results immediately'
complete -c buku -s p -l print --description 'show bookmark details'
complete -c buku -s r -l sreg -r --description 'match a regular expression'
complete -c buku -l replace -r --description 'replace a tag'
complete -c buku -s s -l sany -r --description 'match any keyword'
complete -c buku -s S -l sall -r --description 'match all keywords'
complete -c buku -l shorten -r --description 'shorten a URL using tny.im'
complete -c buku -l suggest --description 'show a list of similar tags'
complete -c buku -s t -l stag --description 'search by tag or show tags'
complete -c buku -l tacit --description 'reduce verbosity'
complete -c buku -l tag --description 'set tags, use + to append, - to remove'
complete -c buku -l threads -r --description 'max connections for full refresh'
complete -c buku -l title --description 'set custom title'
complete -c buku -s u -l update --description 'update bookmark'
complete -c buku -l url -r --description 'set url'
complete -c buku -s V --description 'check latest upstream release'
complete -c buku -s v -l version --description 'show program version'
complete -c buku -s w -l write --description 'open editor'
complete -c buku -s x -l exclude -r --description 'exclude keywords'
complete -c buku -s z -l debug --description 'enable debugging mode'

6
dot_config/fish/config.fish.tmpl

@ -77,15 +77,19 @@ end
abbr ab "abbr"
abbr abe "abbr -e"
# abbr rfc "chezmoi apply && source ~/.config/fish/config.fish"
abbr xf "fish_config"
abbr f. "cd .."
abbr f.. "cd ../.."
abbr hsm "history merge"
abbr xf "fish_config"
# ]]] fish-specific #
# fxn abbr's [[[ #
abbr ! "sudo !!"
abbr ag "grep-aliases"
abbr bf "buku-fzf"
abbr bff "buku-fzf fq"
abbr bq "benq-brightness"
abbr cpc "copy cat"
abbr cpe "copy echo"

12
dot_config/fish/functions/buku-fzf.fish

@ -0,0 +1,12 @@
function buku-fzf
# buku -p -f 5 | awk -F '\t' 'BEGIN { OFS=FS }; { $2=substr($2, 1, 90); print }' | column -t -s (printf '\t') | fzf --multi | awk '{ print $1 }'
if test $argv[1] = "fq"
set ids (buku -t fq -f4 | awk -F '\t' 'BEGIN { OFS=FS }; { sub(/https?:\/\/(www\.)?/, "", $2); $2=substr($2, 1, 45); $3=substr($3, 1, 50); print }' | column -t -s (printf '\t') | fzf --multi --tiebreak end | awk '{ print $1 }')
else
set ids (buku -p -f4 | awk -F '\t' 'BEGIN { OFS=FS }; { sub(/https?:\/\/(www\.)?/, "", $2); $2=substr($2, 1, 45); $3=substr($3, 1, 45); print }' | column -t -s (printf '\t') | fzf --multi --tiebreak end | awk '{ print $1 }')
end
for id in $ids
buku -o $id
end
end

7
dot_config/fish/functions/sudo.fish

@ -0,0 +1,7 @@
function sudo
if test "$argv" = !!
eval command sudo $history[1]
else
command sudo $argv
end
end

18
dot_config/i3/config.tmpl

@ -33,7 +33,8 @@ bindsym Control+Shift+Return exec st -A1
bindsym Control+$mod+Return exec $term_alt
# bindsym Control+$mod+Return exec st
# PROTIP: You can also dynamically set dmenu's colors this way:
bindsym Mod4+Return exec dmenu_run -nb "$fg" -nf "$bg" -sb "$bg" -sf "$fg"
bindsym Mod4+Return exec /home/kevin/scripts/dmenu-history -nb "$fg" -nf "$bg" -sb "$bg" -sf "$fg"
# bindsym Mod4+Return exec dmenu_run -nb "$fg" -nf "$bg" -sb "$bg" -sf "$fg"
# bindsym Mod4+Return exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
@ -255,7 +256,7 @@ set $make_st_script "/home/kevin/st/make-st.sh"
bindsym Control+$mod+q exec wal -i $($scripts_path/shuffler "$HOME/Pictures/Backgrounds/bright/editing") && $make_st_script
bindsym Control+$mod+w exec wal -i $($scripts_path/shuffler "$HOME/Pictures/Backgrounds/dim/non-editing") && $make_st_script
bindsym Control+r exec wal -i $($scripts_path/shuffler "$HOME/Pictures/Backgrounds/dim/editing") && $make_st_script
bindsym $mod+r exec wal -i $($scripts_path/shuffler "$HOME/Pictures/Backgrounds/dim/editing") && $make_st_script
bindsym Control+$mod+y exec wal -i $($scripts_path/shuffler "$HOME/Pictures/Backgrounds/bright/non-editing") && $make_st_script
{{ if eq .chezmoi.fullHostname "x1-carbon" }}
bindsym Control+$mod+z exec feh --bg-fill ~/Pictures/Backgrounds/dim/black.jpg
@ -295,8 +296,8 @@ workspace $ws5 output $secondary
assign [class="Steam"] $ws5
bindsym $mod+F5 workspace $ws5; exec $browser
# bindsym Mod4+g workspace $ws5; layout stacking; exec urxvt -e steam
# bindsym Mod4+g workspace $ws5; layout tabbed; exec gimp
bindsym Mod4+g workspace $ws5; exec mgba-qt
bindsym Mod4+g workspace $ws5; layout tabbed; exec gimp
# bindsym Mod4+g workspace $ws5; exec mgba-qt
bindsym Mod4+i workspace $ws5; exec idea
bindsym Mod4+m workspace $ws5; layout tabbed; exec urxvt -e ~/.minetest/minetest/bin/minetest
bindsym Mod4+t workspace $ws5; exec thunderbird
@ -312,7 +313,8 @@ for_window [class="ada-mario"] move absolute position 640 0
set $ws6 "6 "
workspace $ws6 output $secondary
assign [class="Slack"] $ws6
bindsym Mod4+d workspace $ws6; exec discord
# bindsym Mod4+d workspace $ws6; exec discord
bindsym Mod4+d workspace $ws6; exec riot-desktop
# bindsym Mod4+i workspace $ws6; exec firefox -new-window https://riot.im/app/#/home
bindsym Mod4+k workspace $ws6; exec slack
@ -526,13 +528,17 @@ bindsym Control+d exec ~/linux-config/scripts/change-sink dac
bindsym Control+o exec ~/linux-config/scripts/change-sink line-out
# media
# fn key [[[ #
bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks
bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks
bindsym XF86AudioPlay exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
bindsym XF86AudioStop exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
# bindsym XF86AudioStop exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
bindsym XF86AudioPrev exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
bindsym XF86AudioNext exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
# ]]] fn key #
# ]]] media keys #
# vim: fdm=marker ft=i3.go-template

19
dot_vimrc.tmpl

@ -29,7 +29,8 @@ set tabstop=4
" set timeoutlen=350
set timeoutlen=200
" set tw=80
set tw=75
" set tw=75
set tw=70
set undodir=~/.vim/undo
set undofile
" set updatetime=1000
@ -62,7 +63,7 @@ autocmd FileType *css,htmldjango,html,javascript,json,lisp,markdown,tex,text,yam
" autocmd Filetype html set foldmarker=0
autocmd BufNewFile,BufRead *.gd set expandtab!
autocmd Filetype go set expandtab! sw=4
autocmd Filetype markdown set commentstring=<!---\ %s\ -->
" autocmd Filetype markdown set commentstring=<!---\ %s\ -->
autocmd Filetype markdown map <F8> :LivedownToggle<CR>
autocmd Filetype markdown nnoremap <Tab> <Esc>>>A
autocmd Filetype markdown inoremap <S-Tab> <Esc><<A
@ -258,7 +259,10 @@ Plug 'terryma/vim-multiple-cursors'
let g:multi_cursor_exit_from_visual_mode=0
let g:multi_cursor_exit_from_insert_mode=0
Plug 'dag/vim-fish'
Plug 'shime/vim-livedown'
" live preview Markdown"
" Plug 'shime/vim-livedown'
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
" git helper
Plug 'tpope/vim-fugitive'
" auto reload file
Plug 'djoshea/vim-autoread'
@ -298,6 +302,11 @@ Plug 'christoomey/vim-tmux-navigator'
" nnoremap <C-Right> :TmuxNavigateRight<cr>
" ]]] mappings "
" highlight multiple words
" TODO: mapping conflicts "
" Plug 'inkarkat/vim-mark'
" Plug 'jceb/vim-orgmode'
" let g:org_todo_keywords=['TODO', 'STARTED', '|', 'DONE']
" ]]] vim-plug "
" Mappings [[[ "
@ -409,9 +418,11 @@ nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
" replace in line
nnoremap <leader>rl q:i.s///g<left><left><left>
" replace in visual selection
vnoremap <leader>r q:is///g<ESC>3ha
" remove italics tags
nnoremap <leader>rmi :%s/<\/\?i>//g<CR>
" reload vim config
nnoremap <leader>rv :source $MYVIMRC<CR>
vnoremap <leader>r q:is///g<ESC>3ha
" replace in entire file
nnoremap <leader>R q:i%s///g<ESC>2F/i
vnoremap <leader>s :sort<CR>

50
scripts/executable_dmenu-history

@ -0,0 +1,50 @@
#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run
historyfile=$cachedir/dmenu_history
else # if no xdg dir, fall back to dotfiles in ~
cache=$HOME/.dmenu_cache
historyfile=$HOME/.dmenu_history
fi
IFS=:
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u > "$cache"
fi
unset IFS
awk -v histfile=$historyfile '
BEGIN {
while( (getline < histfile) > 0 ) {
sub("^[0-9]+\t","")
print
x[$0]=1
}
} !x[$0]++ ' "$cache" \
| dmenu "$@" \
| awk -v histfile=$historyfile '
BEGIN {
FS=OFS="\t"
while ( (getline < histfile) > 0 ) {
count=$1
sub("^[0-9]+\t","")
fname=$0
history[fname]=count
}
close(histfile)
}
{
history[$0]++
print
}
END {
if(!NR) exit
for (f in history)
print history[f],f | "sort -t '\t' -k1rn >" histfile
}
' \
| while read cmd; do ${SHELL:-"/bin/sh"} -c "$cmd" & done
Loading…
Cancel
Save