From e51c007a78fdba8ce39b4228087fd097596dbd6f Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 27 Mar 2019 18:49:16 -0400 Subject: [PATCH] Temperature i3block, 369-a4 functions Update git-add to add all changes instead of just current dir. --- aliases/key_aliases | 18 ++--- fish/.config/fish/config.fish | 3 +- .../fish/functions/369/a4/mount-image.fish | 3 + .../fish/functions/369/a4/revert-image.fish | 15 ++++ .../.config/fish/functions/369/a4/run-a4.fish | 8 ++- .../fish/functions/create-fish-function.fish | 2 +- fish/.config/fish/functions/grep-pdf.fish | 3 + i3blocks/.config/i3blocks/i3blocks.conf | 4 ++ i3blocks/.config/i3blocks/scripts/temperature | 72 ++----------------- txt/key_dirs.txt | 1 + txt/key_files.txt | 2 +- vim/.vimrc | 11 +-- 12 files changed, 58 insertions(+), 84 deletions(-) create mode 100644 fish/.config/fish/functions/369/a4/mount-image.fish create mode 100755 fish/.config/fish/functions/369/a4/revert-image.fish create mode 100644 fish/.config/fish/functions/grep-pdf.fish diff --git a/aliases/key_aliases b/aliases/key_aliases index bc8bb45..103a2a6 100644 --- a/aliases/key_aliases +++ b/aliases/key_aliases @@ -24,7 +24,7 @@ ba "bat *" grep "grep --color=auto -n" grr "grep -r" # pk "pkill -f" -cld "colordiff -y --suppress-common-lines" +cld "colordiff -wy --suppress-common-lines" mkpk "makepkg -sri" ex "chmod 777" @@ -234,11 +234,11 @@ gro "git remote show origin" # add/remove {{{ # -ga "git add -A . && git status -u" -gac "git add -A . && git commit -S" +ga "git add -A && git status -u" +gac "git add -A && git commit -S" gaf "git add -f" # unsigned commt -gacu "git add -A . && git commit" +gacu "git add -A && git commit" grm "git rm" grmf "git rm -f" @@ -276,11 +276,11 @@ gstp "git stash pop" gc "git commit -S" gcu "git commit" -gca "git add -A . && git commit --amend --no-edit -S" -gcam "git add -A . && git commit --amend -S" -# gcamp "git add -A . && git commit --amend --no-edit -S && gpsf" +gca "git add -A && git commit --amend --no-edit -S" +gcam "git add -A && git commit --amend -S" +# gcamp "git add -A && git commit --amend --no-edit -S && gpsf" -psgi "git add . && git commit -m 'Update' -S && git push" +psgi "git add -A && git commit -m 'Update' -S && git push" gps "git push" gpsi "git config credential.helper store && git push" # gpsn "git push --set-upstream origin master" @@ -393,6 +393,8 @@ rms "rm swapfile.*" wl6 "watson log --all --project=369 --tag=a4" wr6 "watson report --all --project=369 --tag=a4" +um6 "sudo umount /mnt/369-a4" + # a2 {{{ # mcr "bear make clean && printf '\033c' && bear make && ./carsim light 1 20" diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish index 7edccb3..061caf7 100644 --- a/fish/.config/fish/config.fish +++ b/fish/.config/fish/config.fish @@ -32,7 +32,7 @@ abbr rfs "sync-shortcuts && source ~/.config/fish/config.fish" abbr xf "fish_config" abbr f. "cd .." abbr f.. "cd ../.." -abbr mt "math ''" +abbr mt "math" # }}} fish-specific # @@ -76,6 +76,7 @@ abbr grmb "git-delete-branch" # }}} git # abbr hs "scan-history" abbr hst "$EDITOR ~/.local/share/fish/fish_history" +abbr pgr "grep-pdf" abbr ut "unix-timestamp" abbr uzr "unzip-rm" diff --git a/fish/.config/fish/functions/369/a4/mount-image.fish b/fish/.config/fish/functions/369/a4/mount-image.fish new file mode 100644 index 0000000..75d7457 --- /dev/null +++ b/fish/.config/fish/functions/369/a4/mount-image.fish @@ -0,0 +1,3 @@ +function mount-image + sudo mount $argv[1] /mnt/369-a4 +end diff --git a/fish/.config/fish/functions/369/a4/revert-image.fish b/fish/.config/fish/functions/369/a4/revert-image.fish new file mode 100755 index 0000000..376a9a5 --- /dev/null +++ b/fish/.config/fish/functions/369/a4/revert-image.fish @@ -0,0 +1,15 @@ +function revert-image + set img_file 'emptydisk.img' + switch $argv[1] + case 1 + set img_file 'onefile.img' + case m + set img_file 'multilevel.img' + case l + set img_file 'largefile.img' + case s + set img_file 'symlink.img' + end + + cp imgs{-cp,}/$img_file +end diff --git a/fish/.config/fish/functions/369/a4/run-a4.fish b/fish/.config/fish/functions/369/a4/run-a4.fish index a1bf6ac..a3d1a7f 100644 --- a/fish/.config/fish/functions/369/a4/run-a4.fish +++ b/fish/.config/fish/functions/369/a4/run-a4.fish @@ -12,17 +12,23 @@ function run-a4 set img_file 'imgs/multilevel.img' case l set img_file 'imgs/largefile.img' + case s + set img_file 'imgs/symlink.img' end switch $argv[1] case h - ./ext2_helpers_tester 'imgs/multilevel.img' '/level1/level2/bfile' + ./ext2_helpers_tester $img_file case hg gdb -ex "run" -ex "bt" -ex "q" \ --args ./ext2_helpers_tester './imgs/multilevel.img' '/level1/level2/level3//' case m ./ext2_mkdir $img_file '/' # ./ext2_mkdir 'imgs/multilevel.img' '/level1/level2/bfile' + case rg + ./readimage $img_file + gdb -ex "run" -ex "bt" -ex "q" \ + --args ./readimage './imgs/symlink.img' case '*' ./readimage $img_file end diff --git a/fish/.config/fish/functions/create-fish-function.fish b/fish/.config/fish/functions/create-fish-function.fish index 8de1eac..91d1576 100644 --- a/fish/.config/fish/functions/create-fish-function.fish +++ b/fish/.config/fish/functions/create-fish-function.fish @@ -1,5 +1,5 @@ function create-fish-function - printf 'function %s\n \nend' $argv[1] > $fish_fxn_dir/$argv[1].fish + printf 'function %s\nend' $argv[1] > $fish_fxn_dir/$argv[1].fish and cd $fish_fxn_dir and $EDITOR $argv[1].fish end diff --git a/fish/.config/fish/functions/grep-pdf.fish b/fish/.config/fish/functions/grep-pdf.fish new file mode 100644 index 0000000..d5538f1 --- /dev/null +++ b/fish/.config/fish/functions/grep-pdf.fish @@ -0,0 +1,3 @@ +function grep-pdf + pdfgrep -n $argv[1] -B $argv[2] -A $argv[3] (fd -e pdf --no-ignore-vcs) +end diff --git a/i3blocks/.config/i3blocks/i3blocks.conf b/i3blocks/.config/i3blocks/i3blocks.conf index 441933f..b4e866f 100644 --- a/i3blocks/.config/i3blocks/i3blocks.conf +++ b/i3blocks/.config/i3blocks/i3blocks.conf @@ -39,6 +39,10 @@ WIDTH=220 # interval=5 # color=#990000 +[temperature] +label= +interval=5 + # [cpu_usage -w 50 -c 80] [cpu_usage] label= diff --git a/i3blocks/.config/i3blocks/scripts/temperature b/i3blocks/.config/i3blocks/scripts/temperature index ad745c3..e436e98 100755 --- a/i3blocks/.config/i3blocks/scripts/temperature +++ b/i3blocks/.config/i3blocks/scripts/temperature @@ -1,69 +1,7 @@ -#!/usr/bin/perl -# Copyright 2014 Pierre Mavro -# Copyright 2014 Vivien Didelot -# Copyright 2014 Andreas Guldstrand -# Copyright 2014 Benjamin Chretien +#!/bin/bash -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +. "/home/kevin/.cache/wal/colors.sh" -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -use warnings; -use utf8; -use Getopt::Long; - -binmode(STDOUT, ":utf8"); - -# default values -my $t_warn = 70; -my $t_crit = 90; -my $chip = ""; -my $temperature = -9999; - -sub help { - print "Usage: temperature [-w ] [-c ] [--chip ]\n"; - print "-w : warning threshold to become yellow\n"; - print "-c : critical threshold to become red\n"; - print "--chip : sensor chip\n"; - exit 0; -} - -GetOptions("help|h" => \&help, - "w=i" => \$t_warn, - "c=i" => \$t_crit, - "chip=s" => \$chip); - -# Get chip temperature -open (SENSORS, "sensors -u $chip |") or die; -while () { - if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { - $temperature = $1; - last; - } -} -close(SENSORS); - -$temperature eq -9999 and die 'Cannot find temperature'; - -# Print short_text, full_text -print "$temperature°C\n" x2; - -# Print color, if needed -if ($temperature >= $t_crit) { - print "#FF0000\n"; - exit 33; -} elsif ($temperature >= $t_warn) { - print "#FFFC00\n"; -} - -exit 0; +temps="$(sensors | rg 'temp1:.*' | awk '{ print $2 }' | rg -o '\d{2}' | \ + sed 's/$/°C/' | tr '\n' ' ' | xargs)" +printf "%s\n\n%s\n" "$temps" "$color7" diff --git a/txt/key_dirs.txt b/txt/key_dirs.txt index f935c0f..3882f24 100644 --- a/txt/key_dirs.txt +++ b/txt/key_dirs.txt @@ -54,6 +54,7 @@ e3 /home/kevin/school/309/e3 # 369 6 /home/kevin/school/369 6l /home/kevin/school/369/notes/lectures +6m /mnt/369-a4 6f /home/kevin/linux-config/fish/.config/fish/functions/369/a3 a4d /home/kevin/school/369/a4/a4 diff --git a/txt/key_files.txt b/txt/key_files.txt index ea2f644..8b9aa5b 100644 --- a/txt/key_files.txt +++ b/txt/key_files.txt @@ -32,7 +32,7 @@ ne /home/kevin/linux-config/configs/neofetch/config.conf re README.md td todo.md tm /home/kevin/.vim/plugged/vim-snippets/UltiSnips/texmath.snippets -wh /home/kevin/Documents/journal/work-habit.md +wh /home/kevin/Documents/journal/todo/work-habit.md wt /home/kevin/.config/watson/state.tmp # }}} cdn * diff --git a/vim/.vimrc b/vim/.vimrc index f3d71fa..e29625d 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -247,7 +247,6 @@ nnoremap | " leader mappings {{{ " let mapleader="\" -" let maplocalleader="-" " find alias nnoremap a /^ @@ -281,6 +280,10 @@ nnoremap h :set hlsearch! hlsearch? nnoremap he :help nnoremap ht :set tabstop=2 shiftwidth=2 expandtab nnoremap vhe :vert help +" format current line +nnoremap l Vgq +" format this and next line +nnoremap ll Vjgq " move cursor to middle of line nnoremap m :call cursor(0, len(getline('.'))/2) " apply normal command to selection @@ -319,10 +322,6 @@ nnoremap sys :set syn=sh vnoremap t :!tac " open vimrc in vertical split nnoremap vv :vsp ~/.vimrc -" format current line -nnoremap ww Vgq -" format this and next line -nnoremap www Vjgq " copy next thing to system clipboard " nnoremap y "+ " nnoremap Y "+Y @@ -380,6 +379,8 @@ autocmd Filetype tex inoremap tx $t(x)$ autocmd Filetype c inoremap uc unsigned char +autocmd BufNewFile,BufRead *.h nnoremap x 0iextern f{hc$; + autocmd Filetype fish inoremap 1 $argv[1] autocmd Filetype fish inoremap 2 $argv[2]