From 5aaa36fd6bc42d127617e92bd1907816e82bfff0 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 22 Jan 2021 18:41:59 +0100 Subject: update --- .bashrc | 12 ++++ .i3status.conf | 1 + .vimrc | 5 ++ bin/icat | 38 +++++++++++- bin/rssg | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 242 insertions(+), 3 deletions(-) create mode 100755 bin/rssg diff --git a/.bashrc b/.bashrc index 2f6a357..90c903e 100644 --- a/.bashrc +++ b/.bashrc @@ -70,6 +70,12 @@ alias wpa='sudo wpa_gui -i wlan0' alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' +# Some admin command +alias dmesg='sudo dmesg' +alias mount='sudo mount' +alias umount='sudo umount' +alias cryptsetup='sudo cryptsetup' + alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/traefik/yaegi' #alias ty='go test -v -short ./interp' @@ -101,6 +107,12 @@ export -f ws wsd() (cd ~/Wiki && git add . && git diff --cached) export -f wsd +meteo() { + local request="wttr.in/${1-Toulouse}?F&T" + [ "$(tput cols)" -lt 125 ] && request+='&n' + curl -H "Accept-Language: ${LANG%_*}" --compressed "$request" +} + #PS1='[\u@\h \W]\$ ' # fzf diff --git a/.i3status.conf b/.i3status.conf index 229dfc1..87656f8 100644 --- a/.i3status.conf +++ b/.i3status.conf @@ -93,6 +93,7 @@ memory { cpu_temperature 0 { format = "🌡%degrees °C" #path = "/sys/class/hwmon/hwmon0/temp1_input" + #path = "/sys/class/hwmon/hwmon7/temp1_input" path = "/sys/class/hwmon/hwmon6/temp1_input" } diff --git a/.vimrc b/.vimrc index 84c082d..f8fce87 100644 --- a/.vimrc +++ b/.vimrc @@ -7,6 +7,8 @@ filetype plugin on filetype plugin indent on let mapleader = "," +let g:fzf_preview = 'cat {}' + " vimki plugin let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on @@ -14,6 +16,9 @@ autocmd filetype vimki set autowrite autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki +autocmd filetype vimki nnoremap = YpVr= +autocmd filetype vimki nnoremap - YpVr- + " vim-go plugin let g:go_def_mode = "gopls" let g:go_info_mode = "gopls" diff --git a/bin/icat b/bin/icat index 702d648..0170513 100755 --- a/bin/icat +++ b/bin/icat @@ -1,10 +1,10 @@ #!/bin/sh -e # Display images directly in terminal. -# Tested with xterm v361 +# Tested with xterm v361. Depends on imagemagick convert(1). # maxsize prints the geomtry size of terminal window, with # a maximum value of 1000 pixels for width and height, or -# 640x480 if size can not be probed. +# 640x480 if terminal size can not be probed. maxsize() { [ "$WINDOWID" ] || { echo "640x480>"; return; } xwininfo -id "$WINDOWID" | { @@ -19,10 +19,42 @@ maxsize() { } } +clearline() { printf "\r \r"; } + +ms=$(maxsize) + # Use convert(1) from imagemagick to output sixel format. # -flatten uses the terminal background color as transparent layer # -resize use the terminal size as bounding box, with a limit of 1000 pixels # image is not resized if smaller than limit #exec convert -resize "$(maxsize)>" -transparent-color white -flatten -- ${1:--} sixel:- # color #rrrrggggbbbb -exec convert -resize "$(maxsize)>" -- ${1:--} sixel:${2:--} +#exec convert -resize "$(maxsize)>" -- ${1:--} sixel:${2:--} + +put=: +while getopts :cpv opt; do + case $opt in + (c) clear=1 ;; + (p) pause=1 put=printf ;; + (v) put=printf ;; + (*) echo "Usage: icat [-cpv] [image_file ...]"; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +[ "$#" = 0 -o "$#" = 1 -a "$1" = - ] && { + convert -resize "$ms>" - sixel:- + exit +} + +for f; do + $put "Next: %s" "$f" + [ "$pause" ] && { + read -sr + [ "$REPLY" = s ] && clearline && continue + } + [ "$clear" ] && clear + clearline + $put "%s\n" "$f" + convert -resize "$ms>" -- "$f" sixel:- +done diff --git a/bin/rssg b/bin/rssg new file mode 100755 index 0000000..52031e7 --- /dev/null +++ b/bin/rssg @@ -0,0 +1,189 @@ +#!/bin/sh +# +# https://www.romanzolotarev.com/bin/rssg +# Copyright 2018 Roman Zolotarev +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +set -e + + +main () { + test -n "$1" || usage + test -n "$2" || usage + test -f "$1" || no_file "$1" + + + index_file=$(readlink -f "$1") + test -z "${index_file##*html}" && html=$(cat "$index_file") + test -z "${index_file##*md}" && html=$(md_to_html "$index_file") + test -n "$html" || usage + + base="${index_file%/*}" + base_url="$(echo "$html" | get_url | sed 's#\(.*\)/[^/]*#\1#')" + + url=$( echo "$html" | get_url) + + title="$2" + + description=$( echo "$html" | get_description | + remove_tags | + remove_nbsp ) + + items=$( echo "$html" | get_items) + + rss=$( echo "$items" | + render_items "$base" "$base_url" | + render_feed "$url" "$title" "$description") + + >&2 echo "[rssg] ${index_file##$(pwd)/} $(echo "$rss" | grep -c '') items" + echo "$rss" +} + + +usage() { + echo "usage: ${0##*/} index.{html,md} title > rss.xml" >&2 + exit 1 +} + + +no_file() { + echo "${0##*/}: $1: No such file" >&2 + exit 2 +} + + +md_to_html() { + test -x "$(which lowdown)" || exit 3 + lowdown \ + -D html-skiphtml \ + -D smarty \ + -d metadata \ + -d autolink "$1" +} + + +get_title() { + awk 'tolower($0)~/^

]*>/,"",$0);print;exit}' +} + + +get_url() { + grep -i '\(.*\).*#\1 \2 \3#' +} + + +get_description() { + start='sub("^.*<"s"*"t"("s"[^>]*)?>","")' + stop='sub(".*","")&&x=1' + awk -v 's=[[:space:]]' -v 't=[Pp]' "$start,$stop;x{exit}" +} + +remove_tags() { + sed 's#<[^>]*>##g;s#]*>##g' +} + + +remove_nbsp() { + sed 's#\ # #g' +} + + +rel_to_abs_urls() { + site_url="$1" + base_url="$2" + + abs='s#(src|href)="/([^"]*)"#\1="'"$site_url"/'\2"#g' + rel='s#(src|href)="([^:/"]*)"#\1="'"$base_url"/'\2"#g' + sed -E "$abs;$rel" +} + + +date_rfc_822() { + date -j '+%a, %d %b %Y %H:%M:%S %z' \ + "$(echo "$1"| tr -cd '[:digit:]')0000" +} + + +render_items() { + while read -r i + do render_item "$1" "$2" "$i" + done +} + + +render_item() { + base="$1" + base_url="$2" + item="$3" + + site_url="$(echo "$base_url"| sed 's#\(.*//.*\)/.*#\1#')" + + date=$(echo "$item"|awk '{print$2}') + url=$(echo "$item"|awk '{print$1}') + + f="$base/$url" + test -f "$f" && html=$(cat "$f") + test -f "${f%\.html}.md" && html=$(md_to_html "${f%\.html}.md") + + description=$( + echo "$html" | + rel_to_abs_urls "$site_url" "$base_url" | + remove_nbsp + ) + title=$(echo "$description" | get_title) + guid="$base_url/$(echo "$url" | sed 's#^/##')" + + echo ' + +'"$guid"' +'"$guid"' +'"$(date_rfc_822 "$date")"' +'"$title"' + +' +} + + +render_feed() { + url="$1" + title=$(echo "$2" | remove_nbsp) + description="$3" + + base_url="$(echo "$url" | cut -d '/' -f1-3)" + + echo ' + + + +'"$title"' +'"$description"' +'"$base_url"'/ +'"$(date_rfc_822 date)"' +'"$(cat)"' +' +} + + +main "$@" -- cgit v1.2.3