From d1b57c1d68fa60a4a67c208f29b739ef0f20d5c5 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 3 Dec 2024 17:33:13 +0800 Subject: Update --- alias | 5 +- bin/log/shellrc | 2 +- bin/mail/append_authorized_key.sh | 2 +- bin/mail/comment.sh | 41 ++++++++++++ misc/pacman/list | 62 ++++++++++++++++++ mutt/default | 2 +- mutt/muttrc.topo | 134 +++++++++++++++++++------------------- snippets/bash_read_from_pipe | 4 ++ vim/init/highlight.vim | 2 + 9 files changed, 182 insertions(+), 72 deletions(-) create mode 100755 bin/mail/comment.sh create mode 100644 misc/pacman/list create mode 100644 snippets/bash_read_from_pipe diff --git a/alias b/alias index a117258..09f3ae1 100644 --- a/alias +++ b/alias @@ -22,7 +22,7 @@ alias zsh.sourced='zsh -o SOURCE_TRACE' # }}} # CUSTOM HELPER {{{ -cdh() { cd $SETTING_DIR/$@; } +cdh() { set -x; cd $SETTING_DIR/${*// //}; set +x; } alias chh="tig -C $SETTING_DIR status" # }}} # Text Encode/Decode{{{ @@ -51,7 +51,7 @@ alias fb='sudo fail2ban-client' # Nginx{{{ alias vgx='sudo vim /etc/nginx/sites-enabled/vps -c "autocmd BufWritePost * !nginx -t && sudo systemctl reload nginx"' alias ng.conf='sudo vim /etc/nginx/nginx.conf -c "autocmd BufWritePost * !nginx -t && sudo systemctl reload nginx"' -alias ng.log='setterm --linewrap off; tail -n 200 -f /var/log/nginx/access.log; setterm --linewrap on' +alias ng.log='setterm --linewrap off; tail -f /var/log/nginx/access.log; setterm --linewrap on' alias cdngx='cd /etc/nginx' # }}} # Web {{{ @@ -208,6 +208,7 @@ alias smtp.queue='sudo smtpctl show queue' alias smtp.show='sudo smtpctl show' alias smtp.ctl='sudo smtpctl' alias imap.conf='sudo vim /etc/dovecot/dovecot.conf' +alias cdmail='cd ~/Maildir' alias m='mutt' alias mutt.rc="$EDITOR ~/.config/mutt/muttrc" alias h='himalaya' diff --git a/bin/log/shellrc b/bin/log/shellrc index a39e291..b3c95fc 100644 --- a/bin/log/shellrc +++ b/bin/log/shellrc @@ -1,7 +1,7 @@ # about vimwiki alias cdl='cd ~/log' alias chw='tig -C ~/log' -ww() { entry="${1:-plan.context}"; vim ~/log/${entry%%.md}.md; } +ww() { entry="${1:-inbox}"; vim ~/log/${entry%%.md}.md; } wj() { echo "$@" >>~/log/buffer.md; } wg() { grep -r "$@" --color --exclude-dir={logseq,.git,.obsidian} ~/log; } wi() { cat ~/log/${1%%.md}.md; } diff --git a/bin/mail/append_authorized_key.sh b/bin/mail/append_authorized_key.sh index 950be90..3686959 100755 --- a/bin/mail/append_authorized_key.sh +++ b/bin/mail/append_authorized_key.sh @@ -13,7 +13,7 @@ MAIL="$(cat)" test -f ~/.config/passphase || exit 1 PASSPHASE="$(cat ~/.config/passphase)" -# Only execute the following script when header matched +# Check passphase, or exit 0 grep -qE "^Passphase: ${PASSPHASE}" <<<"$MAIL" || exit 0 # Append comment and last line to ~/.ssh/authorized_keys diff --git a/bin/mail/comment.sh b/bin/mail/comment.sh new file mode 100755 index 0000000..807bcb2 --- /dev/null +++ b/bin/mail/comment.sh @@ -0,0 +1,41 @@ +#! /bin/bash + +output_dir=${output_dir:-/srv/http} + +# Restore mail into variable +MAIL="$(tr -d '\r')" +headers="$(<<<"$MAIL" sed '/^$/ q')" +contents="$(<<<"$MAIL" sed -n '/^$/,$ p' | sed '1d')" + +# enable execute last command in pipe under current shell +shopt -s lastpipe; set +m; + +# get route (target page of comment) and id +<<<"$MAIL" sed -En '/^To: comment+/ {s/^To: comment\+([^+]+)\+?(.*)@.*$/\1 \2/p; q}; /^$/q' \ +| read route id + +# sender want comment on some page, but find no route for this +if [ $route = "" ]; then + echo 'rcpt "comment+" not matched' >&2 + exit 1 +fi + +output=$output_dir/${route#/}.comment +exec 1>>$output + +# check mail includes multiple part +<<<"$headers" grep '^Content-Type:.*mixed' >/dev/null +if [ $? -eq 0 ]; then + boundary="$(<<<"$headers" sed -En 's/^Content-Type:.*boundary="(.*)".*$/\1/p')" + if [ $boundary = "" ]; then + echo 'cannot get boundary from mail header' >&2 + exit 1 + fi + + # print content of first mail part + pattern="\\@^--${boundary}\$@" + <<<"$contents" sed -n "${pattern},${pattern} p" | sed -n "1,4d; ${pattern} q; p" +else + # print content + <<<"$contents" sed '/^$/,$ p' +fi diff --git a/misc/pacman/list b/misc/pacman/list new file mode 100644 index 0000000..4eeaec0 --- /dev/null +++ b/misc/pacman/list @@ -0,0 +1,62 @@ +autoconf 2.71-1 +automake 1.16.5-1 +base 2-2 +bison 3.8.2-3 +btrfs-progs 5.16.2-1 +certbot-nginx 1.26.0-1 +cronie 1.6.0-2 +discount 2.2.7-2 +docker 1:20.10.14-1 +dovecot 2.3.18-1 +fakeroot 1.28-1 +flex 2.6.4-3 +fzf 0.30.0-1 +gcc 11.2.0-4 +gd 2.3.3-3 +gdal 3.4.0-5 +git 2.35.1-1 +github-cli 2.7.0-1 +gnu-netcat 0.7.1-8 +grub 2:2.06-5 +htop 3.1.2-1 +hugo 0.96.0-1 +inetutils 2.2-1 +jq 1.6-4 +linux 5.17.1.arch1-1 +linux-firmware 20220309.cd01f85-1 +lshw B.02.19.2-4 +lsof 4.94.0-1 +m4 1.4.19-1 +make 4.3-3 +man-db 2.10.2-1 +mutt 2.2.2-1 +net-tools 2.10-1 +nginx-mainline-mod-dav-ext 3.0.0-21 +nginx-mod-headers-more 0.33-12 +openssh 8.9p1-1 +pass 1.7.4-2 +patch 2.7.6-8 +pkgconf 1.8.0-1 +pkgfile 21-2 +postfix 3.7.0-2 +ranger 1.9.3-4 +rapidjson 1.1.0-5 +s-nail 14.9.23-1 +sudo 1.9.10-1 +tig-git 2.5.4.r18.gf92286a6-1 +tiv 2015-2 +tldr 3.1.0-1 +tmux 3.2_a-1 +tree 2.0.2-1 +ufw 0.36.1-1 +unzip 6.0-18 +vim 8.2.4651-1 +viu 1.4.0-1 +wget 1.21.3-1 +which 2.21-5 +words 2.1-6 +xsel 1.2.0.20200527-1 +yay 10.3.1-2 +yq 2.14.0-1 +zip 3.0-10 +zsh 5.8.1-1 diff --git a/mutt/default b/mutt/default index bae76f6..01730a1 100644 --- a/mutt/default +++ b/mutt/default @@ -1,5 +1,5 @@ # Edit rc file and source it. This is the most important thing -macro index \Cv ":set wait_key=no!$EDITOR ~/.config/mutt/muttrc:source ~/.config/mutt/muttrc:set wait_key=yes" +macro index,browser \Cv ":set wait_key=no!$EDITOR ~/.config/mutt/muttrc:source ~/.config/mutt/muttrc:set wait_key=yes" # Connection options set ssl_force_tls = yes diff --git a/mutt/muttrc.topo b/mutt/muttrc.topo index c737cb7..48e2b10 100644 --- a/mutt/muttrc.topo +++ b/mutt/muttrc.topo @@ -6,14 +6,14 @@ set folder = "/home/pham/Maildir" set smtp_url = "smtp://$my_user:25" # Identify meself -#set from = "pham@topo.tw" -#set realname = "謝晉凡 Hsieh Chin Fan" -#set signature = "~/.config/mutt/.signature" -#set pgp_use_gpg_agent = yes -#set crypt_use_gpgme = yes -#set pgp_timeout = 300 -#set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id -#set autocrypt = yes +set from = "pham@topo.tw" +set realname = "謝晉凡 Hsieh Chin Fan" +set signature = "~/.config/mutt/.signature" +set pgp_use_gpg_agent = yes +set crypt_use_gpgme = yes +set pgp_timeout = 300 +set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id +set autocrypt = yes # For contacts set display_filter = ~/.config/mutt/message_filter.sh @@ -21,62 +21,62 @@ source ~/.config/mutt/alias.topo source ~/.config/mutt/hooks.topo ## Basic Mailbox -#set spoolfile = "+INBOX" -#set mbox= "+mbox" -#set move = yes -#set record = "+INBOX" -#set trash = "+Trash" -#set postponed = "+Drafts" -#set mask="!(INBOX|mbox|dev|Sent|Trash|Drafts|DeltaChat|civildef|hometeach|osm|STOCK|pay|keep|login|update|test|spam)" -# -## Sidebar -#mailboxes -label '📭 [i]' +INBOX \ -# -label '📥 [m]' +mbox \ -# -label '👀 [d]' +dev \ -# -label '💬 [D]' +DeltaChat \ -# +github \ -# +JOB \ -# +promotion \ -# "+---- Watch -----" \ -# -label CivilDEF +civildef \ -# +hometeach \ -# -label OSM +osm \ -# +STOCK \ -# -label '📢 [f]' +feedback \ -# "+-- Permanent ---" \ -# -label '💲 [p]' +pay \ -# -label '🍺 [k]' +keep \ -# -label '📤 [s]' +Sent \ -# -label '🗑 [t]' -poll +Trash \ -# +login \ -# +update \ -# +service \ -# +Drafts \ -# +test \ -# +spam -# -## Keybinding -#macro index,pager 'source ~/.config/mutt/muttrc.topo!' -#macro index,pager 'source ~/.config/mutt/muttrc.gmail!' -#macro index,pager 'source ~/.config/mutt/muttrc.b97602041!' -# -## Hooks for accounts -##folder-hook imaps://imap.gmail.com/ 'source ~/.config/mutt/muttrc.gmail' -##folder-hook ~/Maildir 'source ~/.config/mutt/muttrc.b97602041' -# -## Change mailboxes -#macro index,pager,browser gi "+INBOX" "Switch to INBOX folder" -#macro index,pager,browser gm "+mbox" "Switch to mbox folder" -#macro index,pager,browser gp "+pay" "Switch to pay folder" -#macro index,pager,browser gP "+promotion" "Switch to promotion folder" -#macro index,pager,browser gh "+hometeach" "Switch to hometeach folder" -#macro index,pager,browser gs "+Sent" "Switch to Sent folder" -#macro index,pager,browser gS "+spam" "Switch to spam folder" -#macro index,pager,browser gd "+dev" "Switch to DEV folder" -#macro index,pager,browser gD "+DeltaChat" "Switch to DeltaChat folder" -#macro index,pager,browser gt "+Trash" "Switch to Trash folder" -#macro index,pager,browser gl "+login" "Switch to login folder" -#macro index,pager,browser ga "+arch-general" "Switch to arch-general folder" -#macro index,pager,browser gk "+keep" "Switch to keep folder" -#macro index,pager,browser gu "+update" "Switch to update folder" -#macro index,pager,browser gf "+feedback" "Switch to feedback folder" +set spoolfile = "+" +set mbox= "+mbox" +set move = yes +set record = "+Sent" +set trash = "+Trash" +set postponed = "+Drafts" +set mask="!(tmp|new|cur|dovecot.*|\\..*)" + +# Sidebar +mailboxes -label '📭 [i]' + \ + -label '📥 [m]' +mbox \ + -label '👀 [d]' +dev \ + -label '💬 [D]' +DeltaChat \ + +github \ + +JOB \ + +promotion \ + "+---- Watch -----" \ + -label CivilDEF +civildef \ + +hometeach \ + -label OSM +osm \ + +STOCK \ + -label '📢 [f]' +feedback \ + "+-- Permanent ---" \ + -label '💲 [p]' +pay \ + -label '🍺 [k]' +keep \ + -label '📤 [s]' +Sent \ + -label '🗑 [t]' -poll +Trash \ + +login \ + +update \ + +service \ + +Drafts \ + +test \ + +spam + +# Keybinding +macro index,pager 'source ~/.config/mutt/muttrc.topo!' +macro index,pager 'source ~/.config/mutt/muttrc.gmail!' +macro index,pager 'source ~/.config/mutt/muttrc.b97602041!' + +# Hooks for accounts +#folder-hook imaps://imap.gmail.com/ 'source ~/.config/mutt/muttrc.gmail' +#folder-hook ~/Maildir 'source ~/.config/mutt/muttrc.b97602041' + +# Change mailboxes +macro index,pager,browser gi "+" "Switch to INBOX folder" +macro index,pager,browser gm "+mbox" "Switch to mbox folder" +macro index,pager,browser gp "+pay" "Switch to pay folder" +macro index,pager,browser gP "+promotion" "Switch to promotion folder" +macro index,pager,browser gh "+hometeach" "Switch to hometeach folder" +macro index,pager,browser gs "+Sent" "Switch to Sent folder" +macro index,pager,browser gS "+spam" "Switch to spam folder" +macro index,pager,browser gd "+dev" "Switch to DEV folder" +macro index,pager,browser gD "+DeltaChat" "Switch to DeltaChat folder" +macro index,pager,browser gt "+Trash" "Switch to Trash folder" +macro index,pager,browser gl "+login" "Switch to login folder" +macro index,pager,browser ga "+arch-general" "Switch to arch-general folder" +macro index,pager,browser gk "+keep" "Switch to keep folder" +macro index,pager,browser gu "+update" "Switch to update folder" +macro index,pager,browser gf "+feedback" "Switch to feedback folder" diff --git a/snippets/bash_read_from_pipe b/snippets/bash_read_from_pipe new file mode 100644 index 0000000..47d22b8 --- /dev/null +++ b/snippets/bash_read_from_pipe @@ -0,0 +1,4 @@ +shopt -s lastpipe; set +m; + +echo bar | read foo +echo $foo diff --git a/vim/init/highlight.vim b/vim/init/highlight.vim index 01f74b8..86dfc87 100644 --- a/vim/init/highlight.vim +++ b/vim/init/highlight.vim @@ -10,3 +10,5 @@ hi ExtraWhitespace ctermbg=red guibg=red hi CursorLine guibg=NONE " Only works when :set cursorline in neovim hi CursorLineNr term=bold cterm=bold ctermfg=226 gui=bold guifg=#eeee00 + +hi Folded guifg=#848089 guibg=#37343a ctermfg=lightblue ctermbg=black -- cgit v1.2.3-70-g09d2