From 3b9743fd4f04d6cc529acd467d135df661b2e644 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Sun, 17 Mar 2019 03:03:24 -0400 Subject: [PATCH] Update 369-a3 functions --- aliases/key_aliases | 33 +++++++++------ fish/.config/fish/config.fish | 17 ++++---- .../fish/functions/369/a3/gdb-a3-break.fish | 20 +++++++-- .../.config/fish/functions/369/a3/run-a3.fish | 41 ++++++++++++++----- .../fish/functions/revert-e3-json.fish | 3 ++ fish/.config/fish/functions/unzip-rm.fish | 4 ++ .../fish/functions/zathura-silent.fish | 3 -- i3/.config/i3/config | 6 ++- ranger/.config/ranger/scope.sh | 21 ++++++---- txt/key_dirs.txt | 6 ++- vim/.vimrc | 35 ++++++++++------ 11 files changed, 130 insertions(+), 59 deletions(-) create mode 100644 fish/.config/fish/functions/revert-e3-json.fish create mode 100644 fish/.config/fish/functions/unzip-rm.fish delete mode 100644 fish/.config/fish/functions/zathura-silent.fish diff --git a/aliases/key_aliases b/aliases/key_aliases index d34f61e..7c1a4ca 100644 --- a/aliases/key_aliases +++ b/aliases/key_aliases @@ -1,4 +1,5 @@ # system {{{ # +# vim: fdm=marker # clear screen c "printf '\033c'" @@ -8,8 +9,8 @@ fi "fish" # reload urxvt ru "xrdb ~/.Xresources" # list file sizes in megabytes with depth 1 -duh "sudo du -d 1 -h" -dum "sudo du -d 1 -m" +duh "sudo du -d 1 -ah | sort -hr" +dum "sudo du -d 1 -am | sort -hr" m "man" tl "tldr" @@ -18,8 +19,8 @@ nvt "nvidia-settings --assign CurrentMetaMode='DVI-I-1: nvidia-auto-select +0+0 vgb "sudo nvim /etc/default/grub" mkgb "sudo grub-mkconfig -o /boot/grub/grub.cfg" -bt "bat" -bta "bat *" +b "bat" +ba "bat *" grep "grep --color=auto -n" grr "grep -r" # pk "pkill -f" @@ -50,7 +51,7 @@ udmb "udisksctl mount -b /dev/sdc2" udu "udisksctl unmount -b" udub "udisksctl unmount -b /dev/sdc2" -to "touch" +tc "touch" # directory-related {{{ # ls "lsd" @@ -81,8 +82,9 @@ nbu "cd /run/media/kevin/backup-hd/nzxt/tar && lsd -l" # power options {{{ # s "systemctl suspend" -sd "sudo shutdown 0" -rb "sudo shutdown -r 0" +so "xset dpms force off" +sd "systemctl poweroff" +rb "systemctl reboot" lo "i3-msg exit" x "xmodmap ~/.Xmodmap && xset r rate $XSET_DELAY $XSET_RATE" X "xmodmap ~/.Xmodmap && xset r rate $XSET_DELAY $XSET_RATE" @@ -126,8 +128,8 @@ id "identify" # config files {{{ # rf "source ~/.config/fish/config.fish" +srf "sync-shortcuts && source ~/.config/fish/config.fish" rz "source ~/linux-config/aliases/zsh_aliases" -lca "f ~/linux-config/aliases" pipes "pipes.sh -t 3" @@ -159,6 +161,9 @@ sx "sxiv" sxa "sxiv -a" wg "wego" wp "grep wallpaper ~/.cache/wal/colors.sh" +z "zathura --fork" + +lz "unzip -l" # rsl "java -jar ~/Downloads/RuneLite.jar" # swex "sudo nohup ~/Downloads/swex.appimage $silent" @@ -233,12 +238,12 @@ grmfc "git rm -f --cached" # }}} add # # diff/log {{{ # -gd "git diff -w" -gdc "git diff --cached -w" +gd "git difftool -w --tool=vimdiff" +gdc "git difftool -w --cached --tool=vimdiff" +gdl "git diff -w" +gdlc "git diff --cached -w" gdh "git diff --cached -w HEAD~1" gds "git diff --stat" -gdv "git difftool -w --tool=vimdiff" -gdvc "git difftool -w --cached --tool=vimdiff" gl "git log" gsl "git shortlog" # }}} diff/log # @@ -298,6 +303,8 @@ gunc "git update-index --assume-unchanged" # coding projs {{{ # # coding_dir="~/coding" +rgt "rg TODO" + # trapbot {{{ # # tb "$cd_coding_dir/trapbot" # vtb "$cd_coding_dir/trapbot && ni scan_reddit.py" @@ -397,4 +404,6 @@ hl "valgrind --tool=helgrind ./carsim light 10 20" wl0 "watson log --all --project=309 --tag=project" wr0 "watson report --all --project=309 --tag=project" +e3t "node test-app.js" + # }}} school # diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish index e1c6270..9b47c98 100644 --- a/fish/.config/fish/config.fish +++ b/fish/.config/fish/config.fish @@ -48,6 +48,7 @@ abbr ag "grep-aliases" abbr bq "benq-brightness" abbr cpc "copy cat" abbr cpe "copy echo" +abbr cpp "copy echo (pwd)" abbr cff "create-fish-function" abbr ev "evince-silent" # git {{{ # @@ -62,19 +63,21 @@ abbr grmb "git-delete-branch" abbr hs "scan-history" abbr hst "$EDITOR ~/.local/share/fish/fish_history" abbr ut "unix-timestamp" -abbr z "zathura-silent" +abbr uzr "unzip-rm" set -U BROWSER "chromium" abbr hm "cd $mfs_dir && hugo serve -D --disableFastRender" +# 309 +abbr r0t "revert-e3-json restaurants" +abbr r0s "revert-e3-json reservations" + # 369 abbr grc "grep-c" abbr grh "grep-headers" abbr rgh "rg-headers" -abbr r6 "run-a3 c lru" -abbr r6o "run-a3 c lru o" -abbr g6b "gdb-a3-break c lru" - -# abbr cs "carsim" -# abbr ga2 "gdb-a2" +abbr r6 "run-a3 f d o" +abbr r6g "run-a3 f d g" +abbr r6s "run-a3 s c o" +abbr g6 "source $fish_fxn_dir/369/a3/gdb-a3-break.fish && gdb-a3-break c c" diff --git a/fish/.config/fish/functions/369/a3/gdb-a3-break.fish b/fish/.config/fish/functions/369/a3/gdb-a3-break.fish index c2be459..fc24a17 100644 --- a/fish/.config/fish/functions/369/a3/gdb-a3-break.fish +++ b/fish/.config/fish/functions/369/a3/gdb-a3-break.fish @@ -1,7 +1,7 @@ function gdb-a3-break # 1 = trace file, 2 = alg set trace_file 'traceprogs/tr-custom.ref' - set memsize 1 + set memsize 3 set swapsize 10 if test $argv[1] = 's' set trace_file 'traceprogs/tr-simpleloop.ref' @@ -9,10 +9,22 @@ function gdb-a3-break set swapsize 3000 end + set alg 'rand' + switch $argv[2] + case f + set alg 'fifo' + case l + set alg 'lru' + case c + set alg 'clock' + end + printf '\033c' and bear make - and gdb -ex "b pagetable.c:69" \ - # -ex "b lru.c:65" \ + and gdb \ + # -ex "b pagetable.c:69" \ + # -ex "b sim.c:158" \ + -ex "b clock.c:29" \ -ex "run" \ - --args ./sim -f $trace_file -m $memsize -s $swapsize -a $argv[2] + --args ./sim -f $trace_file -m $memsize -s $swapsize -a $alg end diff --git a/fish/.config/fish/functions/369/a3/run-a3.fish b/fish/.config/fish/functions/369/a3/run-a3.fish index 302a9ff..370e202 100644 --- a/fish/.config/fish/functions/369/a3/run-a3.fish +++ b/fish/.config/fish/functions/369/a3/run-a3.fish @@ -1,13 +1,32 @@ function run-a3 - # 1 = trace file, 2 = alg, 3 = output + # 1 = alg, 2 = trace file, 3 = output - set trace_file 'traceprogs/tr-custom.ref' set memsize 3 set swapsize 10 - if test $argv[1] = 's' - set trace_file 'traceprogs/tr-simpleloop.ref' - set memsize 50 - set swapsize 3000 + set alg 'rand' + switch $argv[1] + case f + set alg 'fifo' + set trace_file 'traceprogs/tr-fifo.ref' + case l + set alg 'lru' + set trace_file 'traceprogs/tr-lru.ref' + case c + set alg 'clock' + set trace_file 'traceprogs/tr-clock.ref' + end + + switch $argv[2] + case c + set trace_file 'traceprogs/tr-custom.ref' + case s + set trace_file 'traceprogs/tr-simpleloop.ref' + set memsize 50 + set swapsize 3000 + case m + set trace_file 'traceprogs/tr-matmul.ref' + set memsize 100 + set swapsize 3000 end printf '\033c' @@ -16,13 +35,15 @@ function run-a3 switch $argv[3] case f - ./sim -f $trace_file -m $memsize -s $swapsize -a $argv[2] > a3.out 2>&1 + ./sim -f $trace_file -m $memsize -s $swapsize -a $alg > a3.out 2>&1 case g gdb -ex "run" -ex "bt" -ex "q" \ - --args ./sim -f $trace_file -m $memsize -s $swapsize -a $argv[2] + --args ./sim -f $trace_file -m $memsize -s $swapsize -a $alg case o - ./sim -f $trace_file -m $memsize -s $swapsize -a $argv[2] + ./sim -f $trace_file -m $memsize -s $swapsize -a $alg end - # rm swapfile.* + if test (count swapfile.*) -gt 0 + rm swapfile.* + end end diff --git a/fish/.config/fish/functions/revert-e3-json.fish b/fish/.config/fish/functions/revert-e3-json.fish new file mode 100644 index 0000000..bf372b7 --- /dev/null +++ b/fish/.config/fish/functions/revert-e3-json.fish @@ -0,0 +1,3 @@ +function revert-e3-json + cp $argv[1]_example.json $argv[1].json +end diff --git a/fish/.config/fish/functions/unzip-rm.fish b/fish/.config/fish/functions/unzip-rm.fish new file mode 100644 index 0000000..e4cd964 --- /dev/null +++ b/fish/.config/fish/functions/unzip-rm.fish @@ -0,0 +1,4 @@ +function unzip-rm + unzip $argv[1] + and rm $argv[1] +end diff --git a/fish/.config/fish/functions/zathura-silent.fish b/fish/.config/fish/functions/zathura-silent.fish deleted file mode 100644 index d1d0f3b..0000000 --- a/fish/.config/fish/functions/zathura-silent.fish +++ /dev/null @@ -1,3 +0,0 @@ -function zathura-silent - zathura $argv[1] > /dev/null 2>&1& -end diff --git a/i3/.config/i3/config b/i3/.config/i3/config index b97582d..293cca8 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -1,4 +1,5 @@ # startup {{{ # +# vim: fdm=marker set $browser "firefox" # set $browser "chromium" set $def_term "urxvt" @@ -46,8 +47,8 @@ bindsym Mod4+p exec passmenu bindsym Mod4+q exec qdirstat bindsym Mod4+r exec urxvt -e ranger bindsym Mod4+$mod+r exec notify-send "watson restart" "$(watson restart)" -# bindsym control+$mod+s exec systemctl suspend bindsym control+$mod+s exec systemctl suspend +bindsym Mod4+$mod+s exec xset dpms force off # bindsym Mod4+t exec st bindsym Mod4+t exec xclip -selection clipboard ~/.password-store/social/trapbot bindsym Mod4+u exec echo 'kevin.mok@mail.utoronto.ca' | xclip -selection clipboard @@ -140,9 +141,11 @@ bindsym $mod+Shift+Right move right # split in horizontal orientation bindsym $mod+b split h +bindsym Mod4+$mod+b split h; exec $def_term # split in vertical orientation bindsym $mod+v split v +bindsym Mod4+$mod+v split v; exec $def_term # bindsym control+Shift+x kill bindsym shift+x kill @@ -326,7 +329,6 @@ bindsym $mod+Shift+5 move container to workspace $ws15; workspace $ws15 # reload config/computer {{{ # -bindsym $mod+Shift+s exec systemctl suspend # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # bindsym $mod+control+r exec ~/.cache/wal/colors.sh; restart bindsym $mod+control+r exec i3-msg restart diff --git a/ranger/.config/ranger/scope.sh b/ranger/.config/ranger/scope.sh index ce8ac5e..e892853 100755 --- a/ranger/.config/ranger/scope.sh +++ b/ranger/.config/ranger/scope.sh @@ -90,6 +90,11 @@ handle_extension() { # lynx -dump -- "${FILE_PATH}" && exit 5 # elinks -dump "${FILE_PATH}" && exit 5 # ;; # Continue with next handler on failure + + # JSON + json) + jq --color-output . "${FILE_PATH}" && exit 5 + python -m json.tool -- "${FILE_PATH}" && exit 5 esac } @@ -179,13 +184,15 @@ handle_mime() { if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then exit 2 fi - if [[ "$( tput colors )" -ge 256 ]]; then - local pygmentize_format='terminal256' - local highlight_format='xterm256' - else - local pygmentize_format='terminal' - local highlight_format='ansi' - fi + if [[ "$( tput colors )" -ge 256 ]]; then + local pygmentize_format='terminal256' + local highlight_format='xterm256' + else + local pygmentize_format='terminal' + local highlight_format='ansi' + fi + # local pygmentize_format='terminal' + # local highlight_format='ansi' highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \ --style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5 # pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5 diff --git a/txt/key_dirs.txt b/txt/key_dirs.txt index 91d48f8..525a186 100644 --- a/txt/key_dirs.txt +++ b/txt/key_dirs.txt @@ -1,4 +1,5 @@ # sys {{{ * +# vim: fdm=marker bg /home/kevin/Pictures/Backgrounds cf /home/kevin/.config @@ -46,13 +47,14 @@ wo /home/kevin/Documents/workout-logs/11 sc /home/kevin/school 0c /home/kevin/school/309-proj/css 0d /home/kevin/school/309 +0l /home/kevin/school/309/l 0p /home/kevin/school/309-proj -e2 /home/kevin/school/309/e2 +e3 /home/kevin/school/309/e3 # 369 6 /home/kevin/school/369 +6f /home/kevin/linux-config/fish/.config/fish/functions/369/a3 a3 /home/kevin/school/369/a3/a3 -a3f /home/kevin/linux-config/fish/.config/fish/functions/369/a3 hp /home/kevin/school/hps lt /home/kevin/school/latex-notes diff --git a/vim/.vimrc b/vim/.vimrc index 1a74f7e..907914c 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -16,6 +16,7 @@ set autoindent set mouse=a set clipboard+=unnamedplus set foldmethod=marker +" set foldmethod=indent set linespace=5 " cursor indicator {{{ " @@ -46,7 +47,15 @@ autocmd BufNewFile,BufRead *.txt set tabstop=2 shiftwidth=2 expandtab autocmd BufNewFile,BufRead *.md set filetype=markdown autocmd Filetype markdown set textwidth=0 " autocmd Filetype html set foldmarker=0 -autocmd VimLeave *.tex !tex-clean % + +autocmd Filetype markdown map :LivedownToggle +autocmd Filetype json nnoremap j :%!python -m json.tool +autocmd Filetype json set foldmethod=marker +autocmd FileType sh map :!clear && shellcheck % +" autocmd FileType tex map :VimtexCompile:VimtexView +autocmd VimEnter *.tex VimtexCompile +autocmd VimLeave *.tex !tex-clean %:p +" map :VimtexCompile " " auto-reload vimrc {{{ " @@ -66,6 +75,10 @@ autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72 " autocmd BufWritePost key_* !sync-shortcuts autocmd BufNewFile,BufRead key_* map :silent !sync-shortcuts +" map :silent !scp %:p k@192.168.0.17:/home/k/a1 +" map :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1 +" map :make -C ~/Documents/resume cv + " }}} commands for specific files " " vim-plug {{{ " @@ -97,10 +110,11 @@ Plug 'vim-scripts/L9' " automatically save buffers upon returning to normal mode Plug '907th/vim-auto-save' let g:auto_save = 1 + autocmd VimEnter *.tex let g:auto_save = 0 " provides various functionality for writing LaTeX in Vim Plug 'lervag/vimtex' - au BufWritePost *.tex silent call Tex_RunLaTeX() + " au BufWritePost *.tex silent call Tex_RunLaTeX() au BufWritePost *.tex silent !pkill -USR1 xdvi.bin let g:vimtex_view_general_viewer = 'zathura' let g:vimtex_quickfix_latexlog = { @@ -199,18 +213,12 @@ colorscheme wal " Mappings {{{ " " function keys {{{ " -" map :silent !scp %:p k@192.168.0.17:/home/k/a1 -" map :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1 +map :wa map :xa map :q! map :qa! -" map :make -C ~/Documents/resume cv -" map :AutoSaveToggle -map :!clear && shellcheck % -map :VimtexCompile:VimtexView -" map :VimtexCompile +map :AutoSaveToggle nnoremap :set paste"+p:set nopaste -map :LivedownToggle " }}} function keys " map O @@ -247,13 +255,15 @@ nnoremap f q/p " find merge conflicts nnoremap fc /[<>=\|]\{7\} " reload folds -nnoremap ff :set foldmethod=marker zM +nnoremap fmi :set foldmethod=indent zM +nnoremap fmm :set foldmethod=marker zM +" add marker foldmethod modeline nnoremap fi :YcmCompleter FixIt " find copied text nnoremap ft /TODO nnoremap g :YcmCompleter GoTo " vimdiff split -nnoremap gd :Gvdiff +nnoremap gd :Gvdiff HEAD " toggle search highlighting nnoremap h :set hlsearch! hlsearch? " help @@ -297,6 +307,7 @@ nnoremap so q:i.,$sort nnoremap sol q:i.,.+sortFsi " set syntax to shell (for dotfiles) nnoremap sys :set syn=sh +vnoremap t :!tac " open vimrc in vertical split nnoremap vv :vsp ~/.vimrc " format current line