From 1aa518b6ec9a261a83d291ff48607c2ce4c7b143 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 9 Jun 2020 01:10:47 +0200 Subject: diffdir --- bin/diffdir | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 bin/diffdir diff --git a/bin/diffdir b/bin/diffdir new file mode 100755 index 0000000..57997ed --- /dev/null +++ b/bin/diffdir @@ -0,0 +1,43 @@ +#!/bin/sh + +Version='diffdir-0.1' + +diffdir() { + [ -f "/etc/backup/ignore" ] && xf=--exclude-from=/etc/backup/ignore || xf= + rsync -aDSniv $xf --delete $Optx "$2/" "$1" | + awk -v OptF="${OptF#./}" -v prefix=$prefix ' + NF == 0 {exit} + NR < 2 || /\/*\.dv$/ || /\/$/ {next} + # Match an itemized status for all versions of rsync -i + $1 !~ /^[<>ch.*][fdLDS+][.+?cstpoguaxz]+$/ {next} + {key = $1; file = substr($0, length(key) + 2)} + OptF && OptF != file {next} + key == "*deleting" {print "deleted " prefix file; next} + substr(key, 3, 7) == "+++++++" {print "created " prefix file; next} + { # Avoid false positive if only mtime is changed. + of = "'$1'/" file; gsub("'\''", "'\'\\\\\'\''", of) + nf = "'$2'/" file; gsub("'\''", "'\'\\\\\'\''", nf) + if (substr(key, 2, 1) == "L") { # Symlink + src = target = file + sub(/.* -> /, "", target); + sub(/ -> .*/, "", src); + "readlink '$2'/" src | getline otarget + if (target != otarget) + print "changed " src + } else if (system("cmp -s '\''" of "'\'\ \''" nf "'\''")) + print "changed " file + }' + # Or: scan key for file/link size, checksum or permission change + # rsync -c is required + #key ~ /[cps]/ { print "changed " prefix file }' +} + +while getopts :V opt; do + case $opt in + (V) echo "$Version"; exit ;; + (*) echo "Usage: $0 [-V]"; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +diffdir "$1" "$2" -- cgit v1.2.3 From 581ea31ab2a9f88b611080fe646d858c140ed7ca Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 9 Jun 2020 10:06:11 +0200 Subject: update --- bin/backup | 13 +++++++++++-- bin/bgc | 2 +- bin/gauth | 2 +- bin/yoda | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/backup b/bin/backup index 2ee6b83..cc98d63 100755 --- a/bin/backup +++ b/bin/backup @@ -6,7 +6,16 @@ die() { echo "$0: fatal: $@" >&2; exit 1; } [ "$(id -u)" = 0 ] || die must run as root -dest=${1:-bip:/home/backup}/$(hostname) +while getopts :v opt; do + case $opt in + (v) optv=v ;; + (*) echo "Usage: $0 [-v] [[host:]dir]"; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +#dest=${1:-/backup/$(hostname)} +dest=${1:-/.history} date=$(date +%Y%m%d_%H%M%S) last=$(rsync --list-only $dest/ 2>/dev/null | cut -b 47- | tail -1) @@ -15,4 +24,4 @@ case $last in (*) opt_link=;; esac -rsync -DSHxav --exclude-from=/etc/backup/ignore $opt_link / /boot /home $dest/$date +rsync -DSHxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot $dest/$date diff --git a/bin/bgc b/bin/bgc index 6ff6874..514b9ab 100755 --- a/bin/bgc +++ b/bin/bgc @@ -46,7 +46,7 @@ retention_delay() { } # sorted list of backups, most recent first -lbu=$(ssh bip ls /home/backup/swift | sort -r) +lbu=$(ssh bip ls -rv /home/backup/swift) for d in $lbu; do tsc=$(date2ts $d) if ! [ "$tsp" ]; then diff --git a/bin/gauth b/bin/gauth index 6c00e1e..575d6fc 100755 --- a/bin/gauth +++ b/bin/gauth @@ -1,7 +1,7 @@ #!/bin/sh # Use backup from andOTP -gpg -qd ~/otp_accounts.json.gpg | +gpg -qd ~/.otp_accounts.json.gpg | jq -r '.[] | "\(.label) \(.secret)"' | while read -r l s; do echo "$l $(oathtool --totp -b "$s")" diff --git a/bin/yoda b/bin/yoda index 4aa1667..4a2e0f9 100755 --- a/bin/yoda +++ b/bin/yoda @@ -1,7 +1,7 @@ #!/bin/sh # Setup an archlinux system to a media -version='yoda-0.1' +version='yoda-0.2' help() { echo 'usage: yoda [-CV] [-u user] dev -- cgit v1.2.3 From 371dc62b59b531303b067524497ad37763db2e8d Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 10 Jun 2020 08:36:21 +0200 Subject: update --- bin/g5 | 3 +++ bin/note2 | 3 +++ 2 files changed, 6 insertions(+) create mode 100755 bin/g5 create mode 100755 bin/note2 diff --git a/bin/g5 b/bin/g5 new file mode 100755 index 0000000..ef8caff --- /dev/null +++ b/bin/g5 @@ -0,0 +1,3 @@ +#!/bin/sh +adb forward tcp:8022 tcp:8022 +ssh ssh://u0_a126@localhost:8022 diff --git a/bin/note2 b/bin/note2 new file mode 100755 index 0000000..e6d0142 --- /dev/null +++ b/bin/note2 @@ -0,0 +1,3 @@ +#!/bin/sh +adb forward tcp:8122 tcp:8022 +ssh ssh://u0_a79@localhost:8122 -- cgit v1.2.3 From b78cfb6b9bb2b7abecab605406f341dff8227bc3 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 10 Jun 2020 22:22:22 +0200 Subject: update --- bin/backup | 5 +++-- bin/backup-clean | 40 ++++++++++++++++++++++++---------------- bin/diffdir | 12 ++++++------ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/bin/backup b/bin/backup index cc98d63..3f1d586 100755 --- a/bin/backup +++ b/bin/backup @@ -1,10 +1,12 @@ #!/bin/sh +[ "$USER" = root ] || exec sudo "$0" "$@" + # incremental backup using rsync(1) die() { echo "$0: fatal: $@" >&2; exit 1; } -[ "$(id -u)" = 0 ] || die must run as root +#[ "$(id -u)" = 0 ] || die must run as root while getopts :v opt; do case $opt in @@ -14,7 +16,6 @@ while getopts :v opt; do done shift $((OPTIND - 1)) -#dest=${1:-/backup/$(hostname)} dest=${1:-/.history} date=$(date +%Y%m%d_%H%M%S) last=$(rsync --list-only $dest/ 2>/dev/null | cut -b 47- | tail -1) diff --git a/bin/backup-clean b/bin/backup-clean index 5034c44..fba4279 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -1,32 +1,40 @@ #!/bin/sh # backup garbage collector -# keep: -# 1 backup per year the previous years -hd=3600 # hour duration: 60s * 60 -h12=43200 # 12h -dd=86400 # day duration: hd * 24 -wd=604800 # week duration: dd * 7 -md=2592000 # month duration: dd * 30 -yd=31557600 # year duration: dd * 365.25 +[ "$USER" = root ] || exec sudo "$0" "$@" + +# Durations, in number of seconds. +hd=3600 # hour duration: 60s * 60 +h12=43200 # 12h: hd * 12 +dd=86400 # day duration: hd * 24 +wd=604800 # week duration: dd * 7 +md=2592000 # month duration: dd * 30 +yd=31557600 # year duration: dd * 365.25 now=$(date +'%Y%m%d_%H%M%S') +# The following works only for busybox date, not coreutils +# Kept for reference only. #date2ts() { d=${1%_*} t=${1#*_}; date -d "$d${t%??}" +%s; } + +# Convert date to timestamp, using date from GNU coreutils, +# works also with busybox date. date2ts() { - t=$1; r=${t#????}; Y=${t%$r} - t=$r; r=${t#??}; m=${t%$r} - t=$r; r=${t#??}; d=${t%$r} - t=${r#_}; r=${t#??}; H=${t%$r} - t=$r; r=${t#??}; M=${t%$r} - S=${t#??} + t=$1; r=${t#????}; Y=${t%$r} # Year (with century) + t=$r; r=${t#??}; m=${t%$r} # Month + t=$r; r=${t#??}; d=${t%$r} # Day + t=${r#_}; r=${t#??}; H=${t%$r} # Hour + t=$r; r=${t#??}; M=${t%$r} # Minute + S=${t#??} # Second date -d "$Y-$m-$d $H:$M:$S" +%s + #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOSX } ts2date() { date -d "@$1" +'%Y%m%d_%H%M%S'; } tsn=$(date2ts "$now") -# minimal retention delay, according to backup age +# Minimal retention delay in seconds, according to backup age, +# implemented using POSIX shell arithmetic. retention_delay() { d=$((tsn - $1)) if [ $((d < h12)) = 1 ]; then @@ -54,7 +62,7 @@ while getopts :nv opt; do done shift $((OPTIND - 1)) -# sorted list of backups, most recent first +# Sorted list of backups, most recent first dest=${1:-/.history} lbu=$(ls -rv "$dest") for d in $lbu; do diff --git a/bin/diffdir b/bin/diffdir index 57997ed..d1a8ae2 100755 --- a/bin/diffdir +++ b/bin/diffdir @@ -4,8 +4,8 @@ Version='diffdir-0.1' diffdir() { [ -f "/etc/backup/ignore" ] && xf=--exclude-from=/etc/backup/ignore || xf= - rsync -aDSniv $xf --delete $Optx "$2/" "$1" | - awk -v OptF="${OptF#./}" -v prefix=$prefix ' + rsync -aDSnivx "$xf" --delete "$2/" "$1" | + awk -v OptF="${OptF#./}" -v prefix="$prefix" ' NF == 0 {exit} NR < 2 || /\/*\.dv$/ || /\/$/ {next} # Match an itemized status for all versions of rsync -i @@ -15,13 +15,13 @@ diffdir() { key == "*deleting" {print "deleted " prefix file; next} substr(key, 3, 7) == "+++++++" {print "created " prefix file; next} { # Avoid false positive if only mtime is changed. - of = "'$1'/" file; gsub("'\''", "'\'\\\\\'\''", of) - nf = "'$2'/" file; gsub("'\''", "'\'\\\\\'\''", nf) + of = "'"$1"'/" file; gsub("'\''", "'\'\\\\\'\''", of) + nf = "'"$2"'/" file; gsub("'\''", "'\'\\\\\'\''", nf) if (substr(key, 2, 1) == "L") { # Symlink src = target = file sub(/.* -> /, "", target); sub(/ -> .*/, "", src); - "readlink '$2'/" src | getline otarget + "readlink '"$2"'/" src | getline otarget if (target != otarget) print "changed " src } else if (system("cmp -s '\''" of "'\'\ \''" nf "'\''")) @@ -35,7 +35,7 @@ diffdir() { while getopts :V opt; do case $opt in (V) echo "$Version"; exit ;; - (*) echo "Usage: $0 [-V]"; exit 1 ;; + (*) echo "Usage: $0 [-V] old new"; exit 1 ;; esac done shift $((OPTIND - 1)) -- cgit v1.2.3 From a07956c688c2aab48ab0f8e39e4ce57c13a7a93e Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 10 Jun 2020 23:47:15 +0200 Subject: update --- bin/backup-clean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/backup-clean b/bin/backup-clean index fba4279..054ffbc 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -62,7 +62,7 @@ while getopts :nv opt; do done shift $((OPTIND - 1)) -# Sorted list of backups, most recent first +# Sorted list of backups, most recent first. dest=${1:-/.history} lbu=$(ls -rv "$dest") for d in $lbu; do -- cgit v1.2.3 From d746e010b0e5636b38eec22caa2ff9df43d09b95 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 13 Jun 2020 10:12:49 +0200 Subject: update --- bin/yoda | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/yoda b/bin/yoda index 4a2e0f9..8ff9e81 100755 --- a/bin/yoda +++ b/bin/yoda @@ -1,7 +1,9 @@ #!/bin/sh # Setup an archlinux system to a media -version='yoda-0.2' +[ "$USER" = root ] || exec sudo "$0" "$@" + +version='yoda-0.3' help() { echo 'usage: yoda [-CV] [-u user] dev @@ -38,7 +40,7 @@ skip() { # return 1 if any of the required commands is missing prereq() { ok='ok' - for cmd in cryptsetup dd fdisk mkfs.fat mkfs.ext4 mount pacstrap genfstab arch-chroot + for cmd in cryptsetup dd fdisk mkfs.fat mkfs.ext4 mkfs.xfs mount pacstrap genfstab arch-chroot do command -v "$cmd" >/dev/null || { ok=''; echo "$cmd not found"; } done @@ -81,7 +83,7 @@ step2() { # Step 3: Format partitions. step3() { mkfs.fat -F32 "${dev}${ppref}1" - yes | mkfs.ext4 "$rootpart" + mkfs.xfs "$rootpart" } # Step 4: Mount partitions. @@ -172,7 +174,7 @@ DNSSEC=no EOT packages="linux linux-firmware intel-ucode amd-ucode sof-firmware \ - dosfstools sudo vi wireless_tools wpa_supplicant openssh arch-install-scripts" + xfsprogs dosfstools sudo vi wireless_tools wpa_supplicant openssh arch-install-scripts" arch-chroot /mnt << EOT locale-gen @@ -237,8 +239,8 @@ while getopts :CFH:S:u:V opt; do done shift $((OPTIND - 1)) -[ "$(id -u)" = 0 ] || die "not root" [ "$1" ] && dev=$1 || die 'no device' + par=${dev##*/}root case $dev in (*nvme*) ppref='p';; esac rootpart="${dev}${ppref}2" -- cgit v1.2.3 From 71767b52cae787217b9e18dbd214f28a7b5b1c9a Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 15 Jun 2020 15:47:00 +0200 Subject: update --- .bashrc | 1 + bin/backup | 17 +++++++---------- bin/byo | 34 ++++++++++++++++++++++++++++++++++ bin/yoda | 12 +++++++----- 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100755 bin/byo diff --git a/.bashrc b/.bashrc index 771c00e..14c87b7 100644 --- a/.bashrc +++ b/.bashrc @@ -38,6 +38,7 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date export TERMINAL=xt alias cl='cf xft:Mono:size=12' +alias cp='cp --reflink' alias ls='ls --color=auto -v' alias ll='ls -AlFhv' alias vi='vim' diff --git a/bin/backup b/bin/backup index 3f1d586..059f2dc 100755 --- a/bin/backup +++ b/bin/backup @@ -1,17 +1,12 @@ #!/bin/sh +# Incremental backup using rsync(1). [ "$USER" = root ] || exec sudo "$0" "$@" -# incremental backup using rsync(1) - -die() { echo "$0: fatal: $@" >&2; exit 1; } - -#[ "$(id -u)" = 0 ] || die must run as root - -while getopts :v opt; do +while getopts :Fv opt; do case $opt in - (v) optv=v ;; - (*) echo "Usage: $0 [-v] [[host:]dir]"; exit 1 ;; + (F|v) eval "opt$opt=$opt" ;; + (*) echo "Usage: $0 [-Fv] [[host:]dir]"; exit 1 ;; esac done shift $((OPTIND - 1)) @@ -25,4 +20,6 @@ case $last in (*) opt_link=;; esac -rsync -DSHxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot $dest/$date +[ "$optF" ] && fsfreeze -f / && trap 'fsfreeze -u /' EXIT + +rsync -HSxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot $dest/$date diff --git a/bin/byo b/bin/byo new file mode 100755 index 0000000..173c2a7 --- /dev/null +++ b/bin/byo @@ -0,0 +1,34 @@ +#!/bin/sh -e +# Backup to yoda +[ "$USER" = root ] || exec sudo "$0" "$@" + +usage='Usage: byo [-cdk] +Backup local disk to yoda external disk. + +Options: + -c close and umount yoda + -d dedupe yoda + -k do not umount and close yoda +' + +while getopts :cdk opt; do + case $opt in + (c|d|k) eval "opt$opt=$opt" ;; + (*) printf %s "$usage"; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb' + +dest=/mnt/backup/$(hostname) +[ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda +findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt +time backup -Fv "$dest" +backup-clean -v "$dest" +[ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" +[ ! "$optk" ] || noumount=1 noclose=1 +[ ! "$optc" ] || noumount='' noclose='' +[ "$noumount" ] || umount /mnt +[ "$noclose" ] || cryptsetup close yoda +echo "bye" diff --git a/bin/yoda b/bin/yoda index 4a2e0f9..8ff9e81 100755 --- a/bin/yoda +++ b/bin/yoda @@ -1,7 +1,9 @@ #!/bin/sh # Setup an archlinux system to a media -version='yoda-0.2' +[ "$USER" = root ] || exec sudo "$0" "$@" + +version='yoda-0.3' help() { echo 'usage: yoda [-CV] [-u user] dev @@ -38,7 +40,7 @@ skip() { # return 1 if any of the required commands is missing prereq() { ok='ok' - for cmd in cryptsetup dd fdisk mkfs.fat mkfs.ext4 mount pacstrap genfstab arch-chroot + for cmd in cryptsetup dd fdisk mkfs.fat mkfs.ext4 mkfs.xfs mount pacstrap genfstab arch-chroot do command -v "$cmd" >/dev/null || { ok=''; echo "$cmd not found"; } done @@ -81,7 +83,7 @@ step2() { # Step 3: Format partitions. step3() { mkfs.fat -F32 "${dev}${ppref}1" - yes | mkfs.ext4 "$rootpart" + mkfs.xfs "$rootpart" } # Step 4: Mount partitions. @@ -172,7 +174,7 @@ DNSSEC=no EOT packages="linux linux-firmware intel-ucode amd-ucode sof-firmware \ - dosfstools sudo vi wireless_tools wpa_supplicant openssh arch-install-scripts" + xfsprogs dosfstools sudo vi wireless_tools wpa_supplicant openssh arch-install-scripts" arch-chroot /mnt << EOT locale-gen @@ -237,8 +239,8 @@ while getopts :CFH:S:u:V opt; do done shift $((OPTIND - 1)) -[ "$(id -u)" = 0 ] || die "not root" [ "$1" ] && dev=$1 || die 'no device' + par=${dev##*/}root case $dev in (*nvme*) ppref='p';; esac rootpart="${dev}${ppref}2" -- cgit v1.2.3 From ad7f45231cb867990a03830ec09e0cd41959f539 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 24 Jun 2020 14:29:51 +0200 Subject: update --- .config/chromium-flags.conf | 6 ------ bin/backup | 14 ++++++-------- bin/byo | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 .config/chromium-flags.conf diff --git a/.config/chromium-flags.conf b/.config/chromium-flags.conf deleted file mode 100644 index a5ef947..0000000 --- a/.config/chromium-flags.conf +++ /dev/null @@ -1,6 +0,0 @@ ---disk-cache-dir=/tmp/cache ---enable-dom-distiller ---ignore-gpu-blacklist ---enable-gpu-rasterization ---enable-native-gpu-memory-buffers ---enable-zero-copy diff --git a/bin/backup b/bin/backup index 059f2dc..4ef83be 100755 --- a/bin/backup +++ b/bin/backup @@ -3,23 +3,21 @@ [ "$USER" = root ] || exec sudo "$0" "$@" -while getopts :Fv opt; do +while getopts :v opt; do case $opt in - (F|v) eval "opt$opt=$opt" ;; - (*) echo "Usage: $0 [-Fv] [[host:]dir]"; exit 1 ;; + (v) eval "opt$opt=$opt" ;; + (*) echo "Usage: $0 [-v] [[host:]dir]"; exit 1 ;; esac done shift $((OPTIND - 1)) dest=${1:-/.history} date=$(date +%Y%m%d_%H%M%S) -last=$(rsync --list-only $dest/ 2>/dev/null | cut -b 47- | tail -1) +last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) case $last in -(2*) opt_link=--link-dest=../$last;; +([12]*) opt_link=--link-dest=../$last;; (*) opt_link=;; esac -[ "$optF" ] && fsfreeze -f / && trap 'fsfreeze -u /' EXIT - -rsync -HSxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot $dest/$date +rsync -HSxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot "$dest/$date" diff --git a/bin/byo b/bin/byo index 173c2a7..71b7578 100755 --- a/bin/byo +++ b/bin/byo @@ -24,7 +24,7 @@ yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb' dest=/mnt/backup/$(hostname) [ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt -time backup -Fv "$dest" +time backup -v "$dest" backup-clean -v "$dest" [ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" [ ! "$optk" ] || noumount=1 noclose=1 -- cgit v1.2.3 From 737ca59089a60edd0447db39775a97ec7fb96268 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 29 Jul 2020 16:31:28 +0200 Subject: update --- .bashrc | 5 ++++- .config/i3/config | 1 + bin/backup | 37 +++++++++++++++++++++++++------------ bin/backup-clean | 9 +++++---- bin/byo | 5 +++-- bin/diffdir | 21 ++++++++++++++++++++- 6 files changed, 58 insertions(+), 20 deletions(-) diff --git a/.bashrc b/.bashrc index 14c87b7..5427224 100644 --- a/.bashrc +++ b/.bashrc @@ -32,6 +32,9 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } #export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta) #export LESS_TERMCAP_ue=$'\E[0m' # end underline +# bat +export BAT_THEME='github' + # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' @@ -67,7 +70,7 @@ alias wpa='sudo wpa_gui -i wlan0' alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' -alias by='go build cmd/yaegi/yaegi.go' +alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/containous/yaegi' #alias ty='go test -v -short ./interp' alias ya='rlwrap -pblue ./yaegi' diff --git a/.config/i3/config b/.config/i3/config index 757e202..677dc90 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -61,6 +61,7 @@ for_window [class="Gpicview"] floating enable for_window [class="Ghb"] floating enable for_window [class="Gitk"] floating enable for_window [class="gnuplot_qt"] floating enable +for_window [instance="gxditview"] floating enable for_window [class="Keybase"] floating enable for_window [class="libreoffice"] floating enable for_window [class="llpp"] floating enable diff --git a/bin/backup b/bin/backup index 4ef83be..d56ee7f 100755 --- a/bin/backup +++ b/bin/backup @@ -3,21 +3,34 @@ [ "$USER" = root ] || exec sudo "$0" "$@" -while getopts :v opt; do +backup() { + date=$(date +%Y%m%d_%H%M%S) + last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) + + case $last in + ([12]*) opt_link=--link-dest=../$last;; + (*) opt_link=;; + esac + + rsync -HSxa$optv --exclude-from=$ignore $opt_link / /boot "$dest/$date" +} + +dest=/.history +ignore=/etc/backup/ignore + +while getopts :d:i:nv opt; do case $opt in - (v) eval "opt$opt=$opt" ;; - (*) echo "Usage: $0 [-v] [[host:]dir]"; exit 1 ;; + (d) dest="$OPTARG" ;; + (i) ignore="$OPTARG" ;; + (n|v) optv="$opt$optv" ;; + (*) echo "Usage: $0 [-nv] [-d [host:]dir] [clean|diff]"; exit 1 ;; esac done shift $((OPTIND - 1)) -dest=${1:-/.history} -date=$(date +%Y%m%d_%H%M%S) -last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) - -case $last in -([12]*) opt_link=--link-dest=../$last;; -(*) opt_link=;; +[ "$1" ] && cmd=$1 && shift || cmd="" +case $cmd in +(""|save) backup ;; +(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";; +(diff) exec diffdir "$@";; esac - -rsync -HSxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot "$dest/$date" diff --git a/bin/backup-clean b/bin/backup-clean index 054ffbc..d12159d 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -26,7 +26,7 @@ date2ts() { t=$r; r=${t#??}; M=${t%$r} # Minute S=${t#??} # Second date -d "$Y-$m-$d $H:$M:$S" +%s - #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOSX + #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOS (not tested) } ts2date() { date -d "@$1" +'%Y%m%d_%H%M%S'; } @@ -53,17 +53,18 @@ retention_delay() { echo $r } -while getopts :nv opt; do +dest=/.history +while getopts :nd:v opt; do case $opt in + (d) dest=$OPTARG ;; (n) optn=1 ;; (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [dir]"; exit 1; + (*) echo "Usage: $0 [-nv] [-d dir]"; exit 1; esac done shift $((OPTIND - 1)) # Sorted list of backups, most recent first. -dest=${1:-/.history} lbu=$(ls -rv "$dest") for d in $lbu; do tsc=$(date2ts "$d") diff --git a/bin/byo b/bin/byo index 71b7578..ecaba23 100755 --- a/bin/byo +++ b/bin/byo @@ -24,9 +24,10 @@ yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb' dest=/mnt/backup/$(hostname) [ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt -time backup -v "$dest" -backup-clean -v "$dest" +time backup -v -d "$dest" +backup -v -d "$dest" clean [ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" +df -h / "$dest" [ ! "$optk" ] || noumount=1 noclose=1 [ ! "$optc" ] || noumount='' noclose='' [ "$noumount" ] || umount /mnt diff --git a/bin/diffdir b/bin/diffdir index d1a8ae2..cbe03b7 100755 --- a/bin/diffdir +++ b/bin/diffdir @@ -32,6 +32,20 @@ diffdir() { #key ~ /[cps]/ { print "changed " prefix file }' } +last() { + i=0 m=0 + case $1 in + ([0-9]|[1-9][0-9]) m=$((m + $1)) ;; + ("") ;; + (*) echo "$1"; return ;; + esac + for l in $vlist; do + [ $i -ge $m ] && break + i=$((i + 1)) + done + echo "$dest/$l" +} + while getopts :V opt; do case $opt in (V) echo "$Version"; exit ;; @@ -40,4 +54,9 @@ while getopts :V opt; do done shift $((OPTIND - 1)) -diffdir "$1" "$2" +dest=/.history +vlist=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tac) + +old=$(last "$1") new=$(last "${2:-/}") +echo "diffdir" "$old" "$new" +diffdir "$old" "$new" -- cgit v1.2.3 From 7bac050e12201c40194d9df7bf711159f4acfa89 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 18 Sep 2020 15:21:29 +0200 Subject: update --- .bashrc | 6 +++--- .config/i3/config | 3 ++- bin/backup | 2 +- bin/backup-clean | 6 +++--- bin/hdmi | 1 + bin/stbip | 7 +++++++ 6 files changed, 17 insertions(+), 8 deletions(-) create mode 100755 bin/stbip diff --git a/.bashrc b/.bashrc index 5427224..821e08b 100644 --- a/.bashrc +++ b/.bashrc @@ -71,16 +71,16 @@ alias wpa='sudo wpa_gui -i wlan0' alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' alias by='go build ./cmd/yaegi' -alias cy='cd ~/go/src/github.com/containous/yaegi' +alias cy='cd ~/go/src/github.com/traefik/yaegi' #alias ty='go test -v -short ./interp' alias ya='rlwrap -pblue ./yaegi' alias dya='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' -alias wai='~/go/src/github.co/containous/whoami/whoami' +alias wai='~/go/src/github.co/traefik/whoami/whoami' # yaegi debug export YAEGI_DOT_CMD='dotty -' -tfk() { ~/go/src/github.com/containous/traefik/traefik "$@"; } +tfk() { ~/go/src/github.com/traefik/traefik/traefik "$@"; } export -f tfk ty() { go test -v -short ./interp; } diff --git a/.config/i3/config b/.config/i3/config index 677dc90..bf8a196 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -50,7 +50,8 @@ bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOU for_window [class="Arandr"] floating enable for_window [class="Brave-browser"] floating enable for_window [class="Chromium"] floating enable -for_window [instance="Task Manager - Chromium"] floating enable +for_window [title="Task Manager - Chromium"] floating enable +for_window [title="Gestionnaire de tâches – Chromium"] floating enable for_window [instance="DOTTY"] floating enable for_window [class="discord"] floating enable for_window [class="Display"] floating enable diff --git a/bin/backup b/bin/backup index d56ee7f..72c69c3 100755 --- a/bin/backup +++ b/bin/backup @@ -31,6 +31,6 @@ shift $((OPTIND - 1)) [ "$1" ] && cmd=$1 && shift || cmd="" case $cmd in (""|save) backup ;; -(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";; +(clean) exec backup-clean ${optv+-$optv} "$dest";; (diff) exec diffdir "$@";; esac diff --git a/bin/backup-clean b/bin/backup-clean index d12159d..0c6e38a 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -54,15 +54,15 @@ retention_delay() { } dest=/.history -while getopts :nd:v opt; do +while getopts :nv opt; do case $opt in - (d) dest=$OPTARG ;; (n) optn=1 ;; (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [-d dir]"; exit 1; + (*) echo "Usage: $0 [-nv] [dir]"; exit 1; esac done shift $((OPTIND - 1)) +[ "$1" ] && dest=$1 # Sorted list of backups, most recent first. lbu=$(ls -rv "$dest") diff --git a/bin/hdmi b/bin/hdmi index f5f7b1f..75e6f37 100755 --- a/bin/hdmi +++ b/bin/hdmi @@ -2,6 +2,7 @@ # Toggle auxiliary HDMI screen on/off when connected/disconnected. opt="--auto --right-of eDP-1" +#opt="--auto --above eDP-1" # Also add the following rule to /etc/udev/rules.d/hdmi.rules # KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/marc/.Xauthority", RUN+="/home/marc/bin/hdmi" diff --git a/bin/stbip b/bin/stbip new file mode 100755 index 0000000..e4a51a0 --- /dev/null +++ b/bin/stbip @@ -0,0 +1,7 @@ +#!/bin/sh + +# Check or establish a ssh tunnel for remote acess to syncthing GUI on bip. +netstat -t4ln | grep 9090 || + ssh -N -L 9090:127.0.0.1:8384 bip.im /dev/null 2>&1 & + +xdg-open http://127.0.0.1:9090 -- cgit v1.2.3 From 04746767a400dbdc03943b872f829732c4335e5f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 25 Sep 2020 15:57:37 +0200 Subject: update --- bin/backup-clean | 10 +++++++--- bin/byo | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/backup-clean b/bin/backup-clean index 0c6e38a..30d25db 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -54,11 +54,12 @@ retention_delay() { } dest=/.history -while getopts :nv opt; do +while getopts :d:nv opt; do case $opt in + (d) tsn=$(date2ts "$OPTARG") ;; (n) optn=1 ;; (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [dir]"; exit 1; + (*) echo "Usage: $0 [-nv] [dir]"; exit 1 ;; esac done shift $((OPTIND - 1)) @@ -66,6 +67,8 @@ shift $((OPTIND - 1)) # Sorted list of backups, most recent first. lbu=$(ls -rv "$dest") +lasy=${lbu##* +} for d in $lbu; do tsc=$(date2ts "$d") if ! [ "$tsp" ]; then @@ -75,7 +78,8 @@ for d in $lbu; do fi mrd=$(retention_delay "$tsp") dp=$((tsp - tsc)) - if [ $((dp < mrd)) = 1 ]; then + #if [ $((dp < mrd)) = 1 ]; then + if [ "$d" != "last" -a $((dp < mrd)) = 1 ]; then [ "$optv" ] && echo "delete $dest/$d" [ "$optn" ] || rm -rf "${dest:?}/$d" else diff --git a/bin/byo b/bin/byo index ecaba23..389e112 100755 --- a/bin/byo +++ b/bin/byo @@ -11,9 +11,9 @@ Options: -k do not umount and close yoda ' -while getopts :cdk opt; do +while getopts :Ccdk opt; do case $opt in - (c|d|k) eval "opt$opt=$opt" ;; + (C|c|d|k) eval "opt$opt=$opt" ;; (*) printf %s "$usage"; exit 1 ;; esac done @@ -25,9 +25,10 @@ dest=/mnt/backup/$(hostname) [ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt time backup -v -d "$dest" -backup -v -d "$dest" clean +[ ! "$optC" ] || backup -v -d "$dest" clean [ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" df -h / "$dest" +ls -v "$dest" [ ! "$optk" ] || noumount=1 noclose=1 [ ! "$optc" ] || noumount='' noclose='' [ "$noumount" ] || umount /mnt -- cgit v1.2.3 From 206192298984a30706243d5ec8ab767ca47fb5d5 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 1 Oct 2020 11:03:34 +0200 Subject: update --- .config/i3/config | 2 +- .gitconfig | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/i3/config b/.config/i3/config index bf8a196..bc65b99 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -99,7 +99,7 @@ bindsym --release button2 kill #bindsym $mod+d exec --no-startup-id i3-dmenu-desktop -dmenu="dmenu -i -fn 'Mono-9'" #bindsym F1 exec --no-startup-id i3-dmenu-desktop -dmenu="dmenu -i -fn 'Mono-9'" bindsym $mod+d exec --no-startup-id i3-dmenu-desktop -bindsym F1 exec --no-startup-id i3-dmenu-desktop +bindsym F1 exec --no-startup-id i3-dmenu-desktop -entry-type=command # Use playerctl to control media player from keyboard bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause diff --git a/.gitconfig b/.gitconfig index 3459f0e..eaefde0 100644 --- a/.gitconfig +++ b/.gitconfig @@ -7,6 +7,7 @@ do = diff origin/master ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%an]" --decorate st = status -s + undo = reset HEAD~ [user] email = mvertes@free.fr name = Marc Vertes -- cgit v1.2.3 From 42c709e21c6e7e4a2276128eee9743a43a174998 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 2 Oct 2020 12:57:47 +0200 Subject: update --- .Xresources | 5 +++++ .config/i3/config | 10 +++++++--- .i3status.conf | 24 +++++++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.Xresources b/.Xresources index 0a54cfc..a653af4 100644 --- a/.Xresources +++ b/.Xresources @@ -21,6 +21,11 @@ xterm*VT100.Translations: #override \ Ctrl Next: smaller-vt-font() \n\ Ctrl Prior: larger-vt-font() \n ! xterm*font: 7x14 +! Allow sixel graphics. (Try: "convert -colors 16 foo.jpg sixel:-"). +xterm*decTerminalID: vt340 +! Allow xterm to read the terminal window size (op #14) +xterm*allowWindowOps : False +xterm*disallowedWindowOps : 1,2,3,4,5,6,7,8,9,11,13,18,19,20,21,GetSelection,SetSelection,SetWinLines,SetXprop ! Black + DarkGrey *color0: #000000 diff --git a/.config/i3/config b/.config/i3/config index bc65b99..d22c3be 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -14,7 +14,9 @@ set $mod Mod4 # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. #font pango:monospace 8 -font fixed +#font fixed +# Same as above X11 fixed 6x13, but with icons +font pango:MiscFixedSC613 regular 9 #font pango:monospace 8, Noto sans 8 # This font is widely installed, provides lots of unicode glyphs, right-to-left @@ -99,7 +101,8 @@ bindsym --release button2 kill #bindsym $mod+d exec --no-startup-id i3-dmenu-desktop -dmenu="dmenu -i -fn 'Mono-9'" #bindsym F1 exec --no-startup-id i3-dmenu-desktop -dmenu="dmenu -i -fn 'Mono-9'" bindsym $mod+d exec --no-startup-id i3-dmenu-desktop -bindsym F1 exec --no-startup-id i3-dmenu-desktop -entry-type=command +#bindsym F1 exec --no-startup-id i3-dmenu-desktop -entry-type=command +bindsym F1 exec --no-startup-id i3-dmenu-desktop -dmenu="dmenu -i -fn 'Fixed-12'" # Use playerctl to control media player from keyboard bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause @@ -246,6 +249,7 @@ bindsym $mod+less move workspace to output left # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command LANG=fr_FR.UTF-8 i3status +# status_command LANG=fr_FR.UTF-8 i3status + status_command i3status tray_output primary } diff --git a/.i3status.conf b/.i3status.conf index ebd8243..e60903b 100644 --- a/.i3status.conf +++ b/.i3status.conf @@ -29,10 +29,12 @@ read_file hostname { path = "/etc/hostname" } +# ☠ wireless _first_ { -# format_up = "W: %essid %quality %ip" - format_up = "W: %essid %quality" - format_down = "W: down" + #format_up = "🌐 %essid %quality" + #format_up = "📶 %essid %quality" + format_up = "📡 %essid %quality" + format_down = "📡 down" } ethernet _first_ { @@ -40,10 +42,15 @@ ethernet _first_ { format_down = "E: down" } +# battery all { last_full_capacity = true integer_battery_capacity = true format = "%status %percentage %remaining" + status_chr = "⚡🔋" + status_bat = "🔋" + status_unk = "? UNK" + status_full = "⚡🔋" threshold_type = "percentage" low_threshold = 10 } @@ -60,7 +67,9 @@ battery all { #} disk "/" { - format = "/ %avail" + #format = "📀 %avail" + #format = "💽 %avail" + format = "/ %avail av." } disk "/boot" { @@ -68,7 +77,7 @@ disk "/boot" { } cpu_usage { - format = "CPU: %usage" + format = "CPU %usage" } load { @@ -76,17 +85,18 @@ load { } memory { - format = "RAM: %available" + format = "Mem %available av." threshold_degraded = "1G" format_degraded = "MEMORY < %available" } cpu_temperature 0 { - format = "T: %degrees °C" + format = "🌡%degrees °C" path = "/sys/class/hwmon/hwmon0/temp1_input" } tztime local { #format = "%Y-%m-%d %H:%M:%S" format = "%a %d %b %H:%M:%S" + #format = "📅 %a %d %b ⌚ %H:%M:%S" } -- cgit v1.2.3 From 60a71e503da5a93d6fc362a096ce12ff58124653 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 4 Oct 2020 11:19:09 +0200 Subject: update --- .bash-powerline.sh | 6 ++++-- .i3status.conf | 2 +- .profile | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 8121f92..232d7a5 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -12,7 +12,8 @@ __powerline() { readonly COLOR_SUCCESS='\[\033[0;34m\]' # blue readonly COLOR_FAILURE='\[\033[0;31m\]' # red - readonly SYMBOL_GIT_BRANCH='⑂' + #readonly SYMBOL_GIT_BRANCH='⑂' + readonly SYMBOL_GIT_BRANCH='→' readonly SYMBOL_GIT_MODIFIED='*' readonly SYMBOL_GIT_PUSH='↑' readonly SYMBOL_GIT_PULL='↓' @@ -66,7 +67,7 @@ __powerline() { done < <($git_eng status --porcelain --branch 2>/dev/null) # note the space between the two < # print the git branch segment without a trailing newline - printf " $ref$marks" + printf "$ref$marks" } ps1() { @@ -98,6 +99,7 @@ __powerline() { fi } + PROMPT_DIRTRIM=2 PROMPT_COMMAND="ps1${PROMPT_COMMAND:+; $PROMPT_COMMAND}" } diff --git a/.i3status.conf b/.i3status.conf index e60903b..b3af3a3 100644 --- a/.i3status.conf +++ b/.i3status.conf @@ -5,6 +5,7 @@ # The following line should contain a sharp s: # ß # If the above line is not correctly displayed, fix your editor first! +# Some icon chars can be found at https://emojipedia.org/objects/ general { colors = true @@ -29,7 +30,6 @@ read_file hostname { path = "/etc/hostname" } -# ☠ wireless _first_ { #format_up = "🌐 %essid %quality" #format_up = "📶 %essid %quality" diff --git a/.profile b/.profile index 3a407f5..cb09e87 100644 --- a/.profile +++ b/.profile @@ -6,5 +6,5 @@ PATH=~/bin:$PATH:~/go/bin # Last action: auto start X11 when logged on first console case $HOSTNAME in -(swift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; +([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; esac -- cgit v1.2.3 From 57f1105837aaf407b3f0e2485e6666668ed2ef28 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 4 Oct 2020 16:07:51 +0200 Subject: add local fixed fonts --- .local/share/fonts/misc-fixed.ttf | Bin 0 -> 42468 bytes .local/share/fonts/miscfs.ttf | Bin 0 -> 23280 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .local/share/fonts/misc-fixed.ttf create mode 100644 .local/share/fonts/miscfs.ttf diff --git a/.local/share/fonts/misc-fixed.ttf b/.local/share/fonts/misc-fixed.ttf new file mode 100644 index 0000000..cf1d11f Binary files /dev/null and b/.local/share/fonts/misc-fixed.ttf differ diff --git a/.local/share/fonts/miscfs.ttf b/.local/share/fonts/miscfs.ttf new file mode 100644 index 0000000..0a81111 Binary files /dev/null and b/.local/share/fonts/miscfs.ttf differ -- cgit v1.2.3 From ea39a38f64f0f2f752e1776038abb15332d98df1 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 4 Oct 2020 23:37:00 +0200 Subject: bash-powerline.sh: shorter prompt --- .bash-powerline.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 232d7a5..dffbf41 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -74,9 +74,9 @@ __powerline() { # Check the exit code of the previous command and display different # colors in the prompt accordingly. if [ $? -eq 0 ]; then - local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET" + local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET" else - local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET" + local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET" fi local cwd="$COLOR_CWD\w$RESET" -- cgit v1.2.3 From dc2b69508c58085ece7be617ae05ebaab5b7ecb2 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 5 Oct 2020 11:00:20 +0200 Subject: bash-powerline: space --- .bash-powerline.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index dffbf41..047631c 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -58,8 +58,8 @@ __powerline() { # scan first two lines of output from `git status` while IFS= read -r line; do if [[ $line =~ ^## ]]; then # header line - [[ $line =~ ahead\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PUSH${BASH_REMATCH[1]}" - [[ $line =~ behind\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PULL${BASH_REMATCH[1]}" + [[ $line =~ ahead\ ([0-9]+) ]] && marks+="$SYMBOL_GIT_PUSH${BASH_REMATCH[1]}" + [[ $line =~ behind\ ([0-9]+) ]] && marks+="$SYMBOL_GIT_PULL${BASH_REMATCH[1]}" else # branch is modified if output contains more lines after the header line marks="$SYMBOL_GIT_MODIFIED$marks" break -- cgit v1.2.3 From d6f29a6f21fdc418d3ab5edb782bbb38afbf1f47 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 6 Oct 2020 13:19:05 +0200 Subject: bash-powerline: restore space before prompt char --- .bash-powerline.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 047631c..556391f 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -74,9 +74,9 @@ __powerline() { # Check the exit code of the previous command and display different # colors in the prompt accordingly. if [ $? -eq 0 ]; then - local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET" + local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET" else - local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET" + local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET" fi local cwd="$COLOR_CWD\w$RESET" -- cgit v1.2.3 From a5f4594b09d034c2302c37516aa4db0e33ef77d9 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 8 Oct 2020 11:25:04 +0200 Subject: add dunst --- .config/dunst/dunstrc | 434 ++++++++++++++++++++++++++++++++++++++++++++++++++ .config/i3/config | 3 + 2 files changed, 437 insertions(+) create mode 100644 .config/dunst/dunstrc diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100644 index 0000000..d5a7f1b --- /dev/null +++ b/.config/dunst/dunstrc @@ -0,0 +1,434 @@ +[global] + ### Display ### + + # Which monitor should the notifications be displayed on. + monitor = 0 + + # Display notification on focused monitor. Possible modes are: + # mouse: follow mouse pointer + # keyboard: follow window with keyboard focus + # none: don't follow anything + # + # "keyboard" needs a window manager that exports the + # _NET_ACTIVE_WINDOW property. + # This should be the case for almost all modern window managers. + # + # If this option is set to mouse or keyboard, the monitor option + # will be ignored. + follow = mouse + + # The geometry of the window: + # [{width}]x{height}[+/-{x}+/-{y}] + # The geometry of the message window. + # The height is measured in number of notifications everything else + # in pixels. If the width is omitted but the height is given + # ("-geometry x2"), the message window expands over the whole screen + # (dmenu-like). If width is 0, the window expands to the longest + # message displayed. A positive x is measured from the left, a + # negative from the right side of the screen. Y is measured from + # the top and down respectively. + # The width can be negative. In this case the actual width is the + # screen width minus the width defined in within the geometry option. + geometry = "300x5-30+20" + + # Show how many messages are currently hidden (because of geometry). + indicate_hidden = yes + + # Shrink window if it's smaller than the width. Will be ignored if + # width is 0. + shrink = no + + # The transparency of the window. Range: [0; 100]. + # This option will only work if a compositing window manager is + # present (e.g. xcompmgr, compiz, etc.). + transparency = 0 + + # The height of the entire notification. If the height is smaller + # than the font height and padding combined, it will be raised + # to the font height and padding. + notification_height = 0 + + # Draw a line of "separator_height" pixel height between two + # notifications. + # Set to 0 to disable. + separator_height = 2 + + # Padding between text and separator. + padding = 8 + + # Horizontal padding. + horizontal_padding = 8 + + # Defines width in pixels of frame around the notification window. + # Set to 0 to disable. + frame_width = 3 + + # Defines color of the frame around the notification window. + frame_color = "#aaaaaa" + + # Define a color for the separator. + # possible values are: + # * auto: dunst tries to find a color fitting to the background; + # * foreground: use the same color as the foreground; + # * frame: use the same color as the frame; + # * anything else will be interpreted as a X color. + separator_color = frame + + # Sort messages by urgency. + sort = yes + + # Don't remove messages, if the user is idle (no mouse or keyboard input) + # for longer than idle_threshold seconds. + # Set to 0 to disable. + # A client can set the 'transient' hint to bypass this. See the rules + # section for how to disable this if necessary + idle_threshold = 120 + + ### Text ### + + font = Monospace 8 + + # The spacing between lines. If the height is smaller than the + # font height, it will get raised to the font height. + line_height = 0 + + # Possible values are: + # full: Allow a small subset of html markup in notifications: + # bold + # italic + # strikethrough + # underline + # + # For a complete reference see + # . + # + # strip: This setting is provided for compatibility with some broken + # clients that send markup even though it's not enabled on the + # server. Dunst will try to strip the markup but the parsing is + # simplistic so using this option outside of matching rules for + # specific applications *IS GREATLY DISCOURAGED*. + # + # no: Disable markup parsing, incoming notifications will be treated as + # plain text. Dunst will not advertise that it has the body-markup + # capability if this is set as a global setting. + # + # It's important to note that markup inside the format option will be parsed + # regardless of what this is set to. + markup = full + + # The format of the message. Possible variables are: + # %a appname + # %s summary + # %b body + # %i iconname (including its path) + # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing + # %n progress value if set without any extra characters + # %% Literal % + # Markup is allowed + format = "%s\n%b" + + # Alignment of message text. + # Possible values are "left", "center" and "right". + alignment = left + + # Vertical alignment of message text and icon. + # Possible values are "top", "center" and "bottom". + vertical_alignment = center + + # Show age of message if message is older than show_age_threshold + # seconds. + # Set to -1 to disable. + show_age_threshold = 60 + + # Split notifications into multiple lines if they don't fit into + # geometry. + word_wrap = yes + + # When word_wrap is set to no, specify where to make an ellipsis in long lines. + # Possible values are "start", "middle" and "end". + ellipsize = middle + + # Ignore newlines '\n' in notifications. + ignore_newline = no + + # Stack together notifications with the same content + stack_duplicates = true + + # Hide the count of stacked notifications with the same content + hide_duplicate_count = false + + # Display indicators for URLs (U) and actions (A). + show_indicators = yes + + ### Icons ### + + # Align icons left/right/off + icon_position = left + + # Scale small icons up to this size, set to 0 to disable. Helpful + # for e.g. small files or high-dpi screens. In case of conflict, + # max_icon_size takes precedence over this. + min_icon_size = 0 + + # Scale larger icons down to this size, set to 0 to disable + max_icon_size = 32 + + # Paths to default icons. + icon_path = /usr/share/icons/Adwaita/24x24/status/:/usr/share/icons/Adwaita/24x24/legacy/:/usr/share/icons/Adwaita/24x24/devices/ + + ### History ### + + # Should a notification popped up from history be sticky or timeout + # as if it would normally do. + sticky_history = yes + + # Maximum amount of notifications kept in history + history_length = 20 + + ### Misc/Advanced ### + + # dmenu path. + dmenu = /usr/bin/dmenu -p dunst: + + # Browser for opening urls in context menu. + #browser = /usr/bin/firefox -new-tab + browser = /usr/bin/chromium + + # Always run rule-defined scripts, even if the notification is suppressed + always_run_script = true + + # Define the title of the windows spawned by dunst + title = Dunst + + # Define the class of the windows spawned by dunst + class = Dunst + + # Print a notification on startup. + # This is mainly for error detection, since dbus (re-)starts dunst + # automatically after a crash. + startup_notification = false + + # Manage dunst's desire for talking + # Can be one of the following values: + # crit: Critical features. Dunst aborts + # warn: Only non-fatal warnings + # mesg: Important Messages + # info: all unimportant stuff + # debug: all less than unimportant stuff + verbosity = mesg + + # Define the corner radius of the notification window + # in pixel size. If the radius is 0, you have no rounded + # corners. + # The radius will be automatically lowered if it exceeds half of the + # notification height to avoid clipping text and/or icons. + corner_radius = 0 + + # Ignore the dbus closeNotification message. + # Useful to enforce the timeout set by dunst configuration. Without this + # parameter, an application may close the notification sent before the + # user defined timeout. + ignore_dbusclose = false + + ### Legacy + + # Use the Xinerama extension instead of RandR for multi-monitor support. + # This setting is provided for compatibility with older nVidia drivers that + # do not support RandR and using it on systems that support RandR is highly + # discouraged. + # + # By enabling this setting dunst will not be able to detect when a monitor + # is connected or disconnected which might break follow mode if the screen + # layout changes. + force_xinerama = false + + ### mouse + + # Defines list of actions for each mouse event + # Possible values are: + # * none: Don't do anything. + # * do_action: If the notification has exactly one action, or one is marked as default, + # invoke it. If there are multiple and no default, open the context menu. + # * close_current: Close current notification. + # * close_all: Close all notifications. + # These values can be strung together for each mouse event, and + # will be executed in sequence. + mouse_left_click = close_current + mouse_middle_click = do_action, close_current + mouse_right_click = close_all + +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # If this setting is enabled the Xft.dpi value will be ignored and instead + # dunst will attempt to calculate an appropriate dpi value for each monitor + # using the resolution and physical size. This might be useful in setups + # where there are multiple screens with very different dpi values. + per_monitor_dpi = false + +[shortcuts] + + # Shortcuts are specified as [modifier+][modifier+]...key + # Available modifiers are "ctrl", "mod1" (the alt-key), "mod2", + # "mod3" and "mod4" (windows-key). + # Xev might be helpful to find names for keys. + + # Close notification. + close = ctrl+space + + # Close all notifications. + close_all = ctrl+shift+space + + # Redisplay last message(s). + # On the US keyboard layout "grave" is normally above TAB and left + # of "1". Make sure this key actually exists on your keyboard layout, + # e.g. check output of 'xmodmap -pke' + #history = ctrl+grave + history = ctrl+exclam + + # Context menu. + #context = ctrl+colon + context = ctrl+shift+exclam + +[urgency_low] + # IMPORTANT: colors have to be defined in quotation marks. + # Otherwise the "#" and following would be interpreted as a comment. + background = "#222222" + foreground = "#888888" + timeout = 10 + # Icon for notifications with low urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + # Icon for notifications with normal urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + frame_color = "#ff0000" + timeout = 0 + # Icon for notifications with critical urgency, uncomment to enable + #icon = /path/to/icon + +# Every section that isn't one of the above is interpreted as a rules to +# override settings for certain messages. +# +# Messages can be matched by +# appname (discouraged, see desktop_entry) +# body +# category +# desktop_entry +# icon +# match_transient +# msg_urgency +# stack_tag +# summary +# +# and you can override the +# background +# foreground +# format +# frame_color +# fullscreen +# new_icon +# set_stack_tag +# set_transient +# timeout +# urgency +# +# Shell-like globbing will get expanded. +# +# Instead of the appname filter, it's recommended to use the desktop_entry filter. +# GLib based applications export their desktop-entry name. In comparison to the appname, +# the desktop-entry won't get localized. +# +# SCRIPTING +# You can specify a script that gets run when the rule matches by +# setting the "script" option. +# The script will be called as follows: +# script appname summary body icon urgency +# where urgency can be "LOW", "NORMAL" or "CRITICAL". +# +# NOTE: if you don't want a notification to be displayed, set the format +# to "". +# NOTE: It might be helpful to run dunst -print in a terminal in order +# to find fitting options for rules. + +# Disable the transient hint so that idle_threshold cannot be bypassed from the +# client +#[transient_disable] +# match_transient = yes +# set_transient = no +# +# Make the handling of transient notifications more strict by making them not +# be placed in history. +#[transient_history_ignore] +# match_transient = yes +# history_ignore = yes + +# fullscreen values +# show: show the notifications, regardless if there is a fullscreen window opened +# delay: displays the new notification, if there is no fullscreen window active +# If the notification is already drawn, it won't get undrawn. +# pushback: same as delay, but when switching into fullscreen, the notification will get +# withdrawn from screen again and will get delayed like a new notification +#[fullscreen_delay_everything] +# fullscreen = delay +#[fullscreen_show_critical] +# msg_urgency = critical +# fullscreen = show + +#[espeak] +# summary = "*" +# script = dunst_espeak.sh + +#[script-test] +# summary = "*script*" +# script = dunst_test.sh + +#[ignore] +# # This notification will not be displayed +# summary = "foobar" +# format = "" + +#[history-ignore] +# # This notification will not be saved in history +# summary = "foobar" +# history_ignore = yes + +#[skip-display] +# # This notification will not be displayed, but will be included in the history +# summary = "foobar" +# skip_display = yes + +#[signed_on] +# appname = Pidgin +# summary = "*signed on*" +# urgency = low +# +#[signed_off] +# appname = Pidgin +# summary = *signed off* +# urgency = low +# +#[says] +# appname = Pidgin +# summary = *says* +# urgency = critical +# +#[twitter] +# appname = Pidgin +# summary = *twitter.com* +# urgency = normal +# +#[stack-volumes] +# appname = "some_volume_notifiers" +# set_stack_tag = "volume" +# +# vim: ft=cfg diff --git a/.config/i3/config b/.config/i3/config index d22c3be..1b10cb1 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -35,6 +35,9 @@ exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -c 000000 --nofork #exec --no-startup-id nm-applet #exec --no-startup-id sudo wpa_gui -t -i wlo1 +# Notification daemon (see ~/.config/dunst/dunstrc for configuration) +exec --no-startup-id dunst + # pulse audio systray icon exec --no-startup-id pasystray -- cgit v1.2.3 From 5487201d526a5ceb42aa051a3c44afffe932d352 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 8 Oct 2020 13:35:59 +0200 Subject: update --- .bashrc | 2 +- .config/dunst/dunstrc | 7 +++---- .config/i3/config | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.bashrc b/.bashrc index 821e08b..861b390 100644 --- a/.bashrc +++ b/.bashrc @@ -73,7 +73,7 @@ alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/traefik/yaegi' #alias ty='go test -v -short ./interp' -alias ya='rlwrap -pblue ./yaegi' +alias ya='rlwrap -pblue yaegi' alias dya='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' alias wai='~/go/src/github.co/traefik/whoami/whoami' diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index d5a7f1b..c670303 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -86,7 +86,7 @@ ### Text ### - font = Monospace 8 + font = Monospace 9 # The spacing between lines. If the height is smaller than the # font height, it will get raised to the font height. @@ -286,11 +286,10 @@ # of "1". Make sure this key actually exists on your keyboard layout, # e.g. check output of 'xmodmap -pke' #history = ctrl+grave - history = ctrl+exclam + history = ctrl+twosuperior # Context menu. - #context = ctrl+colon - context = ctrl+shift+exclam + context = ctrl+colon [urgency_low] # IMPORTANT: colors have to be defined in quotation marks. diff --git a/.config/i3/config b/.config/i3/config index 1b10cb1..441753d 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -37,6 +37,10 @@ exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -c 000000 --nofork # Notification daemon (see ~/.config/dunst/dunstrc for configuration) exec --no-startup-id dunst +bindsym $mod+a exec --no-startup-id dunstctl action +bindsym $mod+n exec --no-startup-id dunstctl close +bindsym $mod+twosuperior exec --no-startup-id dunstctl history-pop + # pulse audio systray icon exec --no-startup-id pasystray -- cgit v1.2.3 From afbf517309c9809516645e3b35cdc2be7852b884 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 14 Oct 2020 15:37:42 +0200 Subject: update --- .bash-powerline.sh | 31 ++++++++++++++++--------------- .config/dunst/dunstrc | 3 ++- .config/i3/config | 1 + 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 556391f..d939f57 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -9,12 +9,12 @@ __powerline() { readonly COLOR_CWD='\[\033[0;34m\]' # blue readonly COLOR_GIT='\[\033[0;36m\]' # cyan #readonly COLOR_SUCCESS='\[\033[0;32m\]' # green - readonly COLOR_SUCCESS='\[\033[0;34m\]' # blue - readonly COLOR_FAILURE='\[\033[0;31m\]' # red + readonly COLOR_SUCCESS='\[\033[0;1;34m\]' # blue, bold + readonly COLOR_FAILURE='\[\033[0;1;31m\]' # red, bold #readonly SYMBOL_GIT_BRANCH='⑂' readonly SYMBOL_GIT_BRANCH='→' - readonly SYMBOL_GIT_MODIFIED='*' + readonly SYMBOL_GIT_MODIFIED='¤' readonly SYMBOL_GIT_PUSH='↑' readonly SYMBOL_GIT_PULL='↓' @@ -26,14 +26,15 @@ __powerline() { host=$(hostname) fi - if [[ -z "$PS_SYMBOL" ]]; then - case "$(uname)" in - # Darwin) PS_SYMBOL='';; - Darwin) PS_SYMBOL='$';; - Linux) PS_SYMBOL='$';; - *) PS_SYMBOL='%';; - esac - fi + [ "$PS_SYMBOL" ] || PS_SYMBOL=';' + #if [[ -z "$PS_SYMBOL" ]]; then + # case "$(uname)" in + # # Darwin) PS_SYMBOL='';; + # Darwin) PS_SYMBOL='$';; + # Linux) PS_SYMBOL='$';; + # *) PS_SYMBOL='%';; + # esac + #fi __git_info() { [[ $POWERLINE_GIT = 0 ]] && return # disabled @@ -74,9 +75,9 @@ __powerline() { # Check the exit code of the previous command and display different # colors in the prompt accordingly. if [ $? -eq 0 ]; then - local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET" + local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET" else - local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET" + local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET" fi local cwd="$COLOR_CWD\w$RESET" @@ -93,9 +94,9 @@ __powerline() { local git="$COLOR_GIT$(__git_info)$RESET" fi - PS1="$cwd$git$symbol" + PS1=": $cwd$git$symbol" if [ "$SSH_TTY" ]; then - PS1="$host:$PS1" + PS1=": $host:$PS1" fi } diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index c670303..245a60c 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -256,7 +256,8 @@ # will be executed in sequence. mouse_left_click = close_current mouse_middle_click = do_action, close_current - mouse_right_click = close_all + mouse_right_click = do_action, close_current + #mouse_right_click = close_all # Experimental features that may or may not work correctly. Do not expect them # to have a consistent behaviour across releases. diff --git a/.config/i3/config b/.config/i3/config index 441753d..22a61af 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -38,6 +38,7 @@ exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -c 000000 --nofork # Notification daemon (see ~/.config/dunst/dunstrc for configuration) exec --no-startup-id dunst bindsym $mod+a exec --no-startup-id dunstctl action +bindsym $mod+c exec --no-startup-id dunstctl context bindsym $mod+n exec --no-startup-id dunstctl close bindsym $mod+twosuperior exec --no-startup-id dunstctl history-pop -- cgit v1.2.3 From 57857f9382ccc0f2ce9bdff05bbbcce63da9f423 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 14 Oct 2020 15:46:55 +0200 Subject: update --- .bash-powerline.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index d939f57..ccb7a5d 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -27,14 +27,6 @@ __powerline() { fi [ "$PS_SYMBOL" ] || PS_SYMBOL=';' - #if [[ -z "$PS_SYMBOL" ]]; then - # case "$(uname)" in - # # Darwin) PS_SYMBOL='';; - # Darwin) PS_SYMBOL='$';; - # Linux) PS_SYMBOL='$';; - # *) PS_SYMBOL='%';; - # esac - #fi __git_info() { [[ $POWERLINE_GIT = 0 ]] && return # disabled @@ -94,10 +86,7 @@ __powerline() { local git="$COLOR_GIT$(__git_info)$RESET" fi - PS1=": $cwd$git$symbol" - if [ "$SSH_TTY" ]; then - PS1=": $host:$PS1" - fi + [ "$SSH_TTY" ] && PS1=": $host:$cwd$git$symbol" || PS1=": $cwd$git$symbol" } PROMPT_DIRTRIM=2 -- cgit v1.2.3 From a896548d0a3c8adc98a9c76c09b3433724e196ab Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 15 Oct 2020 22:23:27 +0200 Subject: add sixel tools --- .bashrc | 4 + bin/icat | 2 + bin/idot | 2 + bin/lsix | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 347 insertions(+) create mode 100755 bin/icat create mode 100755 bin/idot create mode 100755 bin/lsix diff --git a/.bashrc b/.bashrc index 861b390..229f627 100644 --- a/.bashrc +++ b/.bashrc @@ -35,6 +35,10 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } # bat export BAT_THEME='github' +# gnuplot display in terminal +export GNUTERM='sixelgd enhanced truecolor font "arial,9"' +#export GNUTERM='sixelgd enhanced truecolor small' + # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' diff --git a/bin/icat b/bin/icat new file mode 100755 index 0000000..b15a6d4 --- /dev/null +++ b/bin/icat @@ -0,0 +1,2 @@ +#!/bin/sh +exec convert -resize '800x480>' -flatten -- ${1:--} sixel:- diff --git a/bin/idot b/bin/idot new file mode 100755 index 0000000..d36d947 --- /dev/null +++ b/bin/idot @@ -0,0 +1,2 @@ +#!/bin/sh +dot -Tpng -Gsize=8 "${1:-}" | convert -- - sixel:- diff --git a/bin/lsix b/bin/lsix new file mode 100755 index 0000000..0f96b36 --- /dev/null +++ b/bin/lsix @@ -0,0 +1,339 @@ +#!/usr/bin/env bash + +# lsix: like ls, but for images. +# Shows thumbnails of images with titles directly in terminal. + +# Requirements: just ImageMagick (and a Sixel terminal, of course) + +# Version 1.6.2 +# B9 December 2018 + +# See end of file for USAGE. + + +# The following defaults may be overridden if autodetection succeeds. +numcolors=16 # Default number of colors in the palette. +background=white # Default montage background. +foreground=black # Default text color. +width=800 # Default width of screen in pixels. + +# Feel free to edit these defaults to your liking. +tilesize=120 # Width and height of each tile in the montage. +tilewidth=$tilesize # (or specify separately, if you prefer) +tileheight=$tilesize + +# If you get questionmarks for Unicode filenames, try using a different font. +# You can list fonts available using `convert -list font`. +#fontfamily=Droid-Sans-Fallback # Great Asian font coverage +#fontfamily=Dejavu-Sans # Wide coverage, comes with GNU/Linux +#fontfamily=Mincho # Wide coverage, comes with MS Windows + +# Default font size is based on width of each tile in montage. +#fontfamily=Monaco +fontfamily=MiscFixedSC613 +fontsize=$((tilewidth/10)) +fontsize=12 # (or set the point size directly, if you prefer) + +timeout=0.25 # How long to wait for terminal to respond + # to a control sequence (in seconds). + +# Sanity checks and compatibility +if [[ ${BASH_VERSINFO[0]} -eq 3 ]]; then + if bash --version | head -1 | grep -q "version 3"; then + cat <<-EOF >&2 + Error: The version of Bash is extremely out of date. + (2007, the same year Steve Jobs announced the iPhone!) + + This is almost always due to Apple's MacOS being silly. + Please let Apple know that their users expect current UNIX tools. + + In the meantime, try using "brew install bash". + EOF + exit 1 + else + exec bash "$0" "$@" || echo "Exec failed" >&2 + exit 1 + fi +fi + +if ! command -v montage >/dev/null; then + echo "Please install ImageMagick" >&2 + exit 1 +fi + +if command -v gsed >/dev/null; then + alias sed=gsed # Use GNU sed for MacOS & BSD +fi + +cleanup() { + echo -n $'\e\\' # Escape sequence to stop SIXEL. + stty echo # Reset terminal to show characters. + exit 0 +} +trap cleanup SIGINT SIGHUP SIGABRT EXIT + +autodetect() { + # Various terminal automatic configuration routines. + + # Don't show escape sequences the terminal doesn't understand. + stty -echo # Hush-a Mandara Ni Pari + + # IS TERMINAL SIXEL CAPABLE? # Send Device Attributes + IFS=";" read -a REPLY -s -t 1 -d "c" -p $'\e[c' >&2 + for code in "${REPLY[@]}"; do + if [[ $code == "4" ]]; then + hassixel=yup + break + fi + done + + # YAFT is vt102 compatible, cannot respond to vt220 escape sequence. + if [[ "$TERM" == yaft* ]]; then hassixel=yeah; fi + + if [[ -z "$hassixel" ]]; then + cat <<-EOF >&2 + Error: Your terminal does not report having sixel graphics support. + + Please use a sixel capable terminal, such as xterm -ti vt340, or + ask your terminal manufacturer to add sixel support. + + You may test your terminal by viewing a single image, like so: + + convert foo.jpg -geometry 800x480 sixel:- + + If your terminal actually does support sixel, please file a bug + report at http://github.com/hackerb9/lsix/issues + EOF + read -s -t 1 -d "c" -p $'\e[c' >&2 + if [[ "$REPLY" ]]; then + echo + cat -v <<< "(Please mention device attribute codes: ${REPLY}c)" + fi + + exit 1 + fi + + # ENABLE SIXEL SCROLLING so image will appear right after cursor. + if [[ $TERM != "mlterm" ]]; then + echo -ne $'\e[?80h' + else + # Except... mlterm (as of 3.5.0) has a bug that reverses the sense + echo -ne $'\e[?80l' + fi + + # TERMINAL COLOR AUTODETECTION. + # Find out how many color registers the terminal has + IFS=";" read -a REPLY -s -t ${timeout} -d "S" -p $'\e[?1;1;0S' >&2 + [[ ${REPLY[1]} == "0" ]] && numcolors=${REPLY[2]} + + # Bug workaround: mlterm does not report number of colors. + if [[ $TERM =~ mlterm ]]; then numcolors=1024; fi + # YAFT is vt102 compatible, cannot respond to vt220 escape sequence. + if [[ "$TERM" == yaft* ]]; then numcolors=256; fi + + # Increase colors, if needed + if [[ $numcolors -lt 256 ]]; then + # Attempt to set the number of colors to 256. + # This will work for xterm, but fail on a real vt340. + IFS=";" read -a REPLY -s -t ${timeout} -d "S" -p $'\e[?1;3;256S' >&2 + [[ ${REPLY[1]} == "0" ]] && numcolors=${REPLY[2]} + fi + + # Query the terminal background and foreground colors. + IFS=";:/" read -a REPLY -r -s -t ${timeout} -d "\\" -p $'\e]11;?\e\\' >&2 + if [[ ${REPLY[1]} =~ ^rgb ]]; then + # Return value format: $'\e]11;rgb:ffff/0000/ffff\e\\'. + # ImageMagick wants colors formatted as #ffff0000ffff. + background='#'${REPLY[2]}${REPLY[3]}${REPLY[4]%%$'\e'*} + IFS=";:/" read -a REPLY -r -s -t ${timeout} -d "\\" -p $'\e]10;?\e\\' >&2 + if [[ ${REPLY[1]} =~ ^rgb ]]; then + foreground='#'${REPLY[2]}${REPLY[3]}${REPLY[4]%%$'\e'*} + # Check for "Reverse Video" (DECSCNM screen mode). + IFS=";?$" read -a REPLY -s -t ${timeout} -d "y" -p $'\e[?5$p' + if [[ ${REPLY[2]} == 1 || ${REPLY[2]} == 3 ]]; then + temp=$foreground + foreground=$background + background=$temp + fi + fi + fi + # YAFT is vt102 compatible, cannot respond to vt220 escape sequence. + if [[ "$TERM" == yaft* ]]; then background=black; foreground=white; fi + + # Send control sequence to query the sixel graphics geometry to + # find out how large of a sixel image can be shown. + IFS=";" read -a REPLY -s -t ${timeout} -d "S" -p $'\e[?2;1;0S' >&2 + if [[ ${REPLY[2]} -gt 0 ]]; then + width=${REPLY[2]} + else + # Nope. Fall back to dtterm WindowOps to approximate sixel geometry. + IFS=";" read -a REPLY -s -t ${timeout} -d "t" -p $'\e[14t' >&2 + if [[ $? == 0 && ${REPLY[2]} -gt 0 ]]; then + width=${REPLY[2]} + fi + fi + + # BUG WORKAROUND: XTerm cannot show images wider than 1000px. + # Remove this hack once XTerm gets fixed. Last checked: XTerm(327) + if [[ $TERM =~ xterm && $width -ge 1000 ]]; then width=1000; fi + + # Space on either side of each tile is less than 0.5% of total screen width + tilexspace=$((width/201)) + tileyspace=$((tilexspace/2)) + # Figure out how many tiles we can fit per row. ("+ 1" is for -shadow). + numtiles=$((width/(tilewidth + 2*tilexspace + 1))) +} + +main() { + # Discover and setup the terminal + autodetect + + if [[ $# == 0 ]]; then + # No command line args? Use a sorted list of image files in CWD. + shopt -s nullglob nocaseglob nocasematch + set - *{jpg,jpeg,png,gif,tiff,tif,p?m,x[pb]m,bmp,ico,svg,eps} + [[ $# != 0 ]] || exit + readarray -t < <(printf "%s\n" "$@" | sort) + + # Only show first frame of animated GIFs if filename not specified. + for x in ${!MAPFILE[@]}; do + if [[ ${MAPFILE[$x]} =~ gif$ ]]; then + MAPFILE[$x]=":${MAPFILE[$x]}[0]" + fi + done + set - "${MAPFILE[@]}" + fi + + # Resize on load: Save memory by appending this suffix to every filename. + resize="[${tilewidth}x${tileheight}]" + + + imoptions="-tile ${numtiles}x1" # Each montage is 1 row x $numtiles columns + imoptions+=" -geometry ${tilewidth}x${tileheight}>+${tilexspace}+${tileyspace}" # Size of each tile and spacing + imoptions+=" -background $background -fill $foreground" # Use terminal's colors + imoptions+=" -auto-orient " # Properly rotate JPEGs from cameras + #if [[ $numcolors -gt 16 ]]; then + # imoptions+=" -shadow " # Just for fun :-) + #fi + + # See top of this file to change fontfamily and fontsize. + [[ "$fontfamily" ]] && imoptions+=" -font $fontfamily " + [[ "$fontsize" ]] && imoptions+=" -pointsize $fontsize " + + # Create and display montages one row at a time. + while [ $# -gt 0 ]; do + # While we still have images to process... + onerow=() + goal=$(($# - numtiles)) # How many tiles left after this row + while [ $# -gt 0 -a $# -gt $goal ]; do + len=${#onerow[@]} + onerow[len++]="-label" + onerow[len++]=$(processlabel "$1") + onerow[len++]="$1" + shift + done + montage "${onerow[@]}" $imoptions gif:- \ + | convert - -colors $numcolors sixel:- + done +} + +processlabel() { + # This routine is all about appeasing ImageMagick. + # 1. Remove silly [0] suffix and : prefix. + # 2. Quote percent backslash, and at sign. + # 3. Replace control characters with question marks. + # 4. If a filename is too long, remove extension (.jpg). + # 5. Split long filenames with newlines (recursively) + span=15 # filenames longer than span will be split + echo -n "$1" | + sed 's|^:||; s|\[0]$||;' | tr '[:cntrl:]' '?' | + awk -v span=$span -v ORS="" ' + function halve(s, l,h) { # l and h are locals + l=length(s); h=int(l/2); + if (l <= span) { return s; } + return halve(substr(s, 1, h)) "\n" halve(substr(s, h+1)); + } + { + if ( length($0) > span ) gsub(/\..?.?.?.?$/, ""); + print halve($0); + } + ' | + sed 's|%|%%|g; s|\\|\\\\|g; s|@|\\@|g;' +} + +#### + +main "$@" + +# Send an escape sequence and wait for a response from the terminal +# so that the program won't quit until images have finished transferring. +read -s -t 60 -d "c" -p $'\e[c' >&2 + + +###################################################################### +# NOTES: + +# Usage: lsix [ FILES ... ] + +# * FILES can be any image file that ImageMagick can handle. +# +# * If no FILES are specified the most common file extensions are tried. +# (For now, lsix only searches the current working directory.) +# +# * Non-bitmap graphics often work fine (.svg, .eps, .pdf, .xcf). +# +# * Files containing multiple images (e.g., animated GIFs) will show +# all the images if the filename is specified at the command line. +# Only the first frame will be shown if "lsix" is called with no +# arguments. +# +# * Because this uses escape sequences, it works seamlessly through ssh. +# +# * If your terminal supports reporting the background and foreground +# color, lsix will use those for the montage background and text fill. +# +# * If your terminal supports changing the number of color registers +# to improve the picture quality, lsix will do so. + +# * Only software needed is ImageMagick (e.g., apt-get install imagemagick). + +# Your terminal must support SIXEL graphics. E.g., +# +# xterm -ti vt340 + +# * To make vt340 be the default xterm type, set this in .Xresources: +# +# ! Allow sixel graphics. (Try: "convert -colors 16 foo.jpg sixel:-"). +# xterm*decTerminalID : vt340 + +# * Xterm does not support reporting the screen size in pixels unless +# you add this to your .Xresources: +# +# ! Allow xterm to read the terminal window size (op #14) +# xterm*allowWindowOps : False +# xterm*disallowedWindowOps : 1,2,3,4,5,6,7,8,9,11,13,18,19,20,21,GetSelection,SetSelection,SetWinLines,SetXprop + +# * Be cautious using lsix on videos (lsix *.avi) as ImageMagick will +# try to make a montage of every single frame and likely exhaust +# your memory and/or your patience. + +# BUGS + +# * Directories are not handled nicely. +# * ImageMagick's Montage doesn't handle long filenames nicely. +# * Some transparent images (many .eps files) presume a white background +# and will not show up if your terminal's background is black. +# * This file is getting awfully long for a one line kludge. :-) + +# LICENSE INFORMATION +# (AKA, You know your kludge has gotten out of hand when...) + +# Dual license: +# * You have all the freedoms permitted to you under the +# GNU GPL >=3. (See the included LICENSE file). + +# * Additionally, this program can be used under the terms of whatever +# license 'xterm' is using (now or in the future). This is primarily +# so that, if the xterm maintainer (currently Thomas E. Dickey) so +# wishes, this program may be included with xterm as a Sixel test. +# However, anyone who wishes to take advantage of this is free to do so. -- cgit v1.2.3 From aa1f45e33a957098615eca24d0b1b26c03b0eb57 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 18 Oct 2020 12:35:30 +0200 Subject: update --- .curlrc | 1 + bin/apac | 9 +++++++++ bin/vpac | 14 ++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 .curlrc create mode 100755 bin/apac create mode 100755 bin/vpac diff --git a/.curlrc b/.curlrc new file mode 100644 index 0000000..3e9b944 --- /dev/null +++ b/.curlrc @@ -0,0 +1 @@ +-L diff --git a/bin/apac b/bin/apac new file mode 100755 index 0000000..ed51734 --- /dev/null +++ b/bin/apac @@ -0,0 +1,9 @@ +#!/bin/sh +# pacman + fzf +#pacman -Slq | fzf --no-clear --multi --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' | xargs -ro sudo pacman -S +yay -Slqa | +fzf --no-clear --multi \ + --bind=left:preview-page-up --bind=right:preview-page-down \ + --preview-window=right:66% \ + --preview 'yay -Qil {1} 2>/dev/null && echo && pactree {1} || yay -Si {1}' | +xargs yay -S diff --git a/bin/vpac b/bin/vpac new file mode 100755 index 0000000..3b8c25c --- /dev/null +++ b/bin/vpac @@ -0,0 +1,14 @@ +#!/bin/sh +# pacman + fzf +#pacman -Slq | fzf --no-clear --multi --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' | xargs -ro sudo pacman -S + +# interactive select of package to remove +remove() { + pacman -Qqe | + fzf --no-clear --multi --bind=left:preview-page-up --bind=right:preview-page-down \ + --preview-window=right:66% \ + --preview 'cat <(yay -Si {1}) <(pacman -Fl {1} 2>/dev/null | awk "!/\/$/ {print $2}")' | + xargs -ro yay -Rns +} + +remove -- cgit v1.2.3 From 3bb7e9d0b1d7bc406bd2361f7484d4484eb483b1 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 1 Nov 2020 09:32:20 +0100 Subject: update --- .bash-powerline.sh | 2 +- .bashrc | 9 +++------ .config/i3/config | 3 +++ .vimrc | 5 ++++- bin/fpac | 8 +++++++- bin/hdmi | 3 ++- bin/icat | 30 ++++++++++++++++++++++++++++-- bin/idot | 4 +++- 8 files changed, 51 insertions(+), 13 deletions(-) diff --git a/.bash-powerline.sh b/.bash-powerline.sh index ccb7a5d..626157a 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -89,7 +89,7 @@ __powerline() { [ "$SSH_TTY" ] && PS1=": $host:$cwd$git$symbol" || PS1=": $cwd$git$symbol" } - PROMPT_DIRTRIM=2 + PROMPT_DIRTRIM=1 PROMPT_COMMAND="ps1${PROMPT_COMMAND:+; $PROMPT_COMMAND}" } diff --git a/.bashrc b/.bashrc index 229f627..a78d064 100644 --- a/.bashrc +++ b/.bashrc @@ -32,12 +32,8 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } #export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta) #export LESS_TERMCAP_ue=$'\E[0m' # end underline -# bat -export BAT_THEME='github' - # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' -#export GNUTERM='sixelgd enhanced truecolor small' # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' @@ -60,8 +56,8 @@ alias go14='go1.14.2' alias gob='go build' alias goh='p go help' alias god='p go doc' -alias gtr='go test -run' -alias gtb='go test -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' +alias gtr='go test -v -run' +alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' #alias vi='vim' alias rvi='sudo vim' alias rxt='sudo xt' @@ -110,3 +106,4 @@ unset base # Display git status in prompt . ~/.bash-powerline.sh +# export PS1='; ' diff --git a/.config/i3/config b/.config/i3/config index 22a61af..9ef0672 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -122,6 +122,9 @@ bindsym $mod+End exec --no-startup-id playerctl stop bindsym $mod+Next exec --no-startup-id playerctl next bindsym $mod+Prior exec --no-startup-id playerctl previous +# Screen shot +bindSym --release Print exec --no-startup-id shot + # jump to urgent bindsym $mod+x [urgent=latest] focus diff --git a/.vimrc b/.vimrc index 79cd484..58841c0 100644 --- a/.vimrc +++ b/.vimrc @@ -1,7 +1,7 @@ " set background= set t_te= t_ti= laststatus=2 -syntax on +syntax off filetype on filetype plugin on filetype plugin indent on @@ -9,7 +9,9 @@ let mapleader = "," " vimki plugin let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" +autocmd filetype vimki syntax on autocmd filetype vimki set autowrite +autocmd filetype vimki setlocal spell spelllang=fr " vim-go plugin let g:go_def_mode = "gopls" @@ -17,6 +19,7 @@ let g:go_info_mode = "gopls" let g:go_list_type = "quickfix" let g:go_fmt_command = "goimports" let g:go_metalinter_command = "golangci-lint" +autocmd FileType go syntax on autocmd FileType go nmap b (go-build) autocmd FileType go nmap i (go-info) autocmd FileType go nmap r (go-run) diff --git a/bin/fpac b/bin/fpac index db30d36..6207191 100755 --- a/bin/fpac +++ b/bin/fpac @@ -1,3 +1,9 @@ #!/bin/sh # pacman + fzf -pacman -Slq | fzf --no-clear --multi --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' | xargs -ro sudo pacman -S +#pacman -Slq | fzf --no-clear --multi --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' | xargs -ro sudo pacman -S +pacman -Slq | +fzf --no-clear --multi \ + --bind=left:preview-page-up --bind=right:preview-page-down \ + --preview-window=right:66% \ + --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} 2>/dev/null | awk "! /\/$/ {print \$2}")' | +xargs -ro sudo pacman -S diff --git a/bin/hdmi b/bin/hdmi index 75e6f37..0b04531 100755 --- a/bin/hdmi +++ b/bin/hdmi @@ -1,7 +1,8 @@ #!/bin/sh # Toggle auxiliary HDMI screen on/off when connected/disconnected. -opt="--auto --right-of eDP-1" +opt="--auto --left-of eDP-1" +#opt="--auto --right-of eDP-1" #opt="--auto --above eDP-1" # Also add the following rule to /etc/udev/rules.d/hdmi.rules diff --git a/bin/icat b/bin/icat index b15a6d4..702d648 100755 --- a/bin/icat +++ b/bin/icat @@ -1,2 +1,28 @@ -#!/bin/sh -exec convert -resize '800x480>' -flatten -- ${1:--} sixel:- +#!/bin/sh -e +# Display images directly in terminal. +# Tested with xterm v361 + +# 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. +maxsize() { + [ "$WINDOWID" ] || { echo "640x480>"; return; } + xwininfo -id "$WINDOWID" | { + w=1000 h=1000 + while read -r a b; do + case $a in + (Width:) [ $((b < w)) = 1 ] && w=$b ;; + (Height:) [ $((b < h)) = 1 ] && h=$b ;; + esac + done + echo "${w}x$h" + } +} + +# 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:--} diff --git a/bin/idot b/bin/idot index d36d947..44387e8 100755 --- a/bin/idot +++ b/bin/idot @@ -1,2 +1,4 @@ #!/bin/sh -dot -Tpng -Gsize=8 "${1:-}" | convert -- - sixel:- +# dot -Gsize=9 -Nshape=box -Nstyle=rounded -Tsvg | convert -- - sixel:/dev/tty +# dot -Gsize=9 -Nfontname=Helvetica -Tsvg | convert -- - sixel:/-dev/tty +dot -Gsize=9 -Nfontname=Arial -Tpng | icat - /dev/tty -- cgit v1.2.3 From b44d13927d1296c6d4eecbf42448372948e74ad8 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 4 Jan 2021 09:16:43 +0100 Subject: update --- .bashrc | 9 +++++++++ .config/i3/config | 1 + .i3status.conf | 3 ++- .profile | 6 +++--- .tmux.conf | 3 +++ .vim/spell/fr.utf-8.add | 1 + .vimrc | 1 + .xinitrc | 1 + .xsession | 24 ++++++++++++++++++++++++ bin/hdmi | 9 ++++++--- bin/vr | 2 ++ 11 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .tmux.conf create mode 100644 .vim/spell/fr.utf-8.add create mode 100755 .xsession create mode 100755 bin/vr diff --git a/.bashrc b/.bashrc index a78d064..2f6a357 100644 --- a/.bashrc +++ b/.bashrc @@ -80,6 +80,15 @@ alias wai='~/go/src/github.co/traefik/whoami/whoami' # yaegi debug export YAEGI_DOT_CMD='dotty -' +mosht() { mosh "$@" -- tmux new -A; } +export -f mosht + +ssht() { ssh -t "$@" -- tmux new -A; } +export -f ssht + +mpvx() { mpv --vo=sixel --profile=sw-fast --really-quiet "$@"; } +export -f mpvx + tfk() { ~/go/src/github.com/traefik/traefik/traefik "$@"; } export -f tfk diff --git a/.config/i3/config b/.config/i3/config index 9ef0672..48c461c 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -65,6 +65,7 @@ for_window [title="Gestionnaire de tâches – Chromium"] floating enable for_window [instance="DOTTY"] floating enable for_window [class="discord"] floating enable for_window [class="Display"] floating enable +for_window [class="Feedreader"] floating enable for_window [class="feh"] floating enable for_window [class="firefox"] floating enable for_window [class="Geeqie"] floating enable diff --git a/.i3status.conf b/.i3status.conf index b3af3a3..229dfc1 100644 --- a/.i3status.conf +++ b/.i3status.conf @@ -92,7 +92,8 @@ memory { cpu_temperature 0 { format = "🌡%degrees °C" - path = "/sys/class/hwmon/hwmon0/temp1_input" + #path = "/sys/class/hwmon/hwmon0/temp1_input" + path = "/sys/class/hwmon/hwmon6/temp1_input" } tztime local { diff --git a/.profile b/.profile index cb09e87..acb8299 100644 --- a/.profile +++ b/.profile @@ -5,6 +5,6 @@ PATH=~/bin:$PATH:~/go/bin [ "${SHELL##*/}" = bash ] && . ~/.bashrc # Last action: auto start X11 when logged on first console -case $HOSTNAME in -([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; -esac +#case $HOSTNAME in +#([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; +#esac diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..8d624a0 --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,3 @@ +set-option -g prefix ² +unbind-key C-b +bind-key ² send-prefix diff --git a/.vim/spell/fr.utf-8.add b/.vim/spell/fr.utf-8.add new file mode 100644 index 0000000..8bd6403 --- /dev/null +++ b/.vim/spell/fr.utf-8.add @@ -0,0 +1 @@ +Flo diff --git a/.vimrc b/.vimrc index 58841c0..84c082d 100644 --- a/.vimrc +++ b/.vimrc @@ -12,6 +12,7 @@ let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite autocmd filetype vimki setlocal spell spelllang=fr +autocmd filetype vimki nmap z :FZF ~/Wiki " vim-go plugin let g:go_def_mode = "gopls" diff --git a/.xinitrc b/.xinitrc index c0b8589..f982ca7 100644 --- a/.xinitrc +++ b/.xinitrc @@ -10,6 +10,7 @@ xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling E # Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards #setxkbmap fr #xk +hdmi xrdb ~/.Xresources #xsetroot -solid rgb:3/4/5 diff --git a/.xsession b/.xsession new file mode 100755 index 0000000..f982ca7 --- /dev/null +++ b/.xsession @@ -0,0 +1,24 @@ +#!/bin/sh +# start pulseaudio on crux only. Should be handled by systemd on arch +#pulseaudio --start --exit-idle-time=-1 --log-target=syslog & + +# enable tapping and natural scrolling on touchpad +# see xinput --list[-props] for ids +xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1 +xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1 + +# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards +#setxkbmap fr +#xk +hdmi + +xrdb ~/.Xresources +#xsetroot -solid rgb:3/4/5 +xsetroot -solid rgb:1/3/4 +#feh --bg-fill ~/Downloads/Alaska_Range.jpg +#conky +#slock + +# Start window manager +#exec fvwm +exec i3 diff --git a/bin/hdmi b/bin/hdmi index 0b04531..d6f206a 100755 --- a/bin/hdmi +++ b/bin/hdmi @@ -1,12 +1,15 @@ #!/bin/sh # Toggle auxiliary HDMI screen on/off when connected/disconnected. -opt="--auto --left-of eDP-1" +opt="--auto --left-of eDP1" #opt="--auto --right-of eDP-1" #opt="--auto --above eDP-1" # Also add the following rule to /etc/udev/rules.d/hdmi.rules # KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/marc/.Xauthority", RUN+="/home/marc/bin/hdmi" -xrandr | grep -q 'HDMI-1 connected' || opt="--off" -xrandr --output HDMI-1 $opt +# wait for the screen to settle +sleep 3 + +xrandr | grep -q 'HDMI1 connected' || opt="--off" +xrandr --output HDMI1 $opt diff --git a/bin/vr b/bin/vr new file mode 100755 index 0000000..189d83e --- /dev/null +++ b/bin/vr @@ -0,0 +1,2 @@ +#!/bin/sh +exec chromium --user-data-dir=/home/marc/vr --silent-debugger-extension-api -- cgit v1.2.3 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 From 9aa203f7d7a1899aac7bb7d8209cc2a394ffdbd8 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 7 Feb 2021 12:03:10 +0100 Subject: update --- .Xresources | 2 ++ .bashrc | 3 +++ bin/byo | 6 ++++-- bin/repairboot | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 bin/repairboot diff --git a/.Xresources b/.Xresources index a653af4..b1c3e3d 100644 --- a/.Xresources +++ b/.Xresources @@ -20,6 +20,8 @@ xterm*termName: xterm-256color xterm*VT100.Translations: #override \ Ctrl Next: smaller-vt-font() \n\ Ctrl Prior: larger-vt-font() \n +xterm*faceName: DejaVu Sans Mono +xterm*faceSize: 10 ! xterm*font: 7x14 ! Allow sixel graphics. (Try: "convert -colors 16 foo.jpg sixel:-"). xterm*decTerminalID: vt340 diff --git a/.bashrc b/.bashrc index 90c903e..c086d45 100644 --- a/.bashrc +++ b/.bashrc @@ -128,3 +128,6 @@ unset base # Display git status in prompt . ~/.bash-powerline.sh # export PS1='; ' + +# load Nix config files (aka auto-completion etc.) +export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" diff --git a/bin/byo b/bin/byo index 389e112..bc09fb8 100755 --- a/bin/byo +++ b/bin/byo @@ -2,7 +2,7 @@ # Backup to yoda [ "$USER" = root ] || exec sudo "$0" "$@" -usage='Usage: byo [-cdk] +usage='Usage: byo [-cdk] [/dev/sda2] Backup local disk to yoda external disk. Options: @@ -19,10 +19,12 @@ while getopts :Ccdk opt; do done shift $((OPTIND - 1)) +dev=$1 yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb' +[ "$dev" ] || dev=$(blkid --uuid "$yoda_uuid") dest=/mnt/backup/$(hostname) -[ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda +[ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$dev" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt time backup -v -d "$dest" [ ! "$optC" ] || backup -v -d "$dest" clean diff --git a/bin/repairboot b/bin/repairboot new file mode 100755 index 0000000..6cb9bb4 --- /dev/null +++ b/bin/repairboot @@ -0,0 +1,14 @@ +#!/bin/sh -ex + +# Repair boot from yoda (for acer swift5) + + +[ "$USER" = root ] || exec sudo "$0" "$@" + +cryptsetup open /dev/nvme0n1p2 swift +mount /dev/mapper/swift /mnt +mount /dev/nvme0n1p1 /mnt/boot + +arch-chroot /mnt << EOT +bootctl --path=/boot install +EOT -- cgit v1.2.3 From 3f71e5e47055550d187eb1b60d889f82bb1de28f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 14 Feb 2021 18:59:26 +0100 Subject: update --- .Xresources | 9 ++++--- .gitconfig | 2 ++ .vimrc | 2 +- .xinitrc | 24 ----------------- .xsession | 24 ----------------- .zsh-powerline.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/open | 11 -------- 7 files changed, 88 insertions(+), 64 deletions(-) delete mode 100644 .xinitrc delete mode 100755 .xsession create mode 100644 .zsh-powerline.sh delete mode 100755 bin/open diff --git a/.Xresources b/.Xresources index b1c3e3d..be0e99f 100644 --- a/.Xresources +++ b/.Xresources @@ -18,10 +18,11 @@ URxvt.keysym.C-Next: font-size:decrease xterm*termName: xterm-256color xterm*VT100.Translations: #override \ - Ctrl Next: smaller-vt-font() \n\ - Ctrl Prior: larger-vt-font() \n -xterm*faceName: DejaVu Sans Mono -xterm*faceSize: 10 + Meta minus: smaller-vt-font() \n\ + Meta equal: larger-vt-font() \n +xterm*cursorColor: red +!xterm*faceName: DejaVu Sans Mono +!xterm*faceSize: 10 ! xterm*font: 7x14 ! Allow sixel graphics. (Try: "convert -colors 16 foo.jpg sixel:-"). xterm*decTerminalID: vt340 diff --git a/.gitconfig b/.gitconfig index eaefde0..cefd5e5 100644 --- a/.gitconfig +++ b/.gitconfig @@ -13,3 +13,5 @@ name = Marc Vertes [pull] rebase = false +[hub] + protocol = ssh diff --git a/.vimrc b/.vimrc index f8fce87..671af49 100644 --- a/.vimrc +++ b/.vimrc @@ -13,7 +13,7 @@ let g:fzf_preview = 'cat {}' let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite -autocmd filetype vimki setlocal spell spelllang=fr +"autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki autocmd filetype vimki nnoremap = YpVr= diff --git a/.xinitrc b/.xinitrc deleted file mode 100644 index f982ca7..0000000 --- a/.xinitrc +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# start pulseaudio on crux only. Should be handled by systemd on arch -#pulseaudio --start --exit-idle-time=-1 --log-target=syslog & - -# enable tapping and natural scrolling on touchpad -# see xinput --list[-props] for ids -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1 -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1 - -# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards -#setxkbmap fr -#xk -hdmi - -xrdb ~/.Xresources -#xsetroot -solid rgb:3/4/5 -xsetroot -solid rgb:1/3/4 -#feh --bg-fill ~/Downloads/Alaska_Range.jpg -#conky -#slock - -# Start window manager -#exec fvwm -exec i3 diff --git a/.xsession b/.xsession deleted file mode 100755 index f982ca7..0000000 --- a/.xsession +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# start pulseaudio on crux only. Should be handled by systemd on arch -#pulseaudio --start --exit-idle-time=-1 --log-target=syslog & - -# enable tapping and natural scrolling on touchpad -# see xinput --list[-props] for ids -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1 -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1 - -# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards -#setxkbmap fr -#xk -hdmi - -xrdb ~/.Xresources -#xsetroot -solid rgb:3/4/5 -xsetroot -solid rgb:1/3/4 -#feh --bg-fill ~/Downloads/Alaska_Range.jpg -#conky -#slock - -# Start window manager -#exec fvwm -exec i3 diff --git a/.zsh-powerline.sh b/.zsh-powerline.sh new file mode 100644 index 0000000..f0835a4 --- /dev/null +++ b/.zsh-powerline.sh @@ -0,0 +1,80 @@ +# Colorscheme +readonly COLOR_CWD='blue' +readonly COLOR_GIT='cyan' +readonly COLOR_SUCCESS='green' +readonly COLOR_FAILURE='red' +readonly COLOR_TIME='cyan' + +readonly SYMBOL_GIT_BRANCH='⑂' +readonly SYMBOL_GIT_MODIFIED='*' +readonly SYMBOL_GIT_PUSH='↑' +readonly SYMBOL_GIT_PULL='↓' +readonly PS_SYMBOL='$' + +_git_info() { + hash git 2>/dev/null || return # git not found + + # get current branch + local ref=$(git symbolic-ref --short HEAD 2>/dev/null) + + if [[ -n "$ref" ]]; then + # prepend branch symbol + ref=$SYMBOL_GIT_BRANCH$ref + else + # get most recent tag or abbreviated unique hash + ref=$(git describe --tags --always 2>/dev/null) + fi + + [[ -n "$ref" ]] || return # not a git repo + + local marks + + # scan first two lines of output from `git status` + while IFS= read -r line; do + if [[ $line =~ ^## ]]; then # header line + [[ $line =~ ahead\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PUSH$match[1]" + [[ $line =~ behind\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PULL$match[1]" + else # branch is modified if output contains more lines after the header line + marks="$SYMBOL_GIT_MODIFIED$marks" + break + fi + done < <(git status --porcelain --branch 2>/dev/null) # note the space between the two < + + # print without a trailing newline + printf " $ref$marks" +} + + +_config_prompt() { + # Color coding based on exit code of the previous command. Note this must + # be dealt with in the beginning of the function, otherwise the $? will not + # match the right command executed. + + if [[ $? -eq 0 ]]; then + local symbol="%F{$COLOR_SUCCESS}$PS_SYMBOL%f" + else + local symbol="%F{$COLOR_FAILURE}$PS_SYMBOL%f" + fi + + local cwd="%F{$COLOR_CWD}%~%f" + local git="%F{$COLOR_GIT}$(_git_info)%f" + local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" + + PROMPT="$cwd$git $symbol " + RPROMPT="$time" +} + + +# useful zsh hook functions + +precmd() { # run before each prompt + _config_prompt +} + + +preexec() { # run after user command is read and about to execute +} + + +chpwd() { # run when changing current working directory +} diff --git a/bin/open b/bin/open deleted file mode 100755 index 0fa97a7..0000000 --- a/bin/open +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -exec >/tmp/open.out 2>&1 -set -x - -cmd=xdg-open -case $1 in -(*.mkv|*.mp4) cmd=vlc;; -esac - -exec $cmd "$@" -- cgit v1.2.3 From fdbb4f3bd7a651834904d0446303b10a76a6e349 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 14 Feb 2021 18:59:26 +0100 Subject: update --- .Xresources | 9 ++++--- .gitconfig | 2 ++ .vimrc | 2 +- .xinitrc | 24 ----------------- .xsession | 24 ----------------- .zsh-powerline.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/open | 11 -------- 7 files changed, 88 insertions(+), 64 deletions(-) delete mode 100644 .xinitrc delete mode 100755 .xsession create mode 100644 .zsh-powerline.sh delete mode 100755 bin/open diff --git a/.Xresources b/.Xresources index b1c3e3d..be0e99f 100644 --- a/.Xresources +++ b/.Xresources @@ -18,10 +18,11 @@ URxvt.keysym.C-Next: font-size:decrease xterm*termName: xterm-256color xterm*VT100.Translations: #override \ - Ctrl Next: smaller-vt-font() \n\ - Ctrl Prior: larger-vt-font() \n -xterm*faceName: DejaVu Sans Mono -xterm*faceSize: 10 + Meta minus: smaller-vt-font() \n\ + Meta equal: larger-vt-font() \n +xterm*cursorColor: red +!xterm*faceName: DejaVu Sans Mono +!xterm*faceSize: 10 ! xterm*font: 7x14 ! Allow sixel graphics. (Try: "convert -colors 16 foo.jpg sixel:-"). xterm*decTerminalID: vt340 diff --git a/.gitconfig b/.gitconfig index eaefde0..cefd5e5 100644 --- a/.gitconfig +++ b/.gitconfig @@ -13,3 +13,5 @@ name = Marc Vertes [pull] rebase = false +[hub] + protocol = ssh diff --git a/.vimrc b/.vimrc index f8fce87..671af49 100644 --- a/.vimrc +++ b/.vimrc @@ -13,7 +13,7 @@ let g:fzf_preview = 'cat {}' let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite -autocmd filetype vimki setlocal spell spelllang=fr +"autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki autocmd filetype vimki nnoremap = YpVr= diff --git a/.xinitrc b/.xinitrc deleted file mode 100644 index f982ca7..0000000 --- a/.xinitrc +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# start pulseaudio on crux only. Should be handled by systemd on arch -#pulseaudio --start --exit-idle-time=-1 --log-target=syslog & - -# enable tapping and natural scrolling on touchpad -# see xinput --list[-props] for ids -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1 -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1 - -# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards -#setxkbmap fr -#xk -hdmi - -xrdb ~/.Xresources -#xsetroot -solid rgb:3/4/5 -xsetroot -solid rgb:1/3/4 -#feh --bg-fill ~/Downloads/Alaska_Range.jpg -#conky -#slock - -# Start window manager -#exec fvwm -exec i3 diff --git a/.xsession b/.xsession deleted file mode 100755 index f982ca7..0000000 --- a/.xsession +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# start pulseaudio on crux only. Should be handled by systemd on arch -#pulseaudio --start --exit-idle-time=-1 --log-target=syslog & - -# enable tapping and natural scrolling on touchpad -# see xinput --list[-props] for ids -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1 -xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1 - -# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards -#setxkbmap fr -#xk -hdmi - -xrdb ~/.Xresources -#xsetroot -solid rgb:3/4/5 -xsetroot -solid rgb:1/3/4 -#feh --bg-fill ~/Downloads/Alaska_Range.jpg -#conky -#slock - -# Start window manager -#exec fvwm -exec i3 diff --git a/.zsh-powerline.sh b/.zsh-powerline.sh new file mode 100644 index 0000000..f0835a4 --- /dev/null +++ b/.zsh-powerline.sh @@ -0,0 +1,80 @@ +# Colorscheme +readonly COLOR_CWD='blue' +readonly COLOR_GIT='cyan' +readonly COLOR_SUCCESS='green' +readonly COLOR_FAILURE='red' +readonly COLOR_TIME='cyan' + +readonly SYMBOL_GIT_BRANCH='⑂' +readonly SYMBOL_GIT_MODIFIED='*' +readonly SYMBOL_GIT_PUSH='↑' +readonly SYMBOL_GIT_PULL='↓' +readonly PS_SYMBOL='$' + +_git_info() { + hash git 2>/dev/null || return # git not found + + # get current branch + local ref=$(git symbolic-ref --short HEAD 2>/dev/null) + + if [[ -n "$ref" ]]; then + # prepend branch symbol + ref=$SYMBOL_GIT_BRANCH$ref + else + # get most recent tag or abbreviated unique hash + ref=$(git describe --tags --always 2>/dev/null) + fi + + [[ -n "$ref" ]] || return # not a git repo + + local marks + + # scan first two lines of output from `git status` + while IFS= read -r line; do + if [[ $line =~ ^## ]]; then # header line + [[ $line =~ ahead\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PUSH$match[1]" + [[ $line =~ behind\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PULL$match[1]" + else # branch is modified if output contains more lines after the header line + marks="$SYMBOL_GIT_MODIFIED$marks" + break + fi + done < <(git status --porcelain --branch 2>/dev/null) # note the space between the two < + + # print without a trailing newline + printf " $ref$marks" +} + + +_config_prompt() { + # Color coding based on exit code of the previous command. Note this must + # be dealt with in the beginning of the function, otherwise the $? will not + # match the right command executed. + + if [[ $? -eq 0 ]]; then + local symbol="%F{$COLOR_SUCCESS}$PS_SYMBOL%f" + else + local symbol="%F{$COLOR_FAILURE}$PS_SYMBOL%f" + fi + + local cwd="%F{$COLOR_CWD}%~%f" + local git="%F{$COLOR_GIT}$(_git_info)%f" + local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" + + PROMPT="$cwd$git $symbol " + RPROMPT="$time" +} + + +# useful zsh hook functions + +precmd() { # run before each prompt + _config_prompt +} + + +preexec() { # run after user command is read and about to execute +} + + +chpwd() { # run when changing current working directory +} diff --git a/bin/open b/bin/open deleted file mode 100755 index 0fa97a7..0000000 --- a/bin/open +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -exec >/tmp/open.out 2>&1 -set -x - -cmd=xdg-open -case $1 in -(*.mkv|*.mp4) cmd=vlc;; -esac - -exec $cmd "$@" -- cgit v1.2.3 From 90ec7bf2b039599f987066c4e16b5817743fafcf Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 15 Feb 2021 17:19:55 +0100 Subject: update --- .Xresources | 1 + .vimrc | 2 ++ .zsh-powerline.sh | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.Xresources b/.Xresources index be0e99f..1514003 100644 --- a/.Xresources +++ b/.Xresources @@ -21,6 +21,7 @@ xterm*VT100.Translations: #override \ Meta minus: smaller-vt-font() \n\ Meta equal: larger-vt-font() \n xterm*cursorColor: red +xterm*visualBell: true !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.vimrc b/.vimrc index 671af49..9e45e2d 100644 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,8 @@ " set background= set t_te= t_ti= laststatus=2 +set rtp+=/opt/local/share/fzf/vim + syntax off filetype on filetype plugin on diff --git a/.zsh-powerline.sh b/.zsh-powerline.sh index f0835a4..e3f05f1 100644 --- a/.zsh-powerline.sh +++ b/.zsh-powerline.sh @@ -1,9 +1,10 @@ # Colorscheme readonly COLOR_CWD='blue' readonly COLOR_GIT='cyan' -readonly COLOR_SUCCESS='green' +#readonly COLOR_SUCCESS='green' +readonly COLOR_SUCCESS='blue' readonly COLOR_FAILURE='red' -readonly COLOR_TIME='cyan' +#readonly COLOR_TIME='cyan' readonly SYMBOL_GIT_BRANCH='⑂' readonly SYMBOL_GIT_MODIFIED='*' @@ -56,12 +57,13 @@ _config_prompt() { local symbol="%F{$COLOR_FAILURE}$PS_SYMBOL%f" fi - local cwd="%F{$COLOR_CWD}%~%f" + #local cwd="%F{$COLOR_CWD}%~%f" + local cwd="%F{$COLOR_CWD}%2~%f" local git="%F{$COLOR_GIT}$(_git_info)%f" - local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" + #local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" PROMPT="$cwd$git $symbol " - RPROMPT="$time" + #RPROMPT="$time" } -- cgit v1.2.3 From 4ae067058d3cef9e169869215dd29c7d3534d1d2 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 15 Feb 2021 17:19:55 +0100 Subject: update --- .Xresources | 1 + .vimrc | 2 ++ .zsh-powerline.sh | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.Xresources b/.Xresources index be0e99f..1514003 100644 --- a/.Xresources +++ b/.Xresources @@ -21,6 +21,7 @@ xterm*VT100.Translations: #override \ Meta minus: smaller-vt-font() \n\ Meta equal: larger-vt-font() \n xterm*cursorColor: red +xterm*visualBell: true !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.vimrc b/.vimrc index 671af49..9e45e2d 100644 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,8 @@ " set background= set t_te= t_ti= laststatus=2 +set rtp+=/opt/local/share/fzf/vim + syntax off filetype on filetype plugin on diff --git a/.zsh-powerline.sh b/.zsh-powerline.sh index f0835a4..e3f05f1 100644 --- a/.zsh-powerline.sh +++ b/.zsh-powerline.sh @@ -1,9 +1,10 @@ # Colorscheme readonly COLOR_CWD='blue' readonly COLOR_GIT='cyan' -readonly COLOR_SUCCESS='green' +#readonly COLOR_SUCCESS='green' +readonly COLOR_SUCCESS='blue' readonly COLOR_FAILURE='red' -readonly COLOR_TIME='cyan' +#readonly COLOR_TIME='cyan' readonly SYMBOL_GIT_BRANCH='⑂' readonly SYMBOL_GIT_MODIFIED='*' @@ -56,12 +57,13 @@ _config_prompt() { local symbol="%F{$COLOR_FAILURE}$PS_SYMBOL%f" fi - local cwd="%F{$COLOR_CWD}%~%f" + #local cwd="%F{$COLOR_CWD}%~%f" + local cwd="%F{$COLOR_CWD}%2~%f" local git="%F{$COLOR_GIT}$(_git_info)%f" - local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" + #local time="%F{$COLOR_TIME}%D{%H:%M:%S}%f" PROMPT="$cwd$git $symbol " - RPROMPT="$time" + #RPROMPT="$time" } -- cgit v1.2.3 From 17b6d57450341896743f31ae67921d2abd8551bc Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 22 Feb 2021 17:10:51 +0100 Subject: updated --- .Xresources | 1 + .bashrc | 2 ++ .gitconfig | 2 ++ .vimrc | 3 +-- bin/gauth | 4 +++- bin/p4a | 3 +++ bin/xt | 3 ++- 7 files changed, 14 insertions(+), 4 deletions(-) create mode 100755 bin/p4a diff --git a/.Xresources b/.Xresources index 1514003..bdf02a3 100644 --- a/.Xresources +++ b/.Xresources @@ -22,6 +22,7 @@ xterm*VT100.Translations: #override \ Meta equal: larger-vt-font() \n xterm*cursorColor: red xterm*visualBell: true +xterm*geometry: 100x32 !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.bashrc b/.bashrc index c086d45..95f2377 100644 --- a/.bashrc +++ b/.bashrc @@ -131,3 +131,5 @@ unset base # load Nix config files (aka auto-completion etc.) export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/.gitconfig b/.gitconfig index cefd5e5..11f0d14 100644 --- a/.gitconfig +++ b/.gitconfig @@ -15,3 +15,5 @@ rebase = false [hub] protocol = ssh +[init] + defaultBranch = main diff --git a/.vimrc b/.vimrc index 9e45e2d..5220bba 100644 --- a/.vimrc +++ b/.vimrc @@ -1,14 +1,13 @@ " set background= set t_te= t_ti= laststatus=2 -set rtp+=/opt/local/share/fzf/vim - syntax off filetype on filetype plugin on filetype plugin indent on let mapleader = "," +set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' " vimki plugin diff --git a/bin/gauth b/bin/gauth index 575d6fc..699cd84 100755 --- a/bin/gauth +++ b/bin/gauth @@ -1,7 +1,9 @@ #!/bin/sh # Use backup from andOTP -gpg -qd ~/.otp_accounts.json.gpg | +#gpg -qd ~/otp_accounts.json.gpg.pgp | +#gpg -qd ~/.otp_accounts.json.gpg | +cat ~/otp_accounts.json | jq -r '.[] | "\(.label) \(.secret)"' | while read -r l s; do echo "$l $(oathtool --totp -b "$s")" diff --git a/bin/p4a b/bin/p4a new file mode 100755 index 0000000..30e54ff --- /dev/null +++ b/bin/p4a @@ -0,0 +1,3 @@ +#!/bin/sh +adb forward tcp:8222 tcp:8022 +ssh ssh://u0_a250@localhost:8222 diff --git a/bin/xt b/bin/xt index 71b92d3..9395b3e 100755 --- a/bin/xt +++ b/bin/xt @@ -1,4 +1,5 @@ #!/bin/sh -exec xterm -sl 500 -j -cr red "$@" & +#exec xterm -sl 500 -j -cr red "$@" & +exec xterm "$@" & #cmd="urxvtc ${@:--T $HOSTNAME}" #eval "$cmd" || { [ $? = 2 ] && urxvtd -q -o -f && eval "$cmd"; } -- cgit v1.2.3 From 98d3c3b82a8359d9cd1a8e5b3a6e1afe5fa56914 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 22 Feb 2021 17:10:51 +0100 Subject: updated --- .Xresources | 1 + .bashrc | 2 ++ .gitconfig | 2 ++ .vimrc | 3 +-- bin/gauth | 4 +++- bin/p4a | 3 +++ bin/xt | 3 ++- 7 files changed, 14 insertions(+), 4 deletions(-) create mode 100755 bin/p4a diff --git a/.Xresources b/.Xresources index 1514003..bdf02a3 100644 --- a/.Xresources +++ b/.Xresources @@ -22,6 +22,7 @@ xterm*VT100.Translations: #override \ Meta equal: larger-vt-font() \n xterm*cursorColor: red xterm*visualBell: true +xterm*geometry: 100x32 !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.bashrc b/.bashrc index c086d45..95f2377 100644 --- a/.bashrc +++ b/.bashrc @@ -131,3 +131,5 @@ unset base # load Nix config files (aka auto-completion etc.) export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/.gitconfig b/.gitconfig index cefd5e5..11f0d14 100644 --- a/.gitconfig +++ b/.gitconfig @@ -15,3 +15,5 @@ rebase = false [hub] protocol = ssh +[init] + defaultBranch = main diff --git a/.vimrc b/.vimrc index 9e45e2d..5220bba 100644 --- a/.vimrc +++ b/.vimrc @@ -1,14 +1,13 @@ " set background= set t_te= t_ti= laststatus=2 -set rtp+=/opt/local/share/fzf/vim - syntax off filetype on filetype plugin on filetype plugin indent on let mapleader = "," +set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' " vimki plugin diff --git a/bin/gauth b/bin/gauth index 575d6fc..699cd84 100755 --- a/bin/gauth +++ b/bin/gauth @@ -1,7 +1,9 @@ #!/bin/sh # Use backup from andOTP -gpg -qd ~/.otp_accounts.json.gpg | +#gpg -qd ~/otp_accounts.json.gpg.pgp | +#gpg -qd ~/.otp_accounts.json.gpg | +cat ~/otp_accounts.json | jq -r '.[] | "\(.label) \(.secret)"' | while read -r l s; do echo "$l $(oathtool --totp -b "$s")" diff --git a/bin/p4a b/bin/p4a new file mode 100755 index 0000000..30e54ff --- /dev/null +++ b/bin/p4a @@ -0,0 +1,3 @@ +#!/bin/sh +adb forward tcp:8222 tcp:8022 +ssh ssh://u0_a250@localhost:8222 diff --git a/bin/xt b/bin/xt index 71b92d3..9395b3e 100755 --- a/bin/xt +++ b/bin/xt @@ -1,4 +1,5 @@ #!/bin/sh -exec xterm -sl 500 -j -cr red "$@" & +#exec xterm -sl 500 -j -cr red "$@" & +exec xterm "$@" & #cmd="urxvtc ${@:--T $HOSTNAME}" #eval "$cmd" || { [ $? = 2 ] && urxvtd -q -o -f && eval "$cmd"; } -- cgit v1.2.3 From 45ecd3877ab52d73f4bec998ad456aa270ffddac Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 23 Feb 2021 14:52:10 +0100 Subject: update --- bin/update_hosts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bin/update_hosts diff --git a/bin/update_hosts b/bin/update_hosts new file mode 100755 index 0000000..6444550 --- /dev/null +++ b/bin/update_hosts @@ -0,0 +1,16 @@ +#!/bin/sh -ex + +# Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc. +# Custom hosts are preserved. + +[ "$USER" = root ] || exec sudo "$0" "$@" +cd /etc +cp -p hosts hosts.old +hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) +curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | +awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" } +/^# Custom host / { print hosts; next } +/^# End of custom host / { next } +{print}' "$hosts" > hosts.new +mv hosts.new hosts +[ "$(uname -s)" != Darwin ] || dscacheutil -flushcache -- cgit v1.2.3 From 29a52089c0ba2a78f5f7fa9b299f00ece9e6faf1 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 23 Feb 2021 14:52:10 +0100 Subject: update --- bin/update_hosts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bin/update_hosts diff --git a/bin/update_hosts b/bin/update_hosts new file mode 100755 index 0000000..6444550 --- /dev/null +++ b/bin/update_hosts @@ -0,0 +1,16 @@ +#!/bin/sh -ex + +# Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc. +# Custom hosts are preserved. + +[ "$USER" = root ] || exec sudo "$0" "$@" +cd /etc +cp -p hosts hosts.old +hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) +curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | +awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" } +/^# Custom host / { print hosts; next } +/^# End of custom host / { next } +{print}' "$hosts" > hosts.new +mv hosts.new hosts +[ "$(uname -s)" != Darwin ] || dscacheutil -flushcache -- cgit v1.2.3 From 9793ed6f2c0a89728d19a8b06d084c3c3fb102e5 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 24 Feb 2021 22:28:41 +0100 Subject: update --- .Xresources | 2 +- .vimrc | 2 +- bin/start_godoc | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 bin/start_godoc diff --git a/.Xresources b/.Xresources index bdf02a3..8aaf72c 100644 --- a/.Xresources +++ b/.Xresources @@ -22,7 +22,7 @@ xterm*VT100.Translations: #override \ Meta equal: larger-vt-font() \n xterm*cursorColor: red xterm*visualBell: true -xterm*geometry: 100x32 +!xterm*geometry: 100x32 !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.vimrc b/.vimrc index 5220bba..35fb5e1 100644 --- a/.vimrc +++ b/.vimrc @@ -14,7 +14,7 @@ let g:fzf_preview = 'cat {}' let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite -"autocmd filetype vimki setlocal spell spelllang=fr +" autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki autocmd filetype vimki nnoremap = YpVr= diff --git a/bin/start_godoc b/bin/start_godoc new file mode 100755 index 0000000..15bb70a --- /dev/null +++ b/bin/start_godoc @@ -0,0 +1,3 @@ +#!/bin/sh + +/Users/marc/go/bin/godoc >/tmp/godoc.out 2>&1 & -- cgit v1.2.3 From 08c1e56c3905878b358546054ad2eff307a7ec42 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 24 Feb 2021 22:28:41 +0100 Subject: update --- .Xresources | 2 +- .vimrc | 2 +- bin/start_godoc | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 bin/start_godoc diff --git a/.Xresources b/.Xresources index bdf02a3..8aaf72c 100644 --- a/.Xresources +++ b/.Xresources @@ -22,7 +22,7 @@ xterm*VT100.Translations: #override \ Meta equal: larger-vt-font() \n xterm*cursorColor: red xterm*visualBell: true -xterm*geometry: 100x32 +!xterm*geometry: 100x32 !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 ! xterm*font: 7x14 diff --git a/.vimrc b/.vimrc index 5220bba..35fb5e1 100644 --- a/.vimrc +++ b/.vimrc @@ -14,7 +14,7 @@ let g:fzf_preview = 'cat {}' let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite -"autocmd filetype vimki setlocal spell spelllang=fr +" autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki autocmd filetype vimki nnoremap = YpVr= diff --git a/bin/start_godoc b/bin/start_godoc new file mode 100755 index 0000000..15bb70a --- /dev/null +++ b/bin/start_godoc @@ -0,0 +1,3 @@ +#!/bin/sh + +/Users/marc/go/bin/godoc >/tmp/godoc.out 2>&1 & -- cgit v1.2.3 From a4f62573788d3d3d25c0bd1d9c443a8e56577a6f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 25 Feb 2021 22:10:02 +0100 Subject: update --- .otp_accounts.json.gpg | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .otp_accounts.json.gpg diff --git a/.otp_accounts.json.gpg b/.otp_accounts.json.gpg deleted file mode 100644 index bbf1956..0000000 --- a/.otp_accounts.json.gpg +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN PGP MESSAGE----- - -hQIMA+yVXrx81qjVAQ/8DgattaALSr1kOyqcTFdn43dNBwLSBD369Cs3zu7ez5xz -DpBBecMNSuCVFPq0QfocNlDmz3BZxrkrttmAz3W7iK5rDKZeYTAG10ZT7NzI5K/C -43WgEbf3W7FLxJGy6ASv2wRI/NRDZyjWe8yEEE5OF5ZTLawV57R/xW2UHemegI3l -aAC4nU1hWHnmErdaubdxzgCva/hrd3SzroSVfmuQp+Cq1/AszDAe9LQltSAIo2oZ -wwct6GIBNXoiA61YB3+m7oZfMfMa+1fNEobYReN/9E8iVMz01fWWOGsYRIue07yd -0aAMj+ywQ1VU5G2SJ++B3pchbD+ViXvLEy1bnNF37PplKYnjN06db0MuflkfDM+A -ICMTvhGlR58DwBueuLrWBh6dAbSOuz8tHQXzs5nlBI/Vvd2YUkw5Stcn+VBi7Bwg -xvq2WiMhRT0nIvb1yuNGCpwWt2W1ckba79opBe4j1mvXYOq9vTT2VjJnAKe3k55B -KWQBEkRe+T5FgcSfpRiMTogIvA8aOXTxkOltzjWjH5GXza65en4R9LNg7HB/lUd7 -zb3KVEg++XuPFVU08hFF8B4vb3zsLDy0Uf26Ilv63lNgvKR9TAC9VDEfY91qMXWl -e1yeiGQCoAmU2BLm4MopwqBBEADjYSJETS1Kvz3hiR2AvcR5gMcpxp6C121723/S -wWgBuVgsKQmnYVNMzkNhaKj5qWOak5jXq1py751jkGKkVUwSkVQwjMr99A06fNE+ -p0k1XjA36flRSzQgh3vcOTTutXaLe1TfEHC3TWOaXu30/S5ptkpcHFfBLSoVhZ3o -2PN5/3WcRvHL30vvLW7noB5wH32l0AzSHVnZ5cFqlNH5M00HrlPOH+Uy5WfYy684 -V7zyOpg+J7DdJQNS7HBGjSNdK738HUdxWHkNuxaK2HEuzc9YyWy6fpPrefY1z9nH -+H3pgmr4UxiUf0+LbYvL9xcaN265S1RIvx7QJJq7iTwZYtg/qc+SRfgVpvXUr40X -W3bTEO1baPeVpydhLMWyqReN1i3tClTG3uaVNYX5adqaaqBCaKyXexiHrSFJzaIb -mikACoQEFsh2acP+2cp8oCVGS5vdwEfkWfZSld4KfM/v37aDb4Mwq9Ap9/OAHwSt -RWONXZFWftgfhHXnem/iUswob+O+SvF2CSCs7cCqcB5gS0RZTsV3eiRfPbZTSSQD -xz95R4lZ2NIt99vDKi1NWrbIfTletCnYaOahKkC5bHqlzjZ10VKCOkYUBXyewSPy -4d+RCxlF9T6Pya0NKLjKEJwUG67Nr79w9OR6mVWR0e8f+ppw41ApUih3a3sLTuWl -DJFkJiYEL/EwBoAaAtfnMxqlPi6BXAJQXWngS8XMTmksr1PCVovFrr57e0tIyaLt -X4pDpxmElysDbZqLtpDtFU7OU4pMimSmSmQ= -=NBYN ------END PGP MESSAGE----- -- cgit v1.2.3 From 9e34d600e3d8f8e50b8b87779c76c62924f41d2f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 28 Feb 2021 14:05:43 +0100 Subject: update --- bin/vm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 bin/vm diff --git a/bin/vm b/bin/vm new file mode 100755 index 0000000..22886d8 --- /dev/null +++ b/bin/vm @@ -0,0 +1,65 @@ +#!/bin/sh + +# vm is a tool to manage virtual machines. + +vm_version='vm-0.1' +unset CDPATH +export LC_ALL=C IFS=' +' + +add() { + usage 'add name' 'Add a new VM' && return + echo 'not implemented yet' +} + +del() { + usage 'del name' 'Delete a VM' && return + echo 'not implemented yet' +} + +die() { echo "$0: fatal: $@" >&2; exit 1; } + +help() { + usage 'help' 'Print this help text' && return + printf "$vm_version\nUsage: vm command [options] [args]\n" + Opth=1; for c in $Cmdlist; do $c; done +} + +info() { + usage 'info name' 'Print informations on a VM' && return + echo 'not implemented yet' +} + +list() { + usage 'list' 'list VMs' && return + echo 'not implemented yet' +} + +start() { + usage 'start name' 'Start a VM' && return + echo 'not implemented yet' +} + +stop() { + usage 'stop name' 'Stop a VM' && return + echo 'not implemented yet' +} + +usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; } + +version() { + usage 'version' 'Print version' && return + echo "$vm_version" +} + +# Main starts here. +Cmdlist='add del info help list start stop version' +[ "$1" ] && C=$1 && shift 1 || { help; exit 1; } +for c in $Cmdlist +do + case $c in + ($C) cmd=$c; break;; + ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c;; + esac +done +[ "$cmd" ] || die "no command \"$C\"" && $cmd "$@" -- cgit v1.2.3 From 737e83162766162be992f76e068386736abea71d Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 28 Feb 2021 22:10:26 +0100 Subject: update --- .Xresources | 2 +- bin/rdate | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 bin/rdate diff --git a/.Xresources b/.Xresources index 8aaf72c..28b8436 100644 --- a/.Xresources +++ b/.Xresources @@ -21,7 +21,7 @@ xterm*VT100.Translations: #override \ Meta minus: smaller-vt-font() \n\ Meta equal: larger-vt-font() \n xterm*cursorColor: red -xterm*visualBell: true +!xterm*visualBell: true !xterm*geometry: 100x32 !xterm*faceName: DejaVu Sans Mono !xterm*faceSize: 10 diff --git a/bin/rdate b/bin/rdate new file mode 100755 index 0000000..a69d137 --- /dev/null +++ b/bin/rdate @@ -0,0 +1,11 @@ +#!/bin/sh + +# Set date on remote machine from local one. This version works +# from MacOS to AlpineLinux. It is intended to re-sync clock of a +# virtual machine after host wakeup. + +# TODO: option to display the time difference between host and remote. +# hint: use 'date +%s' to get timestamp in seconds since epoch. + +ssh "$1" "sudo date $(date +%m%d%H%M%Y.%S)" + -- cgit v1.2.3 From bcc866236cca05f6caf78a6c3d93a63c9bf19f7c Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 6 Mar 2021 12:31:59 +0100 Subject: add .zshrc, update .vimrc --- .zshrc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .zshrc diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..15ed2e8 --- /dev/null +++ b/.zshrc @@ -0,0 +1,48 @@ +# Environment +export YAEGI_DOT_CMD='dotty -' + +# gnuplot display in terminal +export GNUTERM='sixelgd enhanced truecolor font "arial,9"' + +# Auto completion +FPATH=/opt/homebrew/share/zsh-completions:/opt/homebrew/share/zsh/site-functions:$FPATH +autoload -Uz compinit && compinit + +setopt share_history + +# Aliases +alias pt='sudo port -v' +alias pu='pt selfupdate && pt upgrade outdated' + +alias by='go build ./cmd/yaegi' +alias cy='cd ~/go/src/github.com/traefik/yaegi' +alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' +#alias git='hub' +alias ll='ls -AFGl' +alias ls='ls -AG' +alias ya='rlwrap yaegi' + +export MANWIDTH=92 + +# Functions +man() { + local width=$(tput cols) + [ $width -gt $MANWIDTH ] && width=$MANWIDTH + env MANWIDTH=$width man "$@" +} + +meteo() { + local request="wttr.in/${1-Toulouse}?F&T" + [ "$(tput cols)" -lt 125 ] && request+='&n' + curl -H "Accept-Language: fr" --compressed "$request" +} + +p() { [ -f "$1" -a ! -x "$1" ] && less -XF $1 || "$@" 2>&1 | less -XF ; } + +ty() { go test -v -short ./interp; } + +# Prompt +source ~/.zsh-powerline.sh + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + -- cgit v1.2.3 From 9aa9c25a4d2ced1ea41d1d981b3fad9fe28a17a6 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 6 Mar 2021 16:58:38 +0100 Subject: update --- .vim/pack/mvertes/install.sh | 2 +- .vimrc | 3 ++- .zshrc | 8 +++----- bin/vm | 4 +++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.vim/pack/mvertes/install.sh b/.vim/pack/mvertes/install.sh index 36cf414..24a52f0 100755 --- a/.vim/pack/mvertes/install.sh +++ b/.vim/pack/mvertes/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -plugins='https://github.com/mvertes/vimki https://github.com/fatih/vim-go' +plugins='git@github.com:mvertes/vimki git@github.com:fatih/vim-go' ht='vim -c "helptags doc" -c "q"' mkdir -p start diff --git a/.vimrc b/.vimrc index 35fb5e1..9f5b410 100644 --- a/.vimrc +++ b/.vimrc @@ -1,5 +1,6 @@ " set background= -set t_te= t_ti= laststatus=2 +"set t_te= t_ti= laststatus=2 +set t_te= t_ti= ls=1 ruler syntax off filetype on diff --git a/.zshrc b/.zshrc index 15ed2e8..890bfe4 100644 --- a/.zshrc +++ b/.zshrc @@ -22,13 +22,11 @@ alias ll='ls -AFGl' alias ls='ls -AG' alias ya='rlwrap yaegi' -export MANWIDTH=92 - # Functions man() { - local width=$(tput cols) - [ $width -gt $MANWIDTH ] && width=$MANWIDTH - env MANWIDTH=$width man "$@" + local width='' + [ $(tput cols) -gt 88 ] && width='MANWIDTH=88' + env $width man "$@" } meteo() { diff --git a/bin/vm b/bin/vm index 22886d8..4b0e960 100755 --- a/bin/vm +++ b/bin/vm @@ -21,7 +21,9 @@ die() { echo "$0: fatal: $@" >&2; exit 1; } help() { usage 'help' 'Print this help text' && return - printf "$vm_version\nUsage: vm command [options] [args]\n" + echo "$vm_version +Manage virtual machines +Usage: vm command [options] [args]" Opth=1; for c in $Cmdlist; do $c; done } -- cgit v1.2.3 From 050afa8def0739b459122b9d4c7fcf854ae1ed2a Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 12 Mar 2021 12:31:20 +0100 Subject: added wol. Updated vm --- bin/vm | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ bin/wol | 6 ++++++ 2 files changed, 68 insertions(+), 6 deletions(-) create mode 100755 bin/wol diff --git a/bin/vm b/bin/vm index 4b0e960..5a8ea8d 100755 --- a/bin/vm +++ b/bin/vm @@ -9,7 +9,10 @@ export LC_ALL=C IFS=' add() { usage 'add name' 'Add a new VM' && return - echo 'not implemented yet' + [ -d "$idir/$1" ] && die "vm $1 already exists in $idir/$1" + init_alpine || die "could not init alpine iso" + mkdir -p "$idir/$1" && cd "$idir/$1" || die "add $1 failed" + pwd } del() { @@ -32,9 +35,54 @@ info() { echo 'not implemented yet' } -list() { - usage 'list' 'list VMs' && return - echo 'not implemented yet' +init() { + : +} + +init_alpine() { + mkdir -p "$sdir/alpine" && cd "$sdir/alpine" || die "init alpine failed" + [ -f Makefile ] || cat << \EOT > Makefile +# Do no edit. This file is generated by vm. +# Install a run a native AlpineLinux VM in Apple silicon MacOS + +# Check https://alpinelinux.org/downloads for possible upgrades +iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.2-aarch64.iso +iso = $(notdir $(iso_url)) +isoinfo ?= /opt/homebrew/bin/isoinfo + +all: initrd vmlinux + +runiso: initrd vmlinux $(iso) + vftool -k vmlinux -i initrd -d hdd.img -c $(iso) + +initrd: $(iso) $(isoinfo) + isoinfo -i $(iso) -J -x /boot/initramfs-virt > $@ + +vmlinux: $(iso) $(isoinfo) + isoinfo -i $(iso) -J -x /boot/vmlinuz-virt | gunzip > $@ + +$(iso): + curl -LO $(iso_url) || { rm -f $@; false; } + +$(isoinfo): + brew install cdrtools +EOT + + make -s all +} + +ls() { + usage 'ls' 'list VMs' && return + [ -d "$idir" ] && cd "$idir" || return + for i in *; do + echo "$i" + done +} + +runiso() { + usage 'runiso [isoname]' 'run a cdrom iso' && return + init_alpine + make runiso } start() { @@ -55,7 +103,15 @@ version() { } # Main starts here. -Cmdlist='add del info help list start stop version' +pdir="$HOME/.vm" +sdir="$pdir/iso" +edir="$pdir/engine" +idir="$pdir/img" + +engines="vftool" # Todo: add qemu (when supported on m1) +isos="alpine" # Todo: add freebsd, openbsd, archlinux, debian, ubuntu, macOS, win10, etc... + +Cmdlist='add del info help ls runiso start stop version' [ "$1" ] && C=$1 && shift 1 || { help; exit 1; } for c in $Cmdlist do @@ -64,4 +120,4 @@ do ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c;; esac done -[ "$cmd" ] || die "no command \"$C\"" && $cmd "$@" +[ "$cmd" ] || { help; exit 1; } && $cmd "$@" diff --git a/bin/wol b/bin/wol new file mode 100755 index 0000000..39bce0d --- /dev/null +++ b/bin/wol @@ -0,0 +1,6 @@ +#!/bin/sh -x +ip_plex=192.168.1.90 mac_plex=b0:83:fe:61:a7:aa +eval "mac=\$mac_$1 ip=\$ip_$1" +wakeonlan "$mac" +ping -o "$ip" +ssh "root@$ip" -- cgit v1.2.3 From 5c75618ff26969654a0572ae00b01f77d1898a71 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 12 Mar 2021 13:52:11 +0100 Subject: fix titles --- .zshrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.zshrc b/.zshrc index 890bfe4..9d3ebd2 100644 --- a/.zshrc +++ b/.zshrc @@ -39,6 +39,22 @@ p() { [ -f "$1" -a ! -x "$1" ] && less -XF $1 || "$@" 2>&1 | less -XF ; } ty() { go test -v -short ./interp; } +# Term title management +function set-term-title-precmd() { + emulate -L zsh + print -rn -- $'\e]0;'${(V%):-'%~'}$'\a' >$TTY +} + +function set-term-title-preexec() { + emulate -L zsh + print -rn -- $'\e]0;'${(V)1}$'\a' >$TTY +} + +autoload -Uz add-zsh-hook +add-zsh-hook preexec set-term-title-preexec +add-zsh-hook precmd set-term-title-precmd +set-term-title-precmd + # Prompt source ~/.zsh-powerline.sh -- cgit v1.2.3 From 556754fb516ff84965a510d0205f3c1d6cf64505 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 17 Mar 2021 16:17:42 +0100 Subject: improved vm --- bin/vm | 133 +++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 88 insertions(+), 45 deletions(-) diff --git a/bin/vm b/bin/vm index 5a8ea8d..e8f7684 100755 --- a/bin/vm +++ b/bin/vm @@ -1,32 +1,50 @@ #!/bin/sh -# vm is a tool to manage virtual machines. +# vm is a tool to manage and operate virtual machines. vm_version='vm-0.1' + +# TODO: +# - DONE: fetch, build and install vftool in .vm/vftool +# - setup a config file per VM +# - creation of hdd image +# - script install from CDROM iso: +# - setup system, including static IP address +# - setup user account from host +# - setup ssh from host +# - time synchronization from host +# + unset CDPATH export LC_ALL=C IFS=' ' add() { usage 'add name' 'Add a new VM' && return - [ -d "$idir/$1" ] && die "vm $1 already exists in $idir/$1" + [ -d "$dir/$1" ] && die "vm $1 already exists in $dir/$1" init_alpine || die "could not init alpine iso" - mkdir -p "$idir/$1" && cd "$idir/$1" || die "add $1 failed" + mkdir -p "$dir/$1" && cd "$dir/$1" || die "add $1 failed" pwd } +console() { + usage 'console name' 'Attach a console to a VM' && return + [ "$1" ] || die 'console: name is missing' + cd "$dir/$1" || die 'console $1 failed' + [ -f vftool.pid ] || die "vm $1 is not active" + screen -r "$1" +} + del() { usage 'del name' 'Delete a VM' && return echo 'not implemented yet' } -die() { echo "$0: fatal: $@" >&2; exit 1; } +die() { [ "$1" ] && echo "$@" >&2; exit 1; } help() { usage 'help' 'Print this help text' && return - echo "$vm_version -Manage virtual machines -Usage: vm command [options] [args]" + echo "$vm_version\nManage virtual machines\nUsage: vm command [options] [args]" Opth=1; for c in $Cmdlist; do $c; done } @@ -35,16 +53,9 @@ info() { echo 'not implemented yet' } -init() { - : -} - -init_alpine() { - mkdir -p "$sdir/alpine" && cd "$sdir/alpine" || die "init alpine failed" - [ -f Makefile ] || cat << \EOT > Makefile -# Do no edit. This file is generated by vm. -# Install a run a native AlpineLinux VM in Apple silicon MacOS +# CAUTION: be careful to preserve tabs in the following Makefile template string. +alpine_makefile='# Generated by "vm". DO NOT EDIT. # Check https://alpinelinux.org/downloads for possible upgrades iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.2-aarch64.iso iso = $(notdir $(iso_url)) @@ -52,9 +63,6 @@ isoinfo ?= /opt/homebrew/bin/isoinfo all: initrd vmlinux -runiso: initrd vmlinux $(iso) - vftool -k vmlinux -i initrd -d hdd.img -c $(iso) - initrd: $(iso) $(isoinfo) isoinfo -i $(iso) -J -x /boot/initramfs-virt > $@ @@ -63,36 +71,79 @@ vmlinux: $(iso) $(isoinfo) $(iso): curl -LO $(iso_url) || { rm -f $@; false; } + ln -sf $(iso) iso $(isoinfo): brew install cdrtools -EOT +' +init_alpine() { + mkdir -p "$dir/alpine-iso" && cd "$dir/alpine-iso" || die 'init alpine failed' + [ -f 'Makefile' ] || echo "$alpine_makefile" > Makefile make -s all } +init_vftool() { + [ -x "$dir/vftool" ] && return + cd '/tmp' && + git clone --depth=1 'https://github.com/evansm7/vftool' && + cd 'vftool' && + make && + cp 'build/vftool' "$dir/vftool" + rm -rf '/tmp/vftool' +} + +log() { + usage 'log name' 'print logs of a VM' && return + [ "$1" ] || die "log failed: name missing" + cd "$dir/$1" || die "log $1 failed" + cat vftool.log.old vftool.log 2>/dev/null +} + ls() { usage 'ls' 'list VMs' && return - [ -d "$idir" ] && cd "$idir" || return - for i in *; do - echo "$i" + [ -d "$dir" ] && cd "$dir" || return + for i in */; do + i=${i%/} + [ -f "$i/vftool.pid" ] && state=active || state=stopped + printf "%-20s %s\n" "$i" "$state" done } -runiso() { - usage 'runiso [isoname]' 'run a cdrom iso' && return - init_alpine - make runiso -} - start() { - usage 'start name' 'Start a VM' && return - echo 'not implemented yet' + usage 'start [-a][-c vm] name' 'Start a VM' && return + while getopts :ac: opt; do + case $opt in + (a) attach=1 ;; + (c) from=$OPTARG ;; + (*) Opth=1 start; exit;; + esac + done + shift $((OPTIND - 1)) + + [ "$1" ] || die "start failed: name missing" + init_vftool + cd "$dir/$1" || die "start $1 failed" + [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed" + start_vm & } +start_vm() ( + trap 'rm -f vftool.pid' EXIT + [ -f vftool.log ] && cat vftool.log >> vftool.log.old + "$dir/vftool" -k vmlinux -i initrd -c iso >vftool.log 2>&1 & sleep 1 + exec 1>>vftool.log 2>&1 + echo "$!" >vftool.pid + screen -S "${PWD##*/}" -d -m "$(grep -om 1 '\/dev\/tty.*' vftool.log)" + wait +) + stop() { usage 'stop name' 'Stop a VM' && return - echo 'not implemented yet' + [ "$1" ] || die 'stop: name missing' + cd "$dir/$1" || die 'stop $1 failed' + [ -f vftool.pid ] || die "stop: vm $1 is not active" + kill $(cat vftool.pid) } usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; } @@ -103,21 +154,13 @@ version() { } # Main starts here. -pdir="$HOME/.vm" -sdir="$pdir/iso" -edir="$pdir/engine" -idir="$pdir/img" - -engines="vftool" # Todo: add qemu (when supported on m1) -isos="alpine" # Todo: add freebsd, openbsd, archlinux, debian, ubuntu, macOS, win10, etc... - -Cmdlist='add del info help ls runiso start stop version' +dir="$HOME/.vm" +Cmdlist='add console del info help ls log start stop version' [ "$1" ] && C=$1 && shift 1 || { help; exit 1; } -for c in $Cmdlist -do +for c in $Cmdlist; do case $c in - ($C) cmd=$c; break;; - ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c;; + ($C) cmd=$c; break ;; + ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c ;; esac done [ "$cmd" ] || { help; exit 1; } && $cmd "$@" -- cgit v1.2.3 From d86227be78743b71c713a7ce6267cfcea73f6582 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 18 Mar 2021 16:28:30 +0100 Subject: update --- bin/vm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/bin/vm b/bin/vm index e8f7684..83ce0ea 100755 --- a/bin/vm +++ b/bin/vm @@ -1,12 +1,12 @@ #!/bin/sh -# vm is a tool to manage and operate virtual machines. +# vm is a command line tool to manage and operate virtual machines. vm_version='vm-0.1' # TODO: # - DONE: fetch, build and install vftool in .vm/vftool -# - setup a config file per VM +# - DONE: setup a config file per VM # - creation of hdd image # - script install from CDROM iso: # - setup system, including static IP address @@ -61,7 +61,7 @@ iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-vi iso = $(notdir $(iso_url)) isoinfo ?= /opt/homebrew/bin/isoinfo -all: initrd vmlinux +all: initrd vmlinux config initrd: $(iso) $(isoinfo) isoinfo -i $(iso) -J -x /boot/initramfs-virt > $@ @@ -69,9 +69,11 @@ initrd: $(iso) $(isoinfo) vmlinux: $(iso) $(isoinfo) isoinfo -i $(iso) -J -x /boot/vmlinuz-virt | gunzip > $@ +config: $(iso) + @echo "iso=$(iso)" >config + $(iso): curl -LO $(iso_url) || { rm -f $@; false; } - ln -sf $(iso) iso $(isoinfo): brew install cdrtools @@ -79,7 +81,7 @@ $(isoinfo): init_alpine() { mkdir -p "$dir/alpine-iso" && cd "$dir/alpine-iso" || die 'init alpine failed' - [ -f 'Makefile' ] || echo "$alpine_makefile" > Makefile + [ -f 'Makefile' ] || printf "%s" "$alpine_makefile" > Makefile make -s all } @@ -129,10 +131,21 @@ start() { } start_vm() ( - trap 'rm -f vftool.pid' EXIT [ -f vftool.log ] && cat vftool.log >> vftool.log.old - "$dir/vftool" -k vmlinux -i initrd -c iso >vftool.log 2>&1 & sleep 1 - exec 1>>vftool.log 2>&1 + exec 1>vftool.log 2>&1 + . config || die "vm: could not source $PWD/config" + trap 'rm -f vftool.pid' EXIT + + "$dir/vftool" \ + -k vmlinux \ + -i initrd \ + ${iso+-c "$iso"} \ + ${hdd+-d "$hdd"} \ + ${cpu+-p "$cpu"} \ + ${ram+-m "$ram"} \ + ${arg+-m "$arg"} \ + >>vftool.log 2>&1 & sleep 1 + echo "$!" >vftool.pid screen -S "${PWD##*/}" -d -m "$(grep -om 1 '\/dev\/tty.*' vftool.log)" wait -- cgit v1.2.3 From a8e3586e9b691c2a25b5f2e50a2761d5fcad18f8 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 19 Mar 2021 22:27:11 +0100 Subject: update --- .zshrc | 3 +++ bin/vm | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.zshrc b/.zshrc index 9d3ebd2..bd67270 100644 --- a/.zshrc +++ b/.zshrc @@ -4,6 +4,9 @@ export YAEGI_DOT_CMD='dotty -' # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' +# Terraform-perf +export TFP=$HOME/src/github.com/traefik/terraform-perf + # Auto completion FPATH=/opt/homebrew/share/zsh-completions:/opt/homebrew/share/zsh/site-functions:$FPATH autoload -Uz compinit && compinit diff --git a/bin/vm b/bin/vm index 83ce0ea..0eaa921 100755 --- a/bin/vm +++ b/bin/vm @@ -8,6 +8,7 @@ vm_version='vm-0.1' # - DONE: fetch, build and install vftool in .vm/vftool # - DONE: setup a config file per VM # - creation of hdd image +# - import iso, kernel, initrd from existing vm # - script install from CDROM iso: # - setup system, including static IP address # - setup user account from host @@ -20,13 +21,31 @@ export LC_ALL=C IFS=' ' add() { - usage 'add name' 'Add a new VM' && return + usage 'add [Options] name' 'Add a new VM' && return + while getopts :c:p:s: opt; do + case $opt in + c|k|p|s) eval "$opt=$OPTARG";; + *) Opth=1 add; exit ;; + esac + done + shift $((OPTIND - 1)) + [ -d "$dir/$1" ] && die "vm $1 already exists in $dir/$1" init_alpine || die "could not init alpine iso" mkdir -p "$dir/$1" && cd "$dir/$1" || die "add $1 failed" - pwd + hdd=${p-$1.raw} + [ -f "$hdd" ] || dd if=/dev/zero of=$hdd bs=1 count=0 seek=${s-32g} 2>/dev/null + echo "hdd=\"$hdd\"" > config + [ "$c" ] && { + [ -d "../$c" ] || die "invalid directory: $dir/$c" + iso=$(getconf "$c" iso) + [ "$iso" ] && echo "iso=\"../$c/$iso\"" >> config + cp "../$c/vmlinux" "../$c/initrd" . + } } +getconf() { awk -F '=' -v k="$2" '$1 == k {print $2}' "$dir/$1/config"; } + console() { usage 'console name' 'Attach a console to a VM' && return [ "$1" ] || die 'console: name is missing' @@ -128,6 +147,7 @@ start() { cd "$dir/$1" || die "start $1 failed" [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed" start_vm & + [ "$attach" ] && sleep 1 && vm console $1 } start_vm() ( @@ -139,8 +159,8 @@ start_vm() ( "$dir/vftool" \ -k vmlinux \ -i initrd \ - ${iso+-c "$iso"} \ ${hdd+-d "$hdd"} \ + ${iso+-c "$iso"} \ ${cpu+-p "$cpu"} \ ${ram+-m "$ram"} \ ${arg+-m "$arg"} \ -- cgit v1.2.3 From 262eb286cb7c8d7412160cacfb022247b1f09f00 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 22 Mar 2021 08:50:26 +0100 Subject: update --- bin/vm | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/bin/vm b/bin/vm index 0eaa921..11fed61 100755 --- a/bin/vm +++ b/bin/vm @@ -7,9 +7,12 @@ vm_version='vm-0.1' # TODO: # - DONE: fetch, build and install vftool in .vm/vftool # - DONE: setup a config file per VM -# - creation of hdd image -# - import iso, kernel, initrd from existing vm +# - DONE: creation of hdd image +# - DONE: delete a VM +# - DONE: import iso, kernel, initrd from existing vm +# - when no vm is specified, apply command to last one # - script install from CDROM iso: +# - patch alpine setup-disk # - setup system, including static IP address # - setup user account from host # - setup ssh from host @@ -22,9 +25,9 @@ export LC_ALL=C IFS=' add() { usage 'add [Options] name' 'Add a new VM' && return - while getopts :c:p:s: opt; do + while getopts :c:i:k:p:s: opt; do case $opt in - c|k|p|s) eval "$opt=$OPTARG";; + [cikps]) eval "$opt=$OPTARG";; *) Opth=1 add; exit ;; esac done @@ -32,6 +35,7 @@ add() { [ -d "$dir/$1" ] && die "vm $1 already exists in $dir/$1" init_alpine || die "could not init alpine iso" + [ "$1" = 'alpine-iso' ] && return mkdir -p "$dir/$1" && cd "$dir/$1" || die "add $1 failed" hdd=${p-$1.raw} [ -f "$hdd" ] || dd if=/dev/zero of=$hdd bs=1 count=0 seek=${s-32g} 2>/dev/null @@ -41,11 +45,11 @@ add() { iso=$(getconf "$c" iso) [ "$iso" ] && echo "iso=\"../$c/$iso\"" >> config cp "../$c/vmlinux" "../$c/initrd" . + echo "kernel=${k-vmlinux}" >> config + echo "initrd=initrd" >> config } } -getconf() { awk -F '=' -v k="$2" '$1 == k {print $2}' "$dir/$1/config"; } - console() { usage 'console name' 'Attach a console to a VM' && return [ "$1" ] || die 'console: name is missing' @@ -56,10 +60,39 @@ console() { del() { usage 'del name' 'Delete a VM' && return - echo 'not implemented yet' + case $1 in ''|*/*|.*) die "invalid VM name: $1" ;; esac + [ -d "$dir/$1" ] || die "$dir/$1 not found" + cd "$dir" && rm -r "$1" +} + +die() { [ "$1" ] && echo "$0: $@" >&2; exit 1; } + +edit() { + usage 'edit name' 'Edit a VM configuration' && return + [ -f "$dir/$1/config" ] || die "$dir/$1/config not found" + ${EDITOR-vi} "$dir/$1/config" +} + +exp() { + usage 'exp name' 'experiment on a VM' && return + cd "$dir/$1" || die "invalid VM: $1" + [ -f vftool.pid ] || die "vm $1 is not active" + + screen -X stuff 'root +' + screen -X stuff 'sed -i "s/die..Bootloader/;; #/" /sbin/setup-disk +' + screen -X stuff 'grep BOOTLOADER /sbin/setup-disk +' + } -die() { [ "$1" ] && echo "$@" >&2; exit 1; } +finalize() { + tty=$(vftool_tty) + echo "root\nuname -a" >> "$tty" +} + +getconf() { awk -F '=' -v k="$2" '$1 == k {print $2}' "$dir/$1/config"; } help() { usage 'help' 'Print this help text' && return @@ -90,6 +123,11 @@ vmlinux: $(iso) $(isoinfo) config: $(iso) @echo "iso=$(iso)" >config + @echo "initrd=initrd" >>config + @echo "kernel=vmlinux" >>config + @echo "cpu=1" >> config + @echo "ram=512" >> config + @echo "arg=\"console=hvc0\"" >> config $(iso): curl -LO $(iso_url) || { rm -f $@; false; } @@ -126,17 +164,19 @@ ls() { [ -d "$dir" ] && cd "$dir" || return for i in */; do i=${i%/} + [ "$i" = '*' ] && continue [ -f "$i/vftool.pid" ] && state=active || state=stopped printf "%-20s %s\n" "$i" "$state" done } start() { - usage 'start [-a][-c vm] name' 'Start a VM' && return - while getopts :ac: opt; do + usage 'start [-af][-c vm] name' 'Start a VM' && return + while getopts :ac:f opt; do case $opt in - (a) attach=1 ;; + (a) a=1 ;; (c) from=$OPTARG ;; + (f) f=1 ;; (*) Opth=1 start; exit;; esac done @@ -146,8 +186,9 @@ start() { init_vftool cd "$dir/$1" || die "start $1 failed" [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed" - start_vm & - [ "$attach" ] && sleep 1 && vm console $1 + start_vm & sleep 2 + [ "$f" ] && finalize + [ "$a" ] && vm console $1 } start_vm() ( @@ -157,8 +198,8 @@ start_vm() ( trap 'rm -f vftool.pid' EXIT "$dir/vftool" \ - -k vmlinux \ - -i initrd \ + ${kernel+-k "$kernel"} \ + ${initrd+-i "$initrd"} \ ${hdd+-d "$hdd"} \ ${iso+-c "$iso"} \ ${cpu+-p "$cpu"} \ @@ -167,7 +208,7 @@ start_vm() ( >>vftool.log 2>&1 & sleep 1 echo "$!" >vftool.pid - screen -S "${PWD##*/}" -d -m "$(grep -om 1 '\/dev\/tty.*' vftool.log)" + screen -S "${PWD##*/}" -d -m "$(vftool_tty)" wait ) @@ -186,9 +227,11 @@ version() { echo "$vm_version" } +vftool_tty() { grep -om 1 '\/dev\/tty.*' 'vftool.log'; } + # Main starts here. dir="$HOME/.vm" -Cmdlist='add console del info help ls log start stop version' +Cmdlist='add console del edit exp info help ls log start stop version' [ "$1" ] && C=$1 && shift 1 || { help; exit 1; } for c in $Cmdlist; do case $c in -- cgit v1.2.3 From 73aec290b0f95b7be7ef952b042359bb95b18645 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 26 Mar 2021 10:38:56 +0100 Subject: improve update_hosts --- bin/update_hosts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/update_hosts b/bin/update_hosts index 6444550..793344c 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -1,9 +1,10 @@ -#!/bin/sh -ex +#!/bin/sh -e # Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc. # Custom hosts are preserved. [ "$USER" = root ] || exec sudo "$0" "$@" +echo "last update: $(date -r /etc/hosts)" cd /etc cp -p hosts hosts.old hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) @@ -14,3 +15,4 @@ awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" } {print}' "$hosts" > hosts.new mv hosts.new hosts [ "$(uname -s)" != Darwin ] || dscacheutil -flushcache +diff -u /etc/hosts.old /etc/hosts | diffstat -- cgit v1.2.3 From 9734e798057795f89a7bd0a0d933745f0d249b2f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 26 Mar 2021 12:01:52 +0100 Subject: improve update_hosts --- bin/update_hosts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/update_hosts b/bin/update_hosts index 793344c..8d148a6 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -3,8 +3,18 @@ # Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc. # Custom hosts are preserved. + [ "$USER" = root ] || exec sudo "$0" "$@" -echo "last update: $(date -r /etc/hosts)" + +echo "Check from https://github.com/StevenBlack/hosts" +lsd=$(curl -s "https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1"| jq -r '.[0].commit.committer.date') +echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" +echo "last local update: $(date -r /etc/hosts)" +if [ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ]; then + echo "Nothing to do" + exit +fi + cd /etc cp -p hosts hosts.old hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) -- cgit v1.2.3 From a8243acb9f5cabd19cc9df16a15018129e0b225e Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 26 Mar 2021 13:50:43 +0100 Subject: improve update_hosts --- bin/update_hosts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/update_hosts b/bin/update_hosts index 8d148a6..4427cd2 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -10,19 +10,18 @@ echo "Check from https://github.com/StevenBlack/hosts" lsd=$(curl -s "https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1"| jq -r '.[0].commit.committer.date') echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" echo "last local update: $(date -r /etc/hosts)" -if [ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ]; then - echo "Nothing to do" - exit -fi +[ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo "Nothing to do" && exit cd /etc cp -p hosts hosts.old hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) -curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | -awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" } -/^# Custom host / { print hosts; next } -/^# End of custom host / { next } -{print}' "$hosts" > hosts.new +curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk ' + BEGIN { hosts = ARGV[1]; ARGV[1] = "" } + /^# Custom host / { print hosts; next } + /^# End of custom host / { next } + { print } +' "$hosts" > hosts.new + mv hosts.new hosts [ "$(uname -s)" != Darwin ] || dscacheutil -flushcache diff -u /etc/hosts.old /etc/hosts | diffstat -- cgit v1.2.3 From ae04cc260d63765fc20a2d7bb21d121986f71445 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 29 Mar 2021 10:26:13 +0200 Subject: update --- .zshrc | 3 +++ bin/icat | 2 ++ bin/vm | 50 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/.zshrc b/.zshrc index bd67270..599574e 100644 --- a/.zshrc +++ b/.zshrc @@ -63,3 +63,6 @@ source ~/.zsh-powerline.sh [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +# test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" + diff --git a/bin/icat b/bin/icat index 0170513..d363e09 100755 --- a/bin/icat +++ b/bin/icat @@ -2,6 +2,8 @@ # Display images directly in terminal. # Tested with xterm v361. Depends on imagemagick convert(1). +[ "$LC_TERMINAL" = iTerm2 ] && [ -x "$HOME/.iterm2/imgcat" ] && exec "$HOME/.iterm2/imgcat" "$@" + # maxsize prints the geomtry size of terminal window, with # a maximum value of 1000 pixels for width and height, or # 640x480 if terminal size can not be probed. diff --git a/bin/vm b/bin/vm index 11fed61..818d6f8 100755 --- a/bin/vm +++ b/bin/vm @@ -62,7 +62,8 @@ del() { usage 'del name' 'Delete a VM' && return case $1 in ''|*/*|.*) die "invalid VM name: $1" ;; esac [ -d "$dir/$1" ] || die "$dir/$1 not found" - cd "$dir" && rm -r "$1" + [ -f "$dir/$1/vftool.pid" ] && die "vm $1 is still active, stop it first" + rm -rf "$dir/$1" } die() { [ "$1" ] && echo "$0: $@" >&2; exit 1; } @@ -78,13 +79,48 @@ exp() { cd "$dir/$1" || die "invalid VM: $1" [ -f vftool.pid ] || die "vm $1 is not active" - screen -X stuff 'root + sleep 1 && screen -X stuff 'root ' - screen -X stuff 'sed -i "s/die..Bootloader/;; #/" /sbin/setup-disk + sleep 1 && screen -X stuff 'sed -i.bak "s/die..Bootloader/;; # die \"Bootloader/" /sbin/setup-disk ' - screen -X stuff 'grep BOOTLOADER /sbin/setup-disk + sleep 1 && screen -X stuff 'setup-alpine -e +' + sleep 1 && screen -X stuff 'none +' + sleep 1 && screen -X stuff "$1 +" + sleep 1 && screen -X stuff 'eth0 +' + sleep 1 && screen -X stuff '192.168.64.2 +' + sleep 1 && screen -X stuff '255.255.255.0 +' + sleep 1 && screen -X stuff '192.168.64.1 +' + sleep 1 && screen -X stuff 'n +' + sleep 3 && screen -X stuff ' +' + sleep 1 && screen -X stuff '192.168.64.1 +' + sleep 1 && screen -X stuff 'Europe/Paris +' + sleep 5 && screen -X stuff 'none +' + sleep 1 && screen -X stuff 'chrony +' + sleep 5 && screen -X stuff '1 +' + sleep 1 && screen -X stuff 'openssh +' + sleep 5 && screen -X stuff 'vda +' + sleep 3 && screen -X stuff 'sys +' + sleep 1 && screen -X stuff 'y +' + sleep 20 && screen -X stuff 'cat /etc/fstab ' - } finalize() { @@ -109,7 +145,7 @@ info() { alpine_makefile='# Generated by "vm". DO NOT EDIT. # Check https://alpinelinux.org/downloads for possible upgrades -iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.2-aarch64.iso +iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.3-aarch64.iso iso = $(notdir $(iso_url)) isoinfo ?= /opt/homebrew/bin/isoinfo @@ -204,7 +240,7 @@ start_vm() ( ${iso+-c "$iso"} \ ${cpu+-p "$cpu"} \ ${ram+-m "$ram"} \ - ${arg+-m "$arg"} \ + -a "${arg-console=hvc0}" \ >>vftool.log 2>&1 & sleep 1 echo "$!" >vftool.pid -- cgit v1.2.3 From 3f9cb5afb3b6ee2d4234d5e4d3e5398cf022bc41 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 10 Apr 2021 14:15:57 +0200 Subject: update vm --- bin/vm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/vm b/bin/vm index 818d6f8..19255d2 100755 --- a/bin/vm +++ b/bin/vm @@ -47,6 +47,9 @@ add() { cp "../$c/vmlinux" "../$c/initrd" . echo "kernel=${k-vmlinux}" >> config echo "initrd=initrd" >> config + echo "cpu=1" >> config + echo "ram=512" >> config + echo "arg=\"console=hvc0\"" >> config } } @@ -119,7 +122,7 @@ exp() { ' sleep 1 && screen -X stuff 'y ' - sleep 20 && screen -X stuff 'cat /etc/fstab + sleep 20 && screen -X stuff 'blkid /dev/vda3 ' } @@ -253,7 +256,7 @@ stop() { [ "$1" ] || die 'stop: name missing' cd "$dir/$1" || die 'stop $1 failed' [ -f vftool.pid ] || die "stop: vm $1 is not active" - kill $(cat vftool.pid) + kill $(cat vftool.pid) || rm -f vftool.pid } usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; } -- cgit v1.2.3 From 6962b31552fbf1a2516b0777cc4a52d99a76f6f2 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 5 May 2021 20:32:05 +0200 Subject: update --- .bash-powerline.sh | 12 ++++++------ .bashrc | 55 +++++++++++++++++++++++++++++++----------------------- .profile | 4 +++- .tmux.conf | 3 --- .vimrc | 4 +++- .zshrc | 3 +++ bin/update_hosts | 1 - 7 files changed, 47 insertions(+), 35 deletions(-) delete mode 100644 .tmux.conf diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 626157a..f87eadb 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -9,8 +9,8 @@ __powerline() { readonly COLOR_CWD='\[\033[0;34m\]' # blue readonly COLOR_GIT='\[\033[0;36m\]' # cyan #readonly COLOR_SUCCESS='\[\033[0;32m\]' # green - readonly COLOR_SUCCESS='\[\033[0;1;34m\]' # blue, bold - readonly COLOR_FAILURE='\[\033[0;1;31m\]' # red, bold + readonly COLOR_SUCCESS='\[\033[0;34m\]' # blue + readonly COLOR_FAILURE='\[\033[0;31m\]' # red #readonly SYMBOL_GIT_BRANCH='⑂' readonly SYMBOL_GIT_BRANCH='→' @@ -26,7 +26,7 @@ __powerline() { host=$(hostname) fi - [ "$PS_SYMBOL" ] || PS_SYMBOL=';' + [ "$PS_SYMBOL" ] || PS_SYMBOL='$' __git_info() { [[ $POWERLINE_GIT = 0 ]] && return # disabled @@ -67,9 +67,9 @@ __powerline() { # Check the exit code of the previous command and display different # colors in the prompt accordingly. if [ $? -eq 0 ]; then - local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET" + local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET" else - local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET" + local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET" fi local cwd="$COLOR_CWD\w$RESET" @@ -86,7 +86,7 @@ __powerline() { local git="$COLOR_GIT$(__git_info)$RESET" fi - [ "$SSH_TTY" ] && PS1=": $host:$cwd$git$symbol" || PS1=": $cwd$git$symbol" + [ "$SSH_TTY" ] && PS1="$host:$cwd$git$symbol" || PS1="$cwd$git$symbol" } PROMPT_DIRTRIM=1 diff --git a/.bashrc b/.bashrc index 95f2377..fca1532 100644 --- a/.bashrc +++ b/.bashrc @@ -40,41 +40,41 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date export TERMINAL=xt -alias cl='cf xft:Mono:size=12' -alias cp='cp --reflink' -alias ls='ls --color=auto -v' -alias ll='ls -AlFhv' +#alias cl='cf xft:Mono:size=12' +#alias cp='cp --reflink' +#alias ls='ls --color=auto -v' +alias ls='ls -GF' +alias ll='ls -AlGFhv' alias vi='vim' alias view='vim -R' #alias op='xdg-open' alias git='hub' #alias go='go1.14.1' -alias go11='go1.11.13' -alias go12='go1.12.10' -alias go13='go1.13.8' -alias go14='go1.14.2' +#alias go11='go1.11.13' +#alias go12='go1.12.10' +#alias go13='go1.13.8' +#alias go14='go1.14.2' alias gob='go build' alias goh='p go help' alias god='p go doc' alias gtr='go test -v -run' alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' -#alias vi='vim' alias rvi='sudo vim' alias rxt='sudo xt' alias rxvi='sudo xvi' alias ww='vi ~/Wiki/HomePage' alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' -alias uc='systemctl --user' -alias wpa='sudo wpa_gui -i wlan0' +#alias uc='systemctl --user' +#alias wpa='sudo wpa_gui -i wlan0' -alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' +#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 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' @@ -85,6 +85,9 @@ alias wai='~/go/src/github.co/traefik/whoami/whoami' # yaegi debug export YAEGI_DOT_CMD='dotty -' +export YAEGI_UNSAFE=1 +export YAEGI_UNRESTRICTED=1 +export YAEGI_SYSCALL=1 mosht() { mosh "$@" -- tmux new -A; } export -f mosht @@ -107,6 +110,12 @@ export -f ws wsd() (cd ~/Wiki && git add . && git diff --cached) export -f wsd +man() { + local width='' + [ $(tput cols) -gt 88 ] && width='MANWIDTH=88' + env $width man "$@" +} + meteo() { local request="wttr.in/${1-Toulouse}?F&T" [ "$(tput cols)" -lt 125 ] && request+='&n' @@ -117,19 +126,19 @@ meteo() { # fzf # Accomodate different base prefix on termux -[ -d "$HOME/../usr" ] && base=.. -[ -f "$base/usr/share/fzf/completion.bash" ] && . "$base/usr/share/fzf/completion.bash" -[ -f "$base/usr/share/fzf/key-bindings.bash" ] && . "$base/usr/share/fzf/key-bindings.bash" -unset base +#[ -d "$HOME/../usr" ] && base=.. +#[ -f "$base/usr/share/fzf/completion.bash" ] && . "$base/usr/share/fzf/completion.bash" +#[ -f "$base/usr/share/fzf/key-bindings.bash" ] && . "$base/usr/share/fzf/key-bindings.bash" +#unset base # Arch: display package to install for missing commands -[ -f '/usr/share/doc/pkgfile/command-not-found.bash' ] && . /usr/share/doc/pkgfile/command-not-found.bash +#[ -f '/usr/share/doc/pkgfile/command-not-found.bash' ] && . /usr/share/doc/pkgfile/command-not-found.bash # Display git status in prompt . ~/.bash-powerline.sh # export PS1='; ' # load Nix config files (aka auto-completion etc.) -export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" +#export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" -[ -f ~/.fzf.bash ] && source ~/.fzf.bash +#[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/.profile b/.profile index acb8299..78b4393 100644 --- a/.profile +++ b/.profile @@ -1,6 +1,6 @@ # ~/.profile -PATH=~/bin:$PATH:~/go/bin +PATH=~/bin:/opt/homebrew/bin:$PATH:~/go/bin [ "${SHELL##*/}" = bash ] && . ~/.bashrc @@ -8,3 +8,5 @@ PATH=~/bin:$PATH:~/go/bin #case $HOSTNAME in #([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; #esac + +. "/opt/homebrew/etc/profile.d/bash_completion.sh" diff --git a/.tmux.conf b/.tmux.conf deleted file mode 100644 index 8d624a0..0000000 --- a/.tmux.conf +++ /dev/null @@ -1,3 +0,0 @@ -set-option -g prefix ² -unbind-key C-b -bind-key ² send-prefix diff --git a/.vimrc b/.vimrc index 9f5b410..6b26f67 100644 --- a/.vimrc +++ b/.vimrc @@ -25,7 +25,9 @@ autocmd filetype vimki nnoremap - YpVr- let g:go_def_mode = "gopls" let g:go_info_mode = "gopls" let g:go_list_type = "quickfix" -let g:go_fmt_command = "goimports" +" let g:go_fmt_command = "goimports" +let g:go_fmt_command = "gopls" +let g:go_gopls_gofumpt = 1 let g:go_metalinter_command = "golangci-lint" autocmd FileType go syntax on autocmd FileType go nmap b (go-build) diff --git a/.zshrc b/.zshrc index 599574e..fc3b9f9 100644 --- a/.zshrc +++ b/.zshrc @@ -1,5 +1,8 @@ # Environment export YAEGI_DOT_CMD='dotty -' +export YAEGI_UNSAFE=1 +export YAEGI_UNRESTRICTED=1 +export YAEGI_SYSCALL=1 # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' diff --git a/bin/update_hosts b/bin/update_hosts index 4427cd2..75c41d1 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -3,7 +3,6 @@ # Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc. # Custom hosts are preserved. - [ "$USER" = root ] || exec sudo "$0" "$@" echo "Check from https://github.com/StevenBlack/hosts" -- cgit v1.2.3 From ebfa4aaf6afe44ffcc15261d8333c861c62ae27d Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 9 May 2021 16:59:33 +0200 Subject: add gemini --- bin/gemini | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 bin/gemini diff --git a/bin/gemini b/bin/gemini new file mode 100755 index 0000000..1bc3d57 --- /dev/null +++ b/bin/gemini @@ -0,0 +1,132 @@ +#!/usr/bin/env yaegi +package main + +import ( + "bufio" + "crypto/tls" + "fmt" + "io/ioutil" + "net/url" + "os" + "strconv" + "strings" +) + +func main() { + stdinReader := bufio.NewReader(os.Stdin) + var u string // URL + links := make([]string, 0, 100) + history := make([]string, 0, 100) + for { + fmt.Print("> ") + cmd, _ := stdinReader.ReadString('\n') + cmd = strings.TrimSpace(cmd) + // Command dispatch + switch strings.ToLower(cmd) { + case "": // Nothing + continue + case "q": // Quit + fmt.Println("Bye!") + os.Exit(0) + case "b": // Back + if len(history) < 2 { + fmt.Println("No history yet!") + continue + } + u = history[len(history)-2] + history = history[0 : len(history)-2] + default: + index, err := strconv.Atoi(cmd) + if err != nil { + // Treat this as a URL + u = cmd + if !strings.HasPrefix(u, "gemini://") { + u = "gemini://" + u + } + } else { + // Treat this as a menu lookup + u = links[index-1] + } + } + // Parse URL + parsed, err := url.Parse(u) + if err != nil { + fmt.Println("Error parsing URL!") + continue + } + // Connect to server + conn, err := tls.Dial("tcp", parsed.Host+":1965", &tls.Config{InsecureSkipVerify: true}) + if err != nil { + fmt.Println("Failed to connect: " + err.Error()) + continue + } + defer conn.Close() + // Send request + conn.Write([]byte(u + "\r\n")) + // Receive and parse response header + reader := bufio.NewReader(conn) + responseHeader, err := reader.ReadString('\n') + parts := strings.Fields(responseHeader) + status, err := strconv.Atoi(parts[0][0:1]) + meta := parts[1] + // Switch on status code + switch status { + case 1, 3, 6: + // No input, redirects or client certs + fmt.Println("Unsupported feature!") + case 2: + // Successful transaction + // text/* content only + if !strings.HasPrefix(meta, "text/") { + fmt.Println("Unsupported type " + meta) + continue + } + // Read everything + bodyBytes, err := ioutil.ReadAll(reader) + if err != nil { + fmt.Println("Error reading body") + continue + } + body := string(bodyBytes) + if meta == "text/gemini" { + // Handle Gemini map + links = make([]string, 0, 100) + preformatted := false + for _, line := range strings.Split(body, "\n") { + if strings.HasPrefix(line, "```") { + preformatted = !preformatted + } else if preformatted { + fmt.Println(line) + } else if strings.HasPrefix(line, "=>") { + line = line[2:] + bits := strings.Fields(line) + parsedLink, err := url.Parse(bits[0]) + if err != nil { + continue + } + link := parsed.ResolveReference(parsedLink).String() + var label string + if len(bits) == 1 { + label = link + } else { + label = strings.Join(bits[1:], " ") + } + links = append(links, link) + fmt.Printf("[%d] %s\n", len(links), label) + } else { + // This should really be wrapped, but there's + // no easy support for this in Go's standard + // library + fmt.Println(line) + } + } + } else { + // Just print any other kind of text + fmt.Print(body) + } + history = append(history, u) + case 4, 5: + fmt.Println("ERROR: " + meta) + } + } +} -- cgit v1.2.3 From 67efb5857e720ebbe323ea7284793c43f27b0f67 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 29 May 2021 18:16:42 +0200 Subject: update --- .bash-powerline.sh | 12 ++--- bin/md | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 6 deletions(-) create mode 100755 bin/md diff --git a/.bash-powerline.sh b/.bash-powerline.sh index f87eadb..626157a 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -9,8 +9,8 @@ __powerline() { readonly COLOR_CWD='\[\033[0;34m\]' # blue readonly COLOR_GIT='\[\033[0;36m\]' # cyan #readonly COLOR_SUCCESS='\[\033[0;32m\]' # green - readonly COLOR_SUCCESS='\[\033[0;34m\]' # blue - readonly COLOR_FAILURE='\[\033[0;31m\]' # red + readonly COLOR_SUCCESS='\[\033[0;1;34m\]' # blue, bold + readonly COLOR_FAILURE='\[\033[0;1;31m\]' # red, bold #readonly SYMBOL_GIT_BRANCH='⑂' readonly SYMBOL_GIT_BRANCH='→' @@ -26,7 +26,7 @@ __powerline() { host=$(hostname) fi - [ "$PS_SYMBOL" ] || PS_SYMBOL='$' + [ "$PS_SYMBOL" ] || PS_SYMBOL=';' __git_info() { [[ $POWERLINE_GIT = 0 ]] && return # disabled @@ -67,9 +67,9 @@ __powerline() { # Check the exit code of the previous command and display different # colors in the prompt accordingly. if [ $? -eq 0 ]; then - local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET" + local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET" else - local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET" + local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET" fi local cwd="$COLOR_CWD\w$RESET" @@ -86,7 +86,7 @@ __powerline() { local git="$COLOR_GIT$(__git_info)$RESET" fi - [ "$SSH_TTY" ] && PS1="$host:$cwd$git$symbol" || PS1="$cwd$git$symbol" + [ "$SSH_TTY" ] && PS1=": $host:$cwd$git$symbol" || PS1=": $cwd$git$symbol" } PROMPT_DIRTRIM=1 diff --git a/bin/md b/bin/md new file mode 100755 index 0000000..ca08090 --- /dev/null +++ b/bin/md @@ -0,0 +1,136 @@ +#!/bin/sh + +# See https://spec.commonmark.org for reference +md2html() { + awk ' + function newblock(nb) { + if (text) print "<" block ">" text "" + text = "" + block = nb ? nb : "p" + } + + function subinline(tgl, inl) { + while (match($0, tgl)) { + if (inline[ni] == inl) + ni -= sub(tgl, "") + else if (sub(tgl, "<" inl ">")) + inline[++ni] = inl + } + } + + function dolink(href, lnk) { + # Undo escaped html in uris + gsub(/&/, "\\&", href) + gsub(/</, "<", href) + gsub(/>/, ">", href) + # & can be tricky, and not standard: + gsub(/&/, "\\\\\\&", href) + gsub(/&/, "\\\\\\&", lnk) + return "" lnk "" + } + + BEGIN { ni = 0; nl = 0; text = ""; block = "p" } + + # Escape html + esc != "false" { gsub("&", "\\&"); gsub("<", "\\<"); gsub(">", "\\>") } + + # Horizontal rules (_ is not in markdown) + /^[ ]*([-*_] ?)+[ ]*$/ && text == "" { print "
"; next } + + # Tables (not in markdown) + # Syntax: + # Right Align| Center Align |Left Align + /([ ]\|)|(\|[ ])/ { + if (block != "table") newblock("table") + nc = split($0, cells, "|") + $0 = "\n" + for (i = 1; i <= nc; i++) { + align = "left" + if (sub(/^[ ]+/, "", cells[i])) { + if (sub(/[ ]+$/, "", cells[i])) + align = "center" + else + align = "right" + } + sub(/[ ]+$/, "", cells[i]) + $0 = $0 "" cells[i] "\n" + } + $0 = $0 "" + } + + # Ordered and unordered (possibly nested) lists + /^[ ]*([*+-]|(([0-9]+[\.-]?)+))[ ]/ { + newblock("li") + nnl = 1 + while (match($0, /^[ ]/)) { sub(/^[ ]/,""); nnl++ } + while (nl > nnl) print "" + while (nl < nnl) { + list[++nl] = "ol" + if (match($0, /^[*+-]/)) list[nl] = "ul" + print "<" list[nl] ">" + } + sub(/^([*+-]|(([0-9]+[\.-]?)+))[ ]/,"") + } + + # Multi line list items + block == "li" { sub(/^( *)|( *)/,"") } + + # Code blocks + /^( | )/ { + if (block != "code") newblock("code") + sub(/^( | )/, "") + text = text $0 "\n" + next + } + + # Paragraph + /^$/ { newblock(); while(nl > 0) print "" } + + # Setex-style Headers (plus h3 with underscores) + /^=+$/ { block = "h" 1; next } + /^-+$/ { block = "h" 2; next } + /^_+$/ { block = "h" 3; next } + + # Atx-style headers + /^#/ { + newblock() + match($0, /#+/) + n = RLENGTH + if (n > 6) n = 6 + sub(/# */, "#") + text = substr($0, RLENGTH + 1) + block = "h" n + next + } + + { + # Images + while (match($0, /!\[[^\]]+\]\([^\)]+\)/)) { + split(substr($0, RSTART, RLENGTH), a, /(!\[)|\)|(\]\()/) + sub(/!\[[^\]]+\]\([^\)]+\)/, "\""") + } + # Links + while (match($0, /\[[^\]]+\]\([^\)]+\)/)) { + split(substr($0, RSTART, RLENGTH), a, /[\[\)]|(\]\()/) + sub(/\[[^\]]+\]\([^\)]+\)/, dolink(a[3], a[2])) + } + # Auto links (uri matching is poor) + na = split($0, a, /(^\()|[ ]|([,\.\)]([ ]|$))/) + for (i = 1; i <= na; i++) + if (match(a[i], /^(((https?|ftp|file|news|irc):\/\/)|(mailto:)).+$/)) + sub(a[i], dolink(a[i], a[i])) + # Inline + subinline("(\\*\\*)|(__)", "strong") + subinline("\\*", "em") + subinline("`", "code") + text = text (text ? " " : "") $0 + } + + END { + while(ni > 0) text = text "" + newblock() + while(nl > 0) print "" + }' "$1" +} + +md2html "$1" -- cgit v1.2.3 From 4bd0a72b639662f9a13c7c0adb1b423383c84ef5 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 30 May 2021 12:17:55 +0200 Subject: update --- .bashrc | 2 ++ .profile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index fca1532..c6c7b1e 100644 --- a/.bashrc +++ b/.bashrc @@ -47,6 +47,8 @@ alias ls='ls -GF' alias ll='ls -AlGFhv' alias vi='vim' alias view='vim -R' +alias ldd='otool -L' +alias ibrew='arch -x86_64 /usr/local/bin/brew' #alias op='xdg-open' alias git='hub' #alias go='go1.14.1' diff --git a/.profile b/.profile index 78b4393..bbf3c42 100644 --- a/.profile +++ b/.profile @@ -1,6 +1,6 @@ # ~/.profile -PATH=~/bin:/opt/homebrew/bin:$PATH:~/go/bin +PATH=~/bin:/opt/homebrew/bin:$PATH:~/go/bin:~/.cargo/bin [ "${SHELL##*/}" = bash ] && . ~/.bashrc -- cgit v1.2.3 From 2dc5563129877c1aad571e2023a7e9cc8eec5d04 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 30 May 2021 19:01:16 +0200 Subject: update --- .bashrc | 5 ++--- bin/vm | 45 +++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.bashrc b/.bashrc index c6c7b1e..b50da1b 100644 --- a/.bashrc +++ b/.bashrc @@ -121,12 +121,13 @@ man() { meteo() { local request="wttr.in/${1-Toulouse}?F&T" [ "$(tput cols)" -lt 125 ] && request+='&n' - curl -H "Accept-Language: ${LANG%_*}" --compressed "$request" + curl -H "Accept-Language: fr" --compressed "$request" } #PS1='[\u@\h \W]\$ ' # fzf +[ -f ~/.fzf.bash ] && source ~/.fzf.bash # Accomodate different base prefix on termux #[ -d "$HOME/../usr" ] && base=.. #[ -f "$base/usr/share/fzf/completion.bash" ] && . "$base/usr/share/fzf/completion.bash" @@ -142,5 +143,3 @@ meteo() { # load Nix config files (aka auto-completion etc.) #export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" - -#[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/bin/vm b/bin/vm index 19255d2..b0e1303 100755 --- a/bin/vm +++ b/bin/vm @@ -28,7 +28,7 @@ add() { while getopts :c:i:k:p:s: opt; do case $opt in [cikps]) eval "$opt=$OPTARG";; - *) Opth=1 add; exit ;; + *) Opth=1 add "$1"; exit ;; esac done shift $((OPTIND - 1)) @@ -38,25 +38,27 @@ add() { [ "$1" = 'alpine-iso' ] && return mkdir -p "$dir/$1" && cd "$dir/$1" || die "add $1 failed" hdd=${p-$1.raw} - [ -f "$hdd" ] || dd if=/dev/zero of=$hdd bs=1 count=0 seek=${s-32g} 2>/dev/null + [ -f "$hdd" ] || dd if=/dev/zero of="$hdd" bs=1 count=0 seek="${s-32g}" 2>/dev/null echo "hdd=\"$hdd\"" > config [ "$c" ] && { [ -d "../$c" ] || die "invalid directory: $dir/$c" iso=$(getconf "$c" iso) - [ "$iso" ] && echo "iso=\"../$c/$iso\"" >> config cp "../$c/vmlinux" "../$c/initrd" . - echo "kernel=${k-vmlinux}" >> config - echo "initrd=initrd" >> config - echo "cpu=1" >> config - echo "ram=512" >> config - echo "arg=\"console=hvc0\"" >> config + [ "$iso" ] && echo "iso=\"../$c/$iso\"" >> config + cat <<- EOT >> config + kernel=${k-vmlinux} + initrd=initrd + cpu=1 + ram=512 + arg="console=hvc0" + EOT } } console() { usage 'console name' 'Attach a console to a VM' && return [ "$1" ] || die 'console: name is missing' - cd "$dir/$1" || die 'console $1 failed' + cd "$dir/$1" || die "console $1 failed" [ -f vftool.pid ] || die "vm $1 is not active" screen -r "$1" } @@ -66,10 +68,10 @@ del() { case $1 in ''|*/*|.*) die "invalid VM name: $1" ;; esac [ -d "$dir/$1" ] || die "$dir/$1 not found" [ -f "$dir/$1/vftool.pid" ] && die "vm $1 is still active, stop it first" - rm -rf "$dir/$1" + rm -rf "${dir:?}/$1" } -die() { [ "$1" ] && echo "$0: $@" >&2; exit 1; } +die() { [ "$1" ] && echo "$0: $*" >&2; exit 1; } edit() { usage 'edit name' 'Edit a VM configuration' && return @@ -128,14 +130,14 @@ exp() { finalize() { tty=$(vftool_tty) - echo "root\nuname -a" >> "$tty" + printf 'root\nuname -a\n' >> "$tty" } getconf() { awk -F '=' -v k="$2" '$1 == k {print $2}' "$dir/$1/config"; } help() { usage 'help' 'Print this help text' && return - echo "$vm_version\nManage virtual machines\nUsage: vm command [options] [args]" + printf '%s\n' "$vm_version\nManage virtual machines\nUsage: vm command [options] [args]" Opth=1; for c in $Cmdlist; do $c; done } @@ -210,13 +212,12 @@ ls() { } start() { - usage 'start [-af][-c vm] name' 'Start a VM' && return - while getopts :ac:f opt; do + usage 'start [-af] name' 'Start a VM' && return + while getopts :af opt; do case $opt in (a) a=1 ;; - (c) from=$OPTARG ;; (f) f=1 ;; - (*) Opth=1 start; exit;; + (*) Opth=1 start "$1"; exit;; esac done shift $((OPTIND - 1)) @@ -227,7 +228,7 @@ start() { [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed" start_vm & sleep 2 [ "$f" ] && finalize - [ "$a" ] && vm console $1 + [ "$a" ] && vm console "$1" } start_vm() ( @@ -254,9 +255,9 @@ start_vm() ( stop() { usage 'stop name' 'Stop a VM' && return [ "$1" ] || die 'stop: name missing' - cd "$dir/$1" || die 'stop $1 failed' + cd "$dir/$1" || die "stop $1 failed" [ -f vftool.pid ] || die "stop: vm $1 is not active" - kill $(cat vftool.pid) || rm -f vftool.pid + kill "$(cat vftool.pid)" || rm -f vftool.pid } usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; } @@ -274,8 +275,8 @@ Cmdlist='add console del edit exp info help ls log start stop version' [ "$1" ] && C=$1 && shift 1 || { help; exit 1; } for c in $Cmdlist; do case $c in - ($C) cmd=$c; break ;; - ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c ;; + ("$C") cmd=$c; break ;; + ("$C"*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c ;; esac done [ "$cmd" ] || { help; exit 1; } && $cmd "$@" -- cgit v1.2.3 From 87b63654a7a881afefddaeb6c3dbbf32105070bb Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 4 Jun 2021 16:43:08 +0200 Subject: update, add fv --- bin/fv | 6 ++++++ bin/update_hosts | 6 +++--- bin/vm | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100755 bin/fv diff --git a/bin/fv b/bin/fv new file mode 100755 index 0000000..5662ed3 --- /dev/null +++ b/bin/fv @@ -0,0 +1,6 @@ +#!/bin/sh +# quick file viewer +#exec fzf --multi --preview-window=right:66% --preview 'cat {1}' +exec fzf --ansi --multi --preview-window=right:75% \ + --bind=left:preview-page-up --bind=right:preview-page-down \ + --preview 'cat {1}' diff --git a/bin/update_hosts b/bin/update_hosts index 75c41d1..e7321bf 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -5,7 +5,7 @@ [ "$USER" = root ] || exec sudo "$0" "$@" -echo "Check from https://github.com/StevenBlack/hosts" +echo "Checking from https://github.com/StevenBlack/hosts:" lsd=$(curl -s "https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1"| jq -r '.[0].commit.committer.date') echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" echo "last local update: $(date -r /etc/hosts)" @@ -14,7 +14,7 @@ echo "last local update: $(date -r /etc/hosts)" cd /etc cp -p hosts hosts.old hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) -curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk ' +curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk ' BEGIN { hosts = ARGV[1]; ARGV[1] = "" } /^# Custom host / { print hosts; next } /^# End of custom host / { next } @@ -22,5 +22,5 @@ curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | aw ' "$hosts" > hosts.new mv hosts.new hosts -[ "$(uname -s)" != Darwin ] || dscacheutil -flushcache +[ "$(uname -s)" != Darwin ] || { dscacheutil -flushcache; killall -HUP mDNSResponder; } diff -u /etc/hosts.old /etc/hosts | diffstat diff --git a/bin/vm b/bin/vm index b0e1303..732ba49 100755 --- a/bin/vm +++ b/bin/vm @@ -179,7 +179,7 @@ $(isoinfo): init_alpine() { mkdir -p "$dir/alpine-iso" && cd "$dir/alpine-iso" || die 'init alpine failed' - [ -f 'Makefile' ] || printf "%s" "$alpine_makefile" > Makefile + [ -f 'Makefile' ] || printf '%s' "$alpine_makefile" > Makefile make -s all } -- cgit v1.2.3 From 684561b3c989f8421963c8c5c0cd0f38299551e0 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 5 Jun 2021 17:22:33 +0200 Subject: update --- .vim/pack/mvertes/install.sh | 8 ++++++-- Library/LaunchAgents/local.update_hosts.plist | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Library/LaunchAgents/local.update_hosts.plist diff --git a/.vim/pack/mvertes/install.sh b/.vim/pack/mvertes/install.sh index 24a52f0..388a620 100755 --- a/.vim/pack/mvertes/install.sh +++ b/.vim/pack/mvertes/install.sh @@ -1,7 +1,11 @@ #!/bin/sh -e -plugins='git@github.com:mvertes/vimki git@github.com:fatih/vim-go' -ht='vim -c "helptags doc" -c "q"' +plugins=' +git@github.com:mvertes/vimki +git@github.com:fatih/vim-go +git@github.com:othree/xml.vim +' +ht='test -d doc && vim -c "helptags doc" -c "q"' mkdir -p start cd start diff --git a/Library/LaunchAgents/local.update_hosts.plist b/Library/LaunchAgents/local.update_hosts.plist new file mode 100644 index 0000000..c4cf01e --- /dev/null +++ b/Library/LaunchAgents/local.update_hosts.plist @@ -0,0 +1,18 @@ + + + + + Label + local.update_hosts + Program + /Users/marc/bin/update_hosts + StartCalendarInterval + + Hour + 9 + Minute + 0 + + + -- cgit v1.2.3 From 6462de909492c58a8b1061633cec1c325539b3b6 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 11 Jun 2021 00:33:09 +0200 Subject: added migrate_vimki --- bin/migrate_vimki | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 bin/migrate_vimki diff --git a/bin/migrate_vimki b/bin/migrate_vimki new file mode 100755 index 0000000..15242e6 --- /dev/null +++ b/bin/migrate_vimki @@ -0,0 +1,58 @@ +#!/bin/sh + +# Migrate Wiki content from vimki to vimki2 format. + +fixfile() { + awk ' + { + for (i = 1; i <= NR; i++) { + if (match($i, /^[A-Z][A-Z_0-9]*[a-z][a-z0-9]*[_A-Z]/) == 0) continue + s = $i + l = "" + while (match(s, /^[A-Z][A-Z_0-9]*[a-z]+/) != 0) { + l = l substr(s, 1, RLENGTH) " " + s = substr(s, RLENGTH+1) + } + p = match(s, /[^A-Za-z0-9_]/) + if (p != 0) { + s2 = substr(s, 1, p-1) "]" substr(s, p) + s = s2 + } else s = s "]" + l = "[" l s + gsub(/[ \t_]+/, " ", l) + sub(/ *]/, "]", l) + $i = tolower(l) + } + print + } + ' "${1:-HomePage}" +} + +fixname() { + echo "$1" | awk '{ + s = $0 + l = "" + while (match(s, /^[A-Z][A-Z_0-9]*[a-z]+/) != 0) { + l = l substr(s, 1, RLENGTH) " " + s = substr(s, RLENGTH+1) + } + p = match(s, /[^A-Za-z0-9_]/) + if (p != 0) { + s2 = substr(s, 1, p-1) "]" substr(s, p) + s = s2 + } + l = l s + gsub(/[ \t_]+/, " ", l) + sub(/ *$/, "", l) + print tolower(l) + + }' +} + +mkdir -p $HOME/Wiki2 +cd $HOME/Wiki +for file in *; do + new=$(fixname "$file") + echo "$new" + fixfile "$file" > "$HOME/Wiki2/$new" +done -- cgit v1.2.3 From 445652e876c99ea24f7211f356c2a3d2c41d5d09 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 12 Jun 2021 00:24:05 +0200 Subject: update --- .vim/pack/mvertes/install.sh | 1 + .vimrc | 4 ---- Library/LaunchAgents/local.update_hosts.plist | 18 ------------------ 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 Library/LaunchAgents/local.update_hosts.plist diff --git a/.vim/pack/mvertes/install.sh b/.vim/pack/mvertes/install.sh index 388a620..48d5950 100755 --- a/.vim/pack/mvertes/install.sh +++ b/.vim/pack/mvertes/install.sh @@ -4,6 +4,7 @@ plugins=' git@github.com:mvertes/vimki git@github.com:fatih/vim-go git@github.com:othree/xml.vim +git@github.com:junegunn/fzf.vim ' ht='test -d doc && vim -c "helptags doc" -c "q"' diff --git a/.vimrc b/.vimrc index 6b26f67..68ae82a 100644 --- a/.vimrc +++ b/.vimrc @@ -12,15 +12,11 @@ set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' " vimki plugin -let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on 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/Library/LaunchAgents/local.update_hosts.plist b/Library/LaunchAgents/local.update_hosts.plist deleted file mode 100644 index c4cf01e..0000000 --- a/Library/LaunchAgents/local.update_hosts.plist +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Label - local.update_hosts - Program - /Users/marc/bin/update_hosts - StartCalendarInterval - - Hour - 9 - Minute - 0 - - - -- cgit v1.2.3 From 2621ec5405f52343cf253d02e307c5b160cf7f04 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 13 Jun 2021 14:49:53 +0200 Subject: update --- bin/update_hosts | 8 ++++---- bin/vimki | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100755 bin/vimki diff --git a/bin/update_hosts b/bin/update_hosts index e7321bf..8550ec3 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -13,11 +13,11 @@ echo "last local update: $(date -r /etc/hosts)" cd /etc cp -p hosts hosts.old -hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) +hosts=$(awk '/^# Custom host/, /^# End of custom host/' hosts.old) curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk ' - BEGIN { hosts = ARGV[1]; ARGV[1] = "" } - /^# Custom host / { print hosts; next } - /^# End of custom host / { next } + BEGIN { hosts = ARGV[1]; ARGV[1] = "" } + /^# Custom host/ { print hosts; next } + /^# End of custom host/ { next } { print } ' "$hosts" > hosts.new diff --git a/bin/vimki b/bin/vimki new file mode 100755 index 0000000..50ab6ea --- /dev/null +++ b/bin/vimki @@ -0,0 +1,29 @@ +#!/bin/sh + +# Batch operations on vimki + +# rename changes the link name and propagates the change in the wiki +rename1() { + gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + { + gsub("[[]" old "[]]", "[" new "]") + print + } + ' "$3" +} + +linkfile() { + echo "$1" + #echo "$1" | tr '[:upper:] àçéèêëîïôèùûü' '[:lower:]_aceeeeiiouuu' +} + +rename() { + for f in *; do + rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" + done + oldf="$(linkfile "$1")" + [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2")" +} + +cd ~/Wiki +"$@" -- cgit v1.2.3 From 53569210e7967c6d891affb027c1ea202194f9c0 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 19 Jun 2021 13:00:21 +0200 Subject: vimki: rename handle accents and punctuation --- bin/vimki | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/bin/vimki b/bin/vimki index 50ab6ea..f2ba45b 100755 --- a/bin/vimki +++ b/bin/vimki @@ -5,25 +5,46 @@ # rename changes the link name and propagates the change in the wiki rename1() { gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + BEGIN { + rx = old + gsub(/_/, "\\W+", rx) + gsub(/a/, "[aåäáàâã]", rx) + gsub(/c/, "[cç]", rx) + gsub(/e/, "[eéèêë]", rx) + gsub(/i/, "[iîíìï]", rx) + gsub(/o/, "[oôöóõò]", rx) + gsub(/u/, "[uùûüú]", rx) + gsub(/y/, "[yÿ]", rx) + gsub(/n/, "[nñ]", rx) + } { - gsub("[[]" old "[]]", "[" new "]") + gsub("[[]" rx "[]]", "[" new "]") print } ' "$3" } linkfile() { - echo "$1" - #echo "$1" | tr '[:upper:] àçéèêëîïôèùûü' '[:lower:]_aceeeeiiouuu' + echo "$1" | + tr '[:upper:]' '[:lower:]' | + tr 'åäáàâãçéèêëîíìïôöóõòùûüúÿñ' 'aaaaaaceeeeiiiiooooouuuuyn' | + awk '{gsub(/\W+/, "_"); print}' } rename() { - for f in *; do + for f in *.md; do + [ "$(head -c 8 "$f")" = VimCrypt ] && continue rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done oldf="$(linkfile "$1")" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2")" } +fixfiles() { + for f in *; do + mv "$f" "$(linkfile "$f")" + done +} + cd ~/Wiki "$@" -- cgit v1.2.3 From 6f40c5ba8549a66bd2b9ab449f57a574f0c2e905 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 19 Jun 2021 15:59:06 +0200 Subject: vimki: fix rename --- bin/vimki | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/vimki b/bin/vimki index f2ba45b..3c6626c 100755 --- a/bin/vimki +++ b/bin/vimki @@ -24,6 +24,8 @@ rename1() { ' "$3" } +#shellcheck disable=SC2020 + linkfile() { echo "$1" | tr '[:upper:]' '[:lower:]' | @@ -36,8 +38,8 @@ rename() { [ "$(head -c 8 "$f")" = VimCrypt ] && continue rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done - oldf="$(linkfile "$1")" - [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2")" + oldf="$(linkfile "$1").md" + [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2").md" } fixfiles() { @@ -46,5 +48,5 @@ fixfiles() { done } -cd ~/Wiki +cd ~/Wiki || exit "$@" -- cgit v1.2.3 From 1433c15716d0da97d54d39f7397b80654ce10415 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 20 Jun 2021 14:33:05 +0200 Subject: vimki: fix rename --- bin/vimki | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/vimki b/bin/vimki index 3c6626c..2f64162 100755 --- a/bin/vimki +++ b/bin/vimki @@ -5,8 +5,16 @@ # rename changes the link name and propagates the change in the wiki rename1() { gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + { + gsub("[[]" old "[]]", "[" new "]") + print + } + ' "$3" +} + +link2rx() { + gawk -v rx="$1" -v IGNORECASE=1 ' BEGIN { - rx = old gsub(/_/, "\\W+", rx) gsub(/a/, "[aåäáàâã]", rx) gsub(/c/, "[cç]", rx) @@ -16,12 +24,8 @@ rename1() { gsub(/u/, "[uùûüú]", rx) gsub(/y/, "[yÿ]", rx) gsub(/n/, "[nñ]", rx) - } - { - gsub("[[]" rx "[]]", "[" new "]") - print - } - ' "$3" + print rx + }' } #shellcheck disable=SC2020 @@ -34,9 +38,10 @@ linkfile() { } rename() { + rx=$(link2rx "$1") for f in *.md; do [ "$(head -c 8 "$f")" = VimCrypt ] && continue - rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" + rename1 "$rx" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done oldf="$(linkfile "$1").md" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2").md" -- cgit v1.2.3 From 0ad6087640b7c6f9bee6e954f0736d9c183f6a5c Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 20 Jun 2021 15:36:38 +0200 Subject: vimki: parallelize rename --- bin/vimki | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/vimki b/bin/vimki index 2f64162..e3e0f4d 100755 --- a/bin/vimki +++ b/bin/vimki @@ -4,12 +4,13 @@ # rename changes the link name and propagates the change in the wiki rename1() { + [ "$(head -c 8 "$3")" = VimCrypt ] && return gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' { gsub("[[]" old "[]]", "[" new "]") print } - ' "$3" + ' "$3" > "$3.$$" && mv "$3.$$" "$3" } link2rx() { @@ -39,10 +40,8 @@ linkfile() { rename() { rx=$(link2rx "$1") - for f in *.md; do - [ "$(head -c 8 "$f")" = VimCrypt ] && continue - rename1 "$rx" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" - done + # Parallelize renaming + echo *.md | xargs -n 1 -P 8 "$0" rename1 "$rx" "$2" oldf="$(linkfile "$1").md" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2").md" } -- cgit v1.2.3 From e70107cb6a2f1fe17b848c43774b4e946749ea23 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 15 Aug 2021 11:26:14 +0200 Subject: update --- .vimrc | 2 +- bin/update_kernel_host | 8 ++++++++ bin/vm | 10 ++++++---- bin/wol | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) create mode 100755 bin/update_kernel_host diff --git a/.vimrc b/.vimrc index 68ae82a..fd1fbbc 100644 --- a/.vimrc +++ b/.vimrc @@ -25,7 +25,7 @@ let g:go_list_type = "quickfix" let g:go_fmt_command = "gopls" let g:go_gopls_gofumpt = 1 let g:go_metalinter_command = "golangci-lint" -autocmd FileType go syntax on +"autocmd FileType go syntax on autocmd FileType go nmap b (go-build) autocmd FileType go nmap i (go-info) autocmd FileType go nmap r (go-run) diff --git a/bin/update_kernel_host b/bin/update_kernel_host new file mode 100755 index 0000000..6180921 --- /dev/null +++ b/bin/update_kernel_host @@ -0,0 +1,8 @@ +#!/bin/sh -ex + +# After 'apk upgrade', update kernel and initrd on VM host + +sudo cp /boot/initramfs-virt /tmp +sudo chmod a+r /tmp/initramfs-virt +gunzip < /boot/vmlinuz-virt > /tmp/vmlinux +scp /tmp/initramfs-virt /tmp/vmlinux marc@m1:.vm/vm1/ diff --git a/bin/vm b/bin/vm index 732ba49..97e3521 100755 --- a/bin/vm +++ b/bin/vm @@ -212,11 +212,12 @@ ls() { } start() { - usage 'start [-af] name' 'Start a VM' && return - while getopts :af opt; do + usage 'start [-afs] name' 'Start a VM' && return + while getopts :afs opt; do case $opt in (a) a=1 ;; (f) f=1 ;; + (s) s=1 ;; (*) Opth=1 start "$1"; exit;; esac done @@ -227,8 +228,9 @@ start() { cd "$dir/$1" || die "start $1 failed" [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed" start_vm & sleep 2 - [ "$f" ] && finalize - [ "$a" ] && vm console "$1" + ! [ "$f" ] || finalize + ! [ "$a" ] || vm console "$1" + ! [ "$s" ] || exec ssh "$1" } start_vm() ( diff --git a/bin/wol b/bin/wol index 39bce0d..7975df9 100755 --- a/bin/wol +++ b/bin/wol @@ -1,6 +1,6 @@ -#!/bin/sh -x +#!/bin/sh ip_plex=192.168.1.90 mac_plex=b0:83:fe:61:a7:aa eval "mac=\$mac_$1 ip=\$ip_$1" wakeonlan "$mac" -ping -o "$ip" +while ! nc -zw 2 "$ip" 22; do printf .; sleep 2; done ssh "root@$ip" -- cgit v1.2.3 From e27491fbca20c2ecd76fcd84bd7007a546da5a75 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 16 Oct 2021 11:18:17 +0200 Subject: update --- .bashrc | 4 ++-- .profile | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index b50da1b..0a03cf8 100644 --- a/.bashrc +++ b/.bashrc @@ -50,7 +50,7 @@ alias view='vim -R' alias ldd='otool -L' alias ibrew='arch -x86_64 /usr/local/bin/brew' #alias op='xdg-open' -alias git='hub' +#alias git='hub' #alias go='go1.14.1' #alias go11='go1.11.13' #alias go12='go1.12.10' @@ -64,7 +64,7 @@ alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' alias rvi='sudo vim' alias rxt='sudo xt' alias rxvi='sudo xvi' -alias ww='vi ~/Wiki/HomePage' +alias ww='vi ~/Wiki/home_page.md' alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' #alias uc='systemctl --user' diff --git a/.profile b/.profile index bbf3c42..983092c 100644 --- a/.profile +++ b/.profile @@ -2,6 +2,11 @@ PATH=~/bin:/opt/homebrew/bin:$PATH:~/go/bin:~/.cargo/bin +if [ -z "$SSH_AUTH_SOCK" ] ; then + eval `ssh-agent -s` + ssh-add +fi + [ "${SHELL##*/}" = bash ] && . ~/.bashrc # Last action: auto start X11 when logged on first console -- cgit v1.2.3 From 7a36b02b5f3ae6560030c97513b8c15d9abd16d8 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 27 Nov 2021 11:04:34 +0100 Subject: update --- .bashrc | 11 +++++++++-- .profile | 3 ++- .vimrc | 3 ++- bin/update_hosts | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.bashrc b/.bashrc index 0a03cf8..c222116 100644 --- a/.bashrc +++ b/.bashrc @@ -45,8 +45,8 @@ export TERMINAL=xt #alias ls='ls --color=auto -v' alias ls='ls -GF' alias ll='ls -AlGFhv' -alias vi='vim' -alias view='vim -R' +alias vi='nvim' +alias view='nvim -R' alias ldd='otool -L' alias ibrew='arch -x86_64 /usr/local/bin/brew' #alias op='xdg-open' @@ -59,6 +59,7 @@ alias ibrew='arch -x86_64 /usr/local/bin/brew' alias gob='go build' alias goh='p go help' alias god='p go doc' +alias gol='GO111MODULE=off go' alias gtr='go test -v -run' alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' alias rvi='sudo vim' @@ -143,3 +144,9 @@ meteo() { # load Nix config files (aka auto-completion etc.) #export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + +PATH="/Users/marc/perl5/bin${PATH:+:${PATH}}"; export PATH; +PERL5LIB="/Users/marc/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; +PERL_LOCAL_LIB_ROOT="/Users/marc/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; +PERL_MB_OPT="--install_base \"/Users/marc/perl5\""; export PERL_MB_OPT; +PERL_MM_OPT="INSTALL_BASE=/Users/marc/perl5"; export PERL_MM_OPT; diff --git a/.profile b/.profile index 983092c..3e36ae3 100644 --- a/.profile +++ b/.profile @@ -1,6 +1,6 @@ # ~/.profile -PATH=~/bin:/opt/homebrew/bin:$PATH:~/go/bin:~/.cargo/bin +PATH=~/bin:/opt/homebrew/bin:/opt/homebrew/opt/ruby/bin:$PATH:~/go/bin:~/.cargo/bin if [ -z "$SSH_AUTH_SOCK" ] ; then eval `ssh-agent -s` @@ -15,3 +15,4 @@ fi #esac . "/opt/homebrew/etc/profile.d/bash_completion.sh" +eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)" diff --git a/.vimrc b/.vimrc index fd1fbbc..7f425b2 100644 --- a/.vimrc +++ b/.vimrc @@ -25,7 +25,7 @@ let g:go_list_type = "quickfix" let g:go_fmt_command = "gopls" let g:go_gopls_gofumpt = 1 let g:go_metalinter_command = "golangci-lint" -"autocmd FileType go syntax on +autocmd FileType go syntax on autocmd FileType go nmap b (go-build) autocmd FileType go nmap i (go-info) autocmd FileType go nmap r (go-run) @@ -79,3 +79,4 @@ noremap n :bn noremap :bd noremap o :!open & noremap :tag +noremap :Files diff --git a/bin/update_hosts b/bin/update_hosts index 8550ec3..40ec470 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -5,11 +5,11 @@ [ "$USER" = root ] || exec sudo "$0" "$@" -echo "Checking from https://github.com/StevenBlack/hosts:" -lsd=$(curl -s "https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1"| jq -r '.[0].commit.committer.date') +echo 'Checking from https://github.com/StevenBlack/hosts:' +lsd=$(curl -s 'https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1' | jq -r '.[0].commit.committer.date') echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" echo "last local update: $(date -r /etc/hosts)" -[ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo "Nothing to do" && exit +[ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo 'Nothing to do' && exit cd /etc cp -p hosts hosts.old -- cgit v1.2.3 From b9df08e08dc7eba9352bc68a4d1bb55c8d27529f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 28 Nov 2021 15:45:27 +0100 Subject: update --- .backupignore | 11 +++++++++++ .bashrc | 1 + bin/backup | 16 +++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 .backupignore diff --git a/.backupignore b/.backupignore new file mode 100644 index 0000000..8f44c0d --- /dev/null +++ b/.backupignore @@ -0,0 +1,11 @@ +.Trash/ +*[Cc]ache*/ +.bundle/ +.*[Cc]ache*/ +.cargo/ +.cpan* +.gem/ +.ipfs/ +.npm/ +.vm*/ +go/pkg diff --git a/.bashrc b/.bashrc index c222116..f4a4278 100644 --- a/.bashrc +++ b/.bashrc @@ -40,6 +40,7 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date export TERMINAL=xt +alias bu='backup -uvd bip:/home/backup/m1' #alias cl='cf xft:Mono:size=12' #alias cp='cp --reflink' #alias ls='ls --color=auto -v' diff --git a/bin/backup b/bin/backup index 72c69c3..adce78d 100755 --- a/bin/backup +++ b/bin/backup @@ -1,8 +1,6 @@ #!/bin/sh # Incremental backup using rsync(1). -[ "$USER" = root ] || exec sudo "$0" "$@" - backup() { date=$(date +%Y%m%d_%H%M%S) last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) @@ -12,25 +10,29 @@ backup() { (*) opt_link=;; esac - rsync -HSxa$optv --exclude-from=$ignore $opt_link / /boot "$dest/$date" + rsync -HSxa$optv --exclude-from=$ignore $opt_link $volumes "$dest/$date" } dest=/.history -ignore=/etc/backup/ignore +ignore=/etc/backupignore +volumes='/ /boot' -while getopts :d:i:nv opt; do +while getopts :d:i:nuv opt; do case $opt in (d) dest="$OPTARG" ;; (i) ignore="$OPTARG" ;; (n|v) optv="$opt$optv" ;; - (*) echo "Usage: $0 [-nv] [-d [host:]dir] [clean|diff]"; exit 1 ;; + (u) optu=1 volumes="$HOME" ignore="$HOME/.backupignore" ;; + (*) echo "Usage: $0 [-nuv] [-d [[user@]host:]dir] [clean|diff]"; exit 1 ;; esac done shift $((OPTIND - 1)) +[ "$optu" ] || [ "$USER" = root ] || exec sudo "$0" "$@" + [ "$1" ] && cmd=$1 && shift || cmd="" case $cmd in (""|save) backup ;; -(clean) exec backup-clean ${optv+-$optv} "$dest";; +(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";; (diff) exec diffdir "$@";; esac -- cgit v1.2.3 From 3816cb8729fce0206a4e01a2e7989d5462249e88 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 30 Nov 2021 15:42:42 +0100 Subject: update --- .bashrc | 2 +- .config/kitty/kitty.conf | 1516 ++++++++++++++++++++++++++++++++++++++++++++++ .vimrc | 2 +- 3 files changed, 1518 insertions(+), 2 deletions(-) create mode 100644 .config/kitty/kitty.conf diff --git a/.bashrc b/.bashrc index f4a4278..bec9d86 100644 --- a/.bashrc +++ b/.bashrc @@ -38,7 +38,7 @@ export GNUTERM='sixelgd enhanced truecolor font "arial,9"' # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' -export TERMINAL=xt +#export TERMINAL=xt alias bu='backup -uvd bip:/home/backup/m1' #alias cl='cf xft:Mono:size=12' diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf new file mode 100644 index 0000000..eca0bdf --- /dev/null +++ b/.config/kitty/kitty.conf @@ -0,0 +1,1516 @@ +# vim:fileencoding=utf-8:foldmethod=marker + +#: Fonts {{{ + +#: kitty has very powerful font management. You can configure +#: individual font faces and even specify special fonts for particular +#: characters. + +# font_family monospace +# bold_font auto +# italic_font auto +# bold_italic_font auto + +#: You can specify different fonts for the bold/italic/bold-italic +#: variants. To get a full list of supported fonts use the `kitty +#: list-fonts` command. By default they are derived automatically, by +#: the OSes font system. Setting them manually is useful for font +#: families that have many weight variants like Book, Medium, Thick, +#: etc. For example:: + +#: font_family Operator Mono Book +#: bold_font Operator Mono Medium +#: italic_font Operator Mono Book Italic +#: bold_italic_font Operator Mono Medium Italic + +# font_size 11.0 +font_size 14.0 + +#: Font size (in pts) + +# force_ltr no + +#: kitty does not support BIDI (bidirectional text), however, for RTL +#: scripts, words are automatically displayed in RTL. That is to say, +#: in an RTL script, the words "HELLO WORLD" display in kitty as +#: "WORLD HELLO", and if you try to select a substring of an RTL- +#: shaped string, you will get the character that would be there had +#: the the string been LTR. For example, assuming the Hebrew word +#: ירושלים, selecting the character that on the screen appears to be ם +#: actually writes into the selection buffer the character י. kitty's +#: default behavior is useful in conjunction with a filter to reverse +#: the word order, however, if you wish to manipulate RTL glyphs, it +#: can be very challenging to work with, so this option is provided to +#: turn it off. Furthermore, this option can be used with the command +#: line program GNU FriBidi +#: to get BIDI +#: support, because it will force kitty to always treat the text as +#: LTR, which FriBidi expects for terminals. + +# adjust_line_height 0 +# adjust_column_width 0 + +#: Change the size of each character cell kitty renders. You can use +#: either numbers, which are interpreted as pixels or percentages +#: (number followed by %), which are interpreted as percentages of the +#: unmodified values. You can use negative pixels or percentages less +#: than 100% to reduce sizes (but this might cause rendering +#: artifacts). + +# adjust_baseline 0 + +#: Adjust the vertical alignment of text (the height in the cell at +#: which text is positioned). You can use either numbers, which are +#: interpreted as pixels or a percentages (number followed by %), +#: which are interpreted as the percentage of the line height. A +#: positive value moves the baseline up, and a negative value moves +#: them down. The underline and strikethrough positions are adjusted +#: accordingly. + +# symbol_map U+E0A0-U+E0A3,U+E0C0-U+E0C7 PowerlineSymbols + +#: Map the specified unicode codepoints to a particular font. Useful +#: if you need special rendering for some symbols, such as for +#: Powerline. Avoids the need for patched fonts. Each unicode code +#: point is specified in the form U+. You +#: can specify multiple code points, separated by commas and ranges +#: separated by hyphens. symbol_map itself can be specified multiple +#: times. Syntax is:: + +#: symbol_map codepoints Font Family Name + +# disable_ligatures never + +#: Choose how you want to handle multi-character ligatures. The +#: default is to always render them. You can tell kitty to not render +#: them when the cursor is over them by using cursor to make editing +#: easier, or have kitty never render them at all by using always, if +#: you don't like them. The ligature strategy can be set per-window +#: either using the kitty remote control facility or by defining +#: shortcuts for it in kitty.conf, for example:: + +#: map alt+1 disable_ligatures_in active always +#: map alt+2 disable_ligatures_in all never +#: map alt+3 disable_ligatures_in tab cursor + +#: Note that this refers to programming ligatures, typically +#: implemented using the calt OpenType feature. For disabling general +#: ligatures, use the font_features setting. + +# font_features none + +#: Choose exactly which OpenType features to enable or disable. This +#: is useful as some fonts might have features worthwhile in a +#: terminal. For example, Fira Code Retina includes a discretionary +#: feature, zero, which in that font changes the appearance of the +#: zero (0), to make it more easily distinguishable from Ø. Fira Code +#: Retina also includes other discretionary features known as +#: Stylistic Sets which have the tags ss01 through ss20. + +#: For the exact syntax to use for individual features, see the +#: Harfbuzz documentation . + +#: Note that this code is indexed by PostScript name, and not the font +#: family. This allows you to define very precise feature settings; +#: e.g. you can disable a feature in the italic font but not in the +#: regular font. + +#: On Linux, these are read from the FontConfig database first and +#: then this, setting is applied, so they can be configured in a +#: single, central place. + +#: To get the PostScript name for a font, use kitty + list-fonts +#: --psnames: + +#: .. code-block:: sh + +#: $ kitty + list-fonts --psnames | grep Fira +#: Fira Code +#: Fira Code Bold (FiraCode-Bold) +#: Fira Code Light (FiraCode-Light) +#: Fira Code Medium (FiraCode-Medium) +#: Fira Code Regular (FiraCode-Regular) +#: Fira Code Retina (FiraCode-Retina) + +#: The part in brackets is the PostScript name. + +#: Enable alternate zero and oldstyle numerals:: + +#: font_features FiraCode-Retina +zero +onum + +#: Enable only alternate zero:: + +#: font_features FiraCode-Retina +zero + +#: Disable the normal ligatures, but keep the calt feature which (in +#: this font) breaks up monotony:: + +#: font_features TT2020StyleB-Regular -liga +calt + +#: In conjunction with force_ltr, you may want to disable Arabic +#: shaping entirely, and only look at their isolated forms if they +#: show up in a document. You can do this with e.g.:: + +#: font_features UnifontMedium +isol -medi -fina -init + +# box_drawing_scale 0.001, 1, 1.5, 2 + +#: Change the sizes of the lines used for the box drawing unicode +#: characters These values are in pts. They will be scaled by the +#: monitor DPI to arrive at a pixel value. There must be four values +#: corresponding to thin, normal, thick, and very thick lines. + +#: }}} + +#: Cursor customization {{{ + +# cursor #cccccc +cursor #ff0000 + +#: Default cursor color + +# cursor_text_color #111111 + +#: Choose the color of text under the cursor. If you want it rendered +#: with the background color of the cell underneath instead, use the +#: special keyword: background + +# cursor_shape block + +#: The cursor shape can be one of (block, beam, underline). Note that +#: when reloading the config this will be changed only if the cursor +#: shape has not been set by the program running in the terminal. + +# cursor_beam_thickness 1.5 + +#: Defines the thickness of the beam cursor (in pts) + +# cursor_underline_thickness 2.0 + +#: Defines the thickness of the underline cursor (in pts) + +# cursor_blink_interval -1 +cursor_blink_interval 0 + +#: The interval (in seconds) at which to blink the cursor. Set to zero +#: to disable blinking. Negative values mean use system default. Note +#: that numbers smaller than repaint_delay will be limited to +#: repaint_delay. + +# cursor_stop_blinking_after 15.0 + +#: Stop blinking cursor after the specified number of seconds of +#: keyboard inactivity. Set to zero to never stop blinking. + +#: }}} + +#: Scrollback {{{ + +# scrollback_lines 2000 + +#: Number of lines of history to keep in memory for scrolling back. +#: Memory is allocated on demand. Negative numbers are (effectively) +#: infinite scrollback. Note that using very large scrollback is not +#: recommended as it can slow down performance of the terminal and +#: also use large amounts of RAM. Instead, consider using +#: scrollback_pager_history_size. Note that on config reload if this +#: is changed it will only affect newly created windows, not existing +#: ones. + +# scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER + +#: Program with which to view scrollback in a new window. The +#: scrollback buffer is passed as STDIN to this program. If you change +#: it, make sure the program you use can handle ANSI escape sequences +#: for colors and text formatting. INPUT_LINE_NUMBER in the command +#: line above will be replaced by an integer representing which line +#: should be at the top of the screen. Similarly CURSOR_LINE and +#: CURSOR_COLUMN will be replaced by the current cursor position. + +# scrollback_pager_history_size 0 + +#: Separate scrollback history size, used only for browsing the +#: scrollback buffer (in MB). This separate buffer is not available +#: for interactive scrolling but will be piped to the pager program +#: when viewing scrollback buffer in a separate window. The current +#: implementation stores the data in UTF-8, so approximatively 10000 +#: lines per megabyte at 100 chars per line, for pure ASCII text, +#: unformatted text. A value of zero or less disables this feature. +#: The maximum allowed size is 4GB. Note that on config reload if this +#: is changed it will only affect newly created windows, not existing +#: ones. + +# scrollback_fill_enlarged_window no + +#: Fill new space with lines from the scrollback buffer after +#: enlarging a window. + +# wheel_scroll_multiplier 5.0 + +#: Modify the amount scrolled by the mouse wheel. Note this is only +#: used for low precision scrolling devices, not for high precision +#: scrolling on platforms such as macOS and Wayland. Use negative +#: numbers to change scroll direction. + +# touch_scroll_multiplier 1.0 + +#: Modify the amount scrolled by a touchpad. Note this is only used +#: for high precision scrolling devices on platforms such as macOS and +#: Wayland. Use negative numbers to change scroll direction. + +#: }}} + +#: Mouse {{{ + +# mouse_hide_wait 3.0 + +#: Hide mouse cursor after the specified number of seconds of the +#: mouse not being used. Set to zero to disable mouse cursor hiding. +#: Set to a negative value to hide the mouse cursor immediately when +#: typing text. Disabled by default on macOS as getting it to work +#: robustly with the ever-changing sea of bugs that is Cocoa is too +#: much effort. + +# url_color #0087bd +# url_style curly + +#: The color and style for highlighting URLs on mouse-over. url_style +#: can be one of: none, single, double, curly + +# open_url_with default + +#: The program with which to open URLs that are clicked on. The +#: special value default means to use the operating system's default +#: URL handler. + +# url_prefixes http https file ftp gemini irc gopher mailto news git + +#: The set of URL prefixes to look for when detecting a URL under the +#: mouse cursor. + +# detect_urls yes + +#: Detect URLs under the mouse. Detected URLs are highlighted with an +#: underline and the mouse cursor becomes a hand over them. Even if +#: this option is disabled, URLs are still clickable. + +# url_excluded_characters + +#: Additional characters to be disallowed from URLs, when detecting +#: URLs under the mouse cursor. By default, all characters legal in +#: URLs are allowed. + +# copy_on_select no +copy_on_select yes + +#: Copy to clipboard or a private buffer on select. With this set to +#: clipboard, simply selecting text with the mouse will cause the text +#: to be copied to clipboard. Useful on platforms such as macOS that +#: do not have the concept of primary selections. You can instead +#: specify a name such as a1 to copy to a private kitty buffer +#: instead. Map a shortcut with the paste_from_buffer action to paste +#: from this private buffer. For example:: + +#: map cmd+shift+v paste_from_buffer a1 + +#: Note that copying to the clipboard is a security risk, as all +#: programs, including websites open in your browser can read the +#: contents of the system clipboard. + +# strip_trailing_spaces never + +#: Remove spaces at the end of lines when copying to clipboard. A +#: value of smart will do it when using normal selections, but not +#: rectangle selections. always will always do it. + +# select_by_word_characters @-./_~?&=%+# + +#: Characters considered part of a word when double clicking. In +#: addition to these characters any character that is marked as an +#: alphanumeric character in the unicode database will be matched. + +# click_interval -1.0 + +#: The interval between successive clicks to detect double/triple +#: clicks (in seconds). Negative numbers will use the system default +#: instead, if available, or fallback to 0.5. + +# focus_follows_mouse no +focus_follows_mouse yes + +#: Set the active window to the window under the mouse when moving the +#: mouse around + +# pointer_shape_when_grabbed arrow + +#: The shape of the mouse pointer when the program running in the +#: terminal grabs the mouse. Valid values are: arrow, beam and hand + +# default_pointer_shape beam + +#: The default shape of the mouse pointer. Valid values are: arrow, +#: beam and hand + +# pointer_shape_when_dragging beam + +#: The default shape of the mouse pointer when dragging across text. +#: Valid values are: arrow, beam and hand + +#: Mouse actions {{{ + +#: Mouse buttons can be remapped to perform arbitrary actions. The +#: syntax for doing so is: + +#: .. code-block:: none + +#: mouse_map button-name event-type modes action + +#: Where ``button-name`` is one of ``left``, ``middle``, ``right`` or +#: ``b1 ... b8`` with added keyboard modifiers, for example: +#: ``ctrl+shift+left`` refers to holding the ctrl+shift keys while +#: clicking with the left mouse button. The number ``b1 ... b8`` can +#: be used to refer to upto eight buttons on a mouse. + +#: ``event-type`` is one ``press``, ``release``, ``doublepress``, +#: ``triplepress``, ``click`` and ``doubleclick``. ``modes`` +#: indicates whether the action is performed when the mouse is grabbed +#: by the program running in the terminal, or not. It can have one or +#: more or the values, ``grabbed,ungrabbed``. ``grabbed`` refers to +#: when the program running in the terminal has requested mouse +#: events. Note that the click and double click events have a delay of +#: click_interval to disambiguate from double and triple presses. + +#: You can run kitty with the kitty --debug-input command line option +#: to see mouse events. See the builtin actions below to get a sense +#: of what is possible. + +#: If you want to unmap an action map it to ``no-op``. For example, to +#: disable opening of URLs with a plain click:: + +#: mouse_map left click ungrabbed no-op + +#: .. note:: +#: Once a selection is started, releasing the button that started it will +#: automatically end it and no release event will be dispatched. + +# clear_all_mouse_actions no + +#: You can have kitty remove all mouse actions seen up to this point. +#: Useful, for instance, to remove the default mouse actions. + +# mouse_map left click ungrabbed mouse_click_url_or_select +# mouse_map shift+left click grabbed,ungrabbed mouse_click_url_or_select +# mouse_map ctrl+shift+left release grabbed,ungrabbed mouse_click_url + +#: Variant with ctrl+shift is present because the simple click based +#: version has an unavoidable delay of click_interval, to disambiguate +#: clicks from double clicks. + +# mouse_map ctrl+shift+left press grabbed discard_event + +#: Prevent this press event from being sent to the program that has +#: grabbed the mouse, as the corresponding release event is used to +#: open a URL. + +# mouse_map middle release ungrabbed paste_from_selection +# mouse_map left press ungrabbed mouse_selection normal +# mouse_map ctrl+alt+left press ungrabbed mouse_selection rectangle +# mouse_map left doublepress ungrabbed mouse_selection word +# mouse_map left triplepress ungrabbed mouse_selection line + +#: Select the entire line + +# mouse_map ctrl+alt+left triplepress ungrabbed mouse_selection line_from_point + +#: Select from the clicked point to the end of the line + +# mouse_map right press ungrabbed mouse_selection extend + +#: If you want only the end of the selection to be moved instead of +#: the nearest boundary, use move-end instead of extend. + +# mouse_map shift+middle release ungrabbed,grabbed paste_selection +# mouse_map shift+left press ungrabbed,grabbed mouse_selection normal +# mouse_map shift+ctrl+alt+left press ungrabbed,grabbed mouse_selection rectangle +# mouse_map shift+left doublepress ungrabbed,grabbed mouse_selection word +# mouse_map shift+left triplepress ungrabbed,grabbed mouse_selection line + +#: Select the entire line + +# mouse_map shift+ctrl+alt+left triplepress ungrabbed,grabbed mouse_selection line_from_point + +#: Select from the clicked point to the end of the line + +# mouse_map shift+right press ungrabbed,grabbed mouse_selection extend +#: }}} + +#: }}} + +#: Performance tuning {{{ + +# repaint_delay 10 + +#: Delay (in milliseconds) between screen updates. Decreasing it, +#: increases frames-per-second (FPS) at the cost of more CPU usage. +#: The default value yields ~100 FPS which is more than sufficient for +#: most uses. Note that to actually achieve 100 FPS you have to either +#: set sync_to_monitor to no or use a monitor with a high refresh +#: rate. Also, to minimize latency when there is pending input to be +#: processed, repaint_delay is ignored. + +# input_delay 3 + +#: Delay (in milliseconds) before input from the program running in +#: the terminal is processed. Note that decreasing it will increase +#: responsiveness, but also increase CPU usage and might cause flicker +#: in full screen programs that redraw the entire screen on each loop, +#: because kitty is so fast that partial screen updates will be drawn. + +# sync_to_monitor yes + +#: Sync screen updates to the refresh rate of the monitor. This +#: prevents tearing (https://en.wikipedia.org/wiki/Screen_tearing) +#: when scrolling. However, it limits the rendering speed to the +#: refresh rate of your monitor. With a very high speed mouse/high +#: keyboard repeat rate, you may notice some slight input latency. If +#: so, set this to no. + +#: }}} + +#: Terminal bell {{{ + +# enable_audio_bell yes + +#: Enable/disable the audio bell. Useful in environments that require +#: silence. + +# visual_bell_duration 0.0 + +#: Visual bell duration. Flash the screen when a bell occurs for the +#: specified number of seconds. Set to zero to disable. + +# window_alert_on_bell yes + +#: Request window attention on bell. Makes the dock icon bounce on +#: macOS or the taskbar flash on linux. + +# bell_on_tab yes + +#: Show a bell symbol on the tab if a bell occurs in one of the +#: windows in the tab and the window is not the currently focused +#: window + +# command_on_bell none + +#: Program to run when a bell occurs. The environment variable +#: KITTY_CHILD_CMDLINE can be used to get the program running in the +#: window in which the bell occurred. + +#: }}} + +#: Window layout {{{ + +# remember_window_size yes +# initial_window_width 640 +# initial_window_height 400 + +#: If enabled, the window size will be remembered so that new +#: instances of kitty will have the same size as the previous +#: instance. If disabled, the window will initially have size +#: configured by initial_window_width/height, in pixels. You can use a +#: suffix of "c" on the width/height values to have them interpreted +#: as number of cells instead of pixels. + +# enabled_layouts * +enabled_layouts tall,fat,grid + +#: The enabled window layouts. A comma separated list of layout names. +#: The special value all means all layouts. The first listed layout +#: will be used as the startup layout. Default configuration is all +#: layouts in alphabetical order. For a list of available layouts, see +#: the https://sw.kovidgoyal.net/kitty/overview/#layouts. + +# window_resize_step_cells 2 +# window_resize_step_lines 2 + +#: The step size (in units of cell width/cell height) to use when +#: resizing windows. The cells value is used for horizontal resizing +#: and the lines value for vertical resizing. + +# window_border_width 0.5pt + +#: The width of window borders. Can be either in pixels (px) or pts +#: (pt). Values in pts will be rounded to the nearest number of pixels +#: based on screen resolution. If not specified the unit is assumed to +#: be pts. Note that borders are displayed only when more than one +#: window is visible. They are meant to separate multiple windows. + +# draw_minimal_borders yes + +#: Draw only the minimum borders needed. This means that only the +#: minimum needed borders for inactive windows are drawn. That is only +#: the borders that separate the inactive window from a neighbor. Note +#: that setting a non-zero window margin overrides this and causes all +#: borders to be drawn. + +# window_margin_width 0 + +#: The window margin (in pts) (blank area outside the border). A +#: single value sets all four sides. Two values set the vertical and +#: horizontal sides. Three values set top, horizontal and bottom. Four +#: values set top, right, bottom and left. + +# single_window_margin_width -1 + +#: The window margin (in pts) to use when only a single window is +#: visible. Negative values will cause the value of +#: window_margin_width to be used instead. A single value sets all +#: four sides. Two values set the vertical and horizontal sides. Three +#: values set top, horizontal and bottom. Four values set top, right, +#: bottom and left. + +# window_padding_width 0 + +#: The window padding (in pts) (blank area between the text and the +#: window border). A single value sets all four sides. Two values set +#: the vertical and horizontal sides. Three values set top, horizontal +#: and bottom. Four values set top, right, bottom and left. + +# placement_strategy center + +#: When the window size is not an exact multiple of the cell size, the +#: cell area of the terminal window will have some extra padding on +#: the sides. You can control how that padding is distributed with +#: this option. Using a value of center means the cell area will be +#: placed centrally. A value of top-left means the padding will be on +#: only the bottom and right edges. + +# active_border_color #00ff00 + +#: The color for the border of the active window. Set this to none to +#: not draw borders around the active window. + +# inactive_border_color #cccccc + +#: The color for the border of inactive windows + +# bell_border_color #ff5a00 + +#: The color for the border of inactive windows in which a bell has +#: occurred + +# inactive_text_alpha 1.0 + +#: Fade the text in inactive windows by the specified amount (a number +#: between zero and one, with zero being fully faded). + +# hide_window_decorations no + +#: Hide the window decorations (title-bar and window borders) with +#: yes. On macOS, titlebar-only can be used to only hide the titlebar. +#: Whether this works and exactly what effect it has depends on the +#: window manager/operating system. Note that the effects of changing +#: this setting when reloading config are undefined. + +# resize_debounce_time 0.1 + +#: The time (in seconds) to wait before redrawing the screen when a +#: resize event is received. On platforms such as macOS, where the +#: operating system sends events corresponding to the start and end of +#: a resize, this number is ignored. + +# resize_draw_strategy static + +#: Choose how kitty draws a window while a resize is in progress. A +#: value of static means draw the current window contents, mostly +#: unchanged. A value of scale means draw the current window contents +#: scaled. A value of blank means draw a blank window. A value of size +#: means show the window size in cells. + +# resize_in_steps no + +#: Resize the OS window in steps as large as the cells, instead of +#: with the usual pixel accuracy. Combined with an +#: initial_window_width and initial_window_height in number of cells, +#: this option can be used to keep the margins as small as possible +#: when resizing the OS window. Note that this does not currently work +#: on Wayland. + +# confirm_os_window_close 0 + +#: Ask for confirmation when closing an OS window or a tab that has at +#: least this number of kitty windows in it. A value of zero disables +#: confirmation. This confirmation also applies to requests to quit +#: the entire application (all OS windows, via the quit action). + +#: }}} + +#: Tab bar {{{ + +# tab_bar_edge bottom + +#: Which edge to show the tab bar on, top or bottom + +# tab_bar_margin_width 0.0 + +#: The margin to the left and right of the tab bar (in pts) + +# tab_bar_margin_height 0.0 0.0 + +#: The margin above and below the tab bar (in pts). The first number +#: is the margin between the edge of the OS Window and the tab bar and +#: the second number is the margin between the tab bar and the +#: contents of the current tab. + +# tab_bar_style fade + +#: The tab bar style, can be one of: + +#: fade +#: Each tab's edges fade into the background color (see tab_fade) +#: slant +#: Tabs look like the tabs in a physical file +#: separator +#: Tabs are separated by a configurable separator (see tab_separator) +#: powerline +#: Tabs are shown as a continuous line with "fancy" separators (see tab_powerline_style) +#: hidden +#: The tab bar is hidden. If you use this, you might want to create a mapping +#: for the https://sw.kovidgoyal.net/kitty/actions/#select-tab action which presents you with a list +#: of tabs and allows for easy switching to a tab. + +# tab_bar_min_tabs 2 + +#: The minimum number of tabs that must exist before the tab bar is +#: shown + +# tab_switch_strategy previous + +#: The algorithm to use when switching to a tab when the current tab +#: is closed. The default of previous will switch to the last used +#: tab. A value of left will switch to the tab to the left of the +#: closed tab. A value of right will switch to the tab to the right of +#: the closed tab. A value of last will switch to the right-most tab. + +# tab_fade 0.25 0.5 0.75 1 + +#: Control how each tab fades into the background when using fade for +#: the tab_bar_style. Each number is an alpha (between zero and one) +#: that controls how much the corresponding cell fades into the +#: background, with zero being no fade and one being full fade. You +#: can change the number of cells used by adding/removing entries to +#: this list. + +# tab_separator " ┇" + +#: The separator between tabs in the tab bar when using separator as +#: the tab_bar_style. + +# tab_powerline_style angled + +#: The powerline separator style between tabs in the tab bar when +#: using powerline as the tab_bar_style, can be one of: angled, +#: slanted, or round. + +# tab_activity_symbol none + +#: Some text or a unicode symbol to show on the tab if a window in the +#: tab that does not have focus has some activity. If you want to use +#: leading or trailing spaces surround the text with quotes. + +# tab_title_template "{title}" + +#: A template to render the tab title. The default just renders the +#: title. If you wish to include the tab-index as well, use something +#: like: {index}: {title}. Useful if you have shortcuts mapped for +#: goto_tab N. If you prefer to see the index as a superscript, use +#: {sup.index}. In addition you can use {layout_name} for the current +#: layout name, {num_windows} for the number of windows in the tab and +#: {num_window_groups} for the number of window groups (not counting +#: overlay windows) in the tab. Note that formatting is done by +#: Python's string formatting machinery, so you can use, for instance, +#: {layout_name[:2].upper()} to show only the first two letters of the +#: layout name, upper-cased. If you want to style the text, you can +#: use styling directives, for example: +#: {fmt.fg.red}red{fmt.fg.default}normal{fmt.bg._00FF00}green +#: bg{fmt.bg.normal}. Similarly, for bold and italic: +#: {fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}. + +# active_tab_title_template none + +#: Template to use for active tabs, if not specified falls back to +#: tab_title_template. + +# active_tab_foreground #000 +# active_tab_background #eee +# active_tab_font_style bold-italic +# inactive_tab_foreground #444 +# inactive_tab_background #999 +# inactive_tab_font_style normal + +#: Tab bar colors and styles + +# tab_bar_background none + +#: Background color for the tab bar. Defaults to using the terminal +#: background color. + +#: }}} + +#: Color scheme {{{ + +# foreground #dddddd +# background #000000 + +#: The foreground and background colors + +# background_opacity 1.0 + +#: The opacity of the background. A number between 0 and 1, where 1 is +#: opaque and 0 is fully transparent. This will only work if +#: supported by the OS (for instance, when using a compositor under +#: X11). Note that it only sets the background color's opacity in +#: cells that have the same background color as the default terminal +#: background. This is so that things like the status bar in vim, +#: powerline prompts, etc. still look good. But it means that if you +#: use a color theme with a background color in your editor, it will +#: not be rendered as transparent. Instead you should change the +#: default background color in your kitty config and not use a +#: background color in the editor color scheme. Or use the escape +#: codes to set the terminals default colors in a shell script to +#: launch your editor. Be aware that using a value less than 1.0 is a +#: (possibly significant) performance hit. If you want to dynamically +#: change transparency of windows set dynamic_background_opacity to +#: yes (this is off by default as it has a performance cost). Changing +#: this setting when reloading the config will only work if +#: dynamic_background_opacity was enabled in the original config. + +# background_image none + +#: Path to a background image. Must be in PNG format. + +# background_image_layout tiled + +#: Whether to tile or scale the background image. + +# background_image_linear no + +#: When background image is scaled, whether linear interpolation +#: should be used. + +# dynamic_background_opacity no + +#: Allow changing of the background_opacity dynamically, using either +#: keyboard shortcuts (increase_background_opacity and +#: decrease_background_opacity) or the remote control facility. +#: Changing this setting by reloading the config is not supported. + +# background_tint 0.0 + +#: How much to tint the background image by the background color. The +#: tint is applied only under the text area, not margin/borders. Makes +#: it easier to read the text. Tinting is done using the current +#: background color for each window. This setting applies only if +#: background_opacity is set and transparent windows are supported or +#: background_image is set. + +# dim_opacity 0.75 + +#: How much to dim text that has the DIM/FAINT attribute set. One +#: means no dimming and zero means fully dimmed (i.e. invisible). + +# selection_foreground #000000 + +#: The foreground for text selected with the mouse. A value of none +#: means to leave the color unchanged. + +# selection_background #fffacd + +#: The background for text selected with the mouse. + +#: The color table {{{ + +#: The 256 terminal colors. There are 8 basic colors, each color has a +#: dull and bright version, for the first 16 colors. You can set the +#: remaining 240 colors as color16 to color255. + +# color0 #000000 +# color8 #767676 + +#: black + +# color1 #cc0403 +# color9 #f2201f + +#: red + +# color2 #19cb00 +# color10 #23fd00 + +#: green + +# color3 #cecb00 +# color11 #fffd00 + +#: yellow + +# color4 #0d73cc +# color12 #1a8fff + +#: blue + +# color5 #cb1ed1 +# color13 #fd28ff + +#: magenta + +# color6 #0dcdcd +# color14 #14ffff + +#: cyan + +# color7 #dddddd +# color15 #ffffff + +#: white + +# mark1_foreground black + +#: Color for marks of type 1 + +# mark1_background #98d3cb + +#: Color for marks of type 1 (light steel blue) + +# mark2_foreground black + +#: Color for marks of type 2 + +# mark2_background #f2dcd3 + +#: Color for marks of type 1 (beige) + +# mark3_foreground black + +#: Color for marks of type 3 + +# mark3_background #f274bc + +#: Color for marks of type 3 (violet) + +#: }}} + +#: }}} + +#: Advanced {{{ + +# shell . + +#: The shell program to execute. The default value of . means to use +#: whatever shell is set as the default shell for the current user. +#: Note that on macOS if you change this, you might need to add +#: --login and --interactive to ensure that the shell starts in +#: interactive mode and reads its startup rc files. + +# editor . + +#: The terminal editor (such as ``vim`` or ``nano``) to use when +#: editing the kitty config file or similar tasks. + +#: The default value of . means to use the environment variables +#: VISUAL and EDITOR in that order. If these variables aren't set, +#: kitty will run your shell (``$SHELL -l -i -c env``) to see if your +#: shell config files set VISUAL or EDITOR. If that doesn't work, +#: kitty will cycle through various known editors (``vim``, ``emacs``, +#: etc) and take the first one that exists on your system. + +# close_on_child_death no + +#: Close the window when the child process (shell) exits. If no (the +#: default), the terminal will remain open when the child exits as +#: long as there are still processes outputting to the terminal (for +#: example disowned or backgrounded processes). If yes, the window +#: will close as soon as the child process exits. Note that setting it +#: to yes means that any background processes still using the terminal +#: can fail silently because their stdout/stderr/stdin no longer work. + +# allow_remote_control no +allow_remote_control yes + +#: Allow other programs to control kitty. If you turn this on other +#: programs can control all aspects of kitty, including sending text +#: to kitty windows, opening new windows, closing windows, reading the +#: content of windows, etc. Note that this even works over ssh +#: connections. You can chose to either allow any program running +#: within kitty to control it, with yes or only programs that connect +#: to the socket specified with the kitty --listen-on command line +#: option, if you use the value socket-only. The latter is useful if +#: you want to prevent programs running on a remote computer over ssh +#: from controlling kitty. Reloading the config will not affect this +#: setting. + +# listen_on none + +#: Tell kitty to listen to the specified unix/tcp socket for remote +#: control connections. Note that this will apply to all kitty +#: instances. It can be overridden by the kitty --listen-on command +#: line flag. This option accepts only UNIX sockets, such as +#: unix:${TEMP}/mykitty or (on Linux) unix:@mykitty. Environment +#: variables are expanded. If {kitty_pid} is present then it is +#: replaced by the PID of the kitty process, otherwise the PID of the +#: kitty process is appended to the value, with a hyphen. This option +#: is ignored unless you also set allow_remote_control to enable +#: remote control. See the help for kitty --listen-on for more +#: details. Changing this option by reloading the config is not +#: supported. + +# env + +#: Specify environment variables to set in all child processes. Note +#: that environment variables are expanded recursively, so if you +#: use:: + +#: env MYVAR1=a +#: env MYVAR2=${MYVAR1}/${HOME}/b + +#: The value of MYVAR2 will be a//b. + +# update_check_interval 24 + +#: Periodically check if an update to kitty is available. If an update +#: is found a system notification is displayed informing you of the +#: available update. The default is to check every 24 hrs, set to zero +#: to disable. Changing this option by reloading the config is not +#: supported. + +# startup_session none + +#: Path to a session file to use for all kitty instances. Can be +#: overridden by using the kitty --session command line option for +#: individual instances. See +#: https://sw.kovidgoyal.net/kitty/overview/#startup-sessions in the +#: kitty documentation for details. Note that relative paths are +#: interpreted with respect to the kitty config directory. Environment +#: variables in the path are expanded. Changing this option by +#: reloading the config is not supported. + +# clipboard_control write-clipboard write-primary + +#: Allow programs running in kitty to read and write from the +#: clipboard. You can control exactly which actions are allowed. The +#: set of possible actions is: write-clipboard read-clipboard write- +#: primary read-primary. The default is to allow writing to the +#: clipboard and primary selection. Note that enabling the read +#: functionality is a security risk as it means that any program, even +#: one running on a remote server via SSH can read your clipboard. See +#: also clipboard_max_size. + +# clipboard_max_size 64 + +#: The maximum size (in MB) of data from programs running in kitty +#: that will be stored for writing to the system clipboard. See also +#: clipboard_control. A value of zero means no size limit is applied. + +# allow_hyperlinks yes + +#: Process hyperlink (OSC 8) escape sequences. If disabled OSC 8 +#: escape sequences are ignored. Otherwise they become clickable +#: links, that you can click by holding down ctrl+shift and clicking +#: with the mouse. The special value of ``ask`` means that kitty will +#: ask before opening the link. + +# term xterm-kitty + +#: The value of the TERM environment variable to set. Changing this +#: can break many terminal programs, only change it if you know what +#: you are doing, not because you read some advice on Stack Overflow +#: to change it. The TERM variable is used by various programs to get +#: information about the capabilities and behavior of the terminal. If +#: you change it, depending on what programs you run, and how +#: different the terminal you are changing it to is, various things +#: from key-presses, to colors, to various advanced features may not +#: work. Changing this option by reloading the config will only affect +#: newly created windows. + +#: }}} + +#: OS specific tweaks {{{ + +# wayland_titlebar_color system + +#: Change the color of the kitty window's titlebar on Wayland systems +#: with client side window decorations such as GNOME. A value of +#: system means to use the default system color, a value of background +#: means to use the background color of the currently active window +#: and finally you can use an arbitrary color, such as #12af59 or red. + +# macos_titlebar_color system + +#: Change the color of the kitty window's titlebar on macOS. A value +#: of system means to use the default system color, a value of +#: background means to use the background color of the currently +#: active window and finally you can use an arbitrary color, such as +#: #12af59 or red. WARNING: This option works by using a hack, as +#: there is no proper Cocoa API for it. It sets the background color +#: of the entire window and makes the titlebar transparent. As such it +#: is incompatible with background_opacity. If you want to use both, +#: you are probably better off just hiding the titlebar with +#: hide_window_decorations. + +# macos_option_as_alt no + +#: Use the option key as an alt key. With this set to no, kitty will +#: use the macOS native Option+Key = unicode character behavior. This +#: will break any Alt+key keyboard shortcuts in your terminal +#: programs, but you can use the macOS unicode input technique. You +#: can use the values: left, right, or both to use only the left, +#: right or both Option keys as Alt, instead. Changing this setting by +#: reloading the config is not supported. + +# macos_hide_from_tasks no + +#: Hide the kitty window from running tasks (⌘+Tab) on macOS. Changing +#: this setting by reloading the config is not supported. + +# macos_quit_when_last_window_closed no + +#: Have kitty quit when all the top-level windows are closed. By +#: default, kitty will stay running, even with no open windows, as is +#: the expected behavior on macOS. + +# macos_window_resizable yes + +#: Disable this if you want kitty top-level (OS) windows to not be +#: resizable on macOS. Changing this setting by reloading the config +#: will only affect newly created windows. + +# macos_thicken_font 0 + +#: Draw an extra border around the font with the given width, to +#: increase legibility at small font sizes. For example, a value of +#: 0.75 will result in rendering that looks similar to sub-pixel +#: antialiasing at common font sizes. + +# macos_traditional_fullscreen no + +#: Use the traditional full-screen transition, that is faster, but +#: less pretty. + +# macos_show_window_title_in all + +#: Show or hide the window title in the macOS window or menu-bar. A +#: value of window will show the title of the currently active window +#: at the top of the macOS window. A value of menubar will show the +#: title of the currently active window in the macOS menu-bar, making +#: use of otherwise wasted space. all will show the title everywhere +#: and none hides the title in the window and the menu-bar. + +# macos_custom_beam_cursor no + +#: Enable/disable custom mouse cursor for macOS that is easier to see +#: on both light and dark backgrounds. WARNING: this might make your +#: mouse cursor invisible on dual GPU machines. Changing this setting +#: by reloading the config is not supported. + +# linux_display_server auto + +#: Choose between Wayland and X11 backends. By default, an appropriate +#: backend based on the system state is chosen automatically. Set it +#: to x11 or wayland to force the choice. Changing this setting by +#: reloading the config is not supported. + +#: }}} + +#: Keyboard shortcuts {{{ + +#: Keys are identified simply by their lowercase unicode characters. +#: For example: ``a`` for the A key, ``[`` for the left square bracket +#: key, etc. For functional keys, such as ``Enter or Escape`` the +#: names are present at https://sw.kovidgoyal.net/kitty/keyboard- +#: protocol/#functional-key-definitions. For a list of modifier names, +#: see: GLFW mods + +#: On Linux you can also use XKB key names to bind keys that are not +#: supported by GLFW. See XKB keys +#: for a list of key names. The name to use is the part +#: after the XKB_KEY_ prefix. Note that you can only use an XKB key +#: name for keys that are not known as GLFW keys. + +#: Finally, you can use raw system key codes to map keys, again only +#: for keys that are not known as GLFW keys. To see the system key +#: code for a key, start kitty with the kitty --debug-input option. +#: Then kitty will output some debug text for every key event. In that +#: text look for ``native_code`` the value of that becomes the key +#: name in the shortcut. For example: + +#: .. code-block:: none + +#: on_key_input: glfw key: 65 native_code: 0x61 action: PRESS mods: 0x0 text: 'a' + +#: Here, the key name for the A key is 0x61 and you can use it with:: + +#: map ctrl+0x61 something + +#: to map ctrl+a to something. + +#: You can use the special action no_op to unmap a keyboard shortcut +#: that is assigned in the default configuration:: + +#: map kitty_mod+space no_op + +#: You can combine multiple actions to be triggered by a single +#: shortcut, using the syntax below:: + +#: map key combine action1 action2 action3 ... + +#: For example:: + +#: map kitty_mod+e combine : new_window : next_layout + +#: this will create a new window and switch to the next available +#: layout + +#: You can use multi-key shortcuts using the syntax shown below:: + +#: map key1>key2>key3 action + +#: For example:: + +#: map ctrl+f>2 set_font_size 20 + +#: The full list of actions that can be mapped to key presses is +#: available here . + +# kitty_mod ctrl+shift + +#: The value of kitty_mod is used as the modifier for all default +#: shortcuts, you can change it in your kitty.conf to change the +#: modifiers for all the default shortcuts. + +# clear_all_shortcuts no + +#: You can have kitty remove all shortcut definition seen up to this +#: point. Useful, for instance, to remove the default shortcuts. + +# kitten_alias hints hints --hints-offset=0 + +#: You can create aliases for kitten names, this allows overriding the +#: defaults for kitten options and can also be used to shorten +#: repeated mappings of the same kitten with a specific group of +#: options. For example, the above alias changes the default value of +#: kitty +kitten hints --hints-offset to zero for all mappings, +#: including the builtin ones. + +#: Clipboard {{{ + +# map kitty_mod+c copy_to_clipboard + +#: There is also a copy_or_interrupt action that can be optionally +#: mapped to Ctrl+c. It will copy only if there is a selection and +#: send an interrupt otherwise. Similarly, copy_and_clear_or_interrupt +#: will copy and clear the selection or send an interrupt if there is +#: no selection. + +# map kitty_mod+v paste_from_clipboard +# map kitty_mod+s paste_from_selection +# map kitty_mod+o pass_selection_to_program + +#: You can also pass the contents of the current selection to any +#: program using pass_selection_to_program. By default, the system's +#: open program is used, but you can specify your own, the selection +#: will be passed as a command line argument to the program, for +#: example:: + +#: map kitty_mod+o pass_selection_to_program firefox + +#: You can pass the current selection to a terminal program running in +#: a new kitty window, by using the @selection placeholder:: + +#: map kitty_mod+y new_window less @selection + +#: }}} + +#: Scrolling {{{ + +# map kitty_mod+up scroll_line_up +# map kitty_mod+down scroll_line_down +# map kitty_mod+page_up scroll_page_up +# map kitty_mod+page_down scroll_page_down +# map kitty_mod+home scroll_home +# map kitty_mod+end scroll_end +# map kitty_mod+h show_scrollback + +#: You can pipe the contents of the current screen + history buffer as +#: STDIN to an arbitrary program using the ``launch`` function. For +#: example, the following opens the scrollback buffer in less in an +#: overlay window:: + +#: map f1 launch --stdin-source=@screen_scrollback --stdin-add-formatting --type=overlay less +G -R + +#: For more details on piping screen and buffer contents to external +#: programs, see launch. + +#: }}} + +#: Window management {{{ + +# map kitty_mod+enter new_window + +#: You can open a new window running an arbitrary program, for +#: example:: + +#: map kitty_mod+y launch mutt + +#: You can open a new window with the current working directory set to +#: the working directory of the current window using:: + +#: map ctrl+alt+enter launch --cwd=current + +#: You can open a new window that is allowed to control kitty via the +#: kitty remote control facility by prefixing the command line with @. +#: Any programs running in that window will be allowed to control +#: kitty. For example:: + +#: map ctrl+enter launch --allow-remote-control some_program + +#: You can open a new window next to the currently active window or as +#: the first window, with:: + +#: map ctrl+n launch --location=neighbor some_program +#: map ctrl+f launch --location=first some_program + +#: For more details, see launch. + +# map kitty_mod+n new_os_window + +#: Works like new_window above, except that it opens a top level OS +#: kitty window. In particular you can use new_os_window_with_cwd to +#: open a window with the current working directory. + +# map kitty_mod+w close_window +# map kitty_mod+] next_window +# map kitty_mod+[ previous_window +# map kitty_mod+f move_window_forward +# map kitty_mod+b move_window_backward +# map kitty_mod+` move_window_to_top +# map kitty_mod+r start_resizing_window +# map kitty_mod+1 first_window +# map kitty_mod+2 second_window +# map kitty_mod+3 third_window +# map kitty_mod+4 fourth_window +# map kitty_mod+5 fifth_window +# map kitty_mod+6 sixth_window +# map kitty_mod+7 seventh_window +# map kitty_mod+8 eighth_window +# map kitty_mod+9 ninth_window +# map kitty_mod+0 tenth_window +#: }}} + +#: Tab management {{{ + +# map kitty_mod+right next_tab +# map kitty_mod+left previous_tab +# map kitty_mod+t new_tab +# map kitty_mod+q close_tab +# map shift+cmd+w close_os_window +# map kitty_mod+. move_tab_forward +# map kitty_mod+, move_tab_backward +# map kitty_mod+alt+t set_tab_title + +#: You can also create shortcuts to go to specific tabs, with 1 being +#: the first tab, 2 the second tab and -1 being the previously active +#: tab, and any number larger than the last tab being the last tab:: + +#: map ctrl+alt+1 goto_tab 1 +#: map ctrl+alt+2 goto_tab 2 + +#: Just as with new_window above, you can also pass the name of +#: arbitrary commands to run when using new_tab and use +#: new_tab_with_cwd. Finally, if you want the new tab to open next to +#: the current tab rather than at the end of the tabs list, use:: + +#: map ctrl+t new_tab !neighbor [optional cmd to run] +#: }}} + +#: Layout management {{{ + +# map kitty_mod+l next_layout + +#: You can also create shortcuts to switch to specific layouts:: + +#: map ctrl+alt+t goto_layout tall +#: map ctrl+alt+s goto_layout stack + +#: Similarly, to switch back to the previous layout:: + +#: map ctrl+alt+p last_used_layout + +#: There is also a toggle layout function that switches to the named +#: layout or back to the previous layout if in the named layout. +#: Useful to temporarily "zoom" the active window by switching to the +#: stack layout:: + +#: map ctrl+alt+z toggle_layout stack +#: }}} + +#: Font sizes {{{ + +#: You can change the font size for all top-level kitty OS windows at +#: a time or only the current one. + +# map kitty_mod+equal change_font_size all +2.0 +# map kitty_mod+minus change_font_size all -2.0 +# map kitty_mod+backspace change_font_size all 0 + +#: To setup shortcuts for specific font sizes:: + +#: map kitty_mod+f6 change_font_size all 10.0 + +#: To setup shortcuts to change only the current OS window's font +#: size:: + +#: map kitty_mod+f6 change_font_size current 10.0 +#: }}} + +#: Select and act on visible text {{{ + +#: Use the hints kitten to select text and either pass it to an +#: external program or insert it into the terminal or copy it to the +#: clipboard. + +# map kitty_mod+e open_url_with_hints + +#: Open a currently visible URL using the keyboard. The program used +#: to open the URL is specified in open_url_with. + +# map kitty_mod+p>f kitten hints --type path --program - + +#: Select a path/filename and insert it into the terminal. Useful, for +#: instance to run git commands on a filename output from a previous +#: git command. + +# map kitty_mod+p>shift+f kitten hints --type path + +#: Select a path/filename and open it with the default open program. + +# map kitty_mod+p>l kitten hints --type line --program - + +#: Select a line of text and insert it into the terminal. Use for the +#: output of things like: ls -1 + +# map kitty_mod+p>w kitten hints --type word --program - + +#: Select words and insert into terminal. + +# map kitty_mod+p>h kitten hints --type hash --program - + +#: Select something that looks like a hash and insert it into the +#: terminal. Useful with git, which uses sha1 hashes to identify +#: commits + +# map kitty_mod+p>n kitten hints --type linenum + +#: Select something that looks like filename:linenum and open it in +#: vim at the specified line number. + +# map kitty_mod+p>y kitten hints --type hyperlink + +#: Select a hyperlink (i.e. a URL that has been marked as such by the +#: terminal program, for example, by ls --hyperlink=auto). + + +#: The hints kitten has many more modes of operation that you can map +#: to different shortcuts. For a full description see kittens/hints. +#: }}} + +#: Miscellaneous {{{ + +# map kitty_mod+f11 toggle_fullscreen +# map kitty_mod+f10 toggle_maximized +# map kitty_mod+u kitten unicode_input +# map kitty_mod+f2 edit_config_file +# map kitty_mod+escape kitty_shell window + +#: Open the kitty shell in a new window/tab/overlay/os_window to +#: control kitty using commands. + +# map kitty_mod+a>m set_background_opacity +0.1 +# map kitty_mod+a>l set_background_opacity -0.1 +# map kitty_mod+a>1 set_background_opacity 1 +# map kitty_mod+a>d set_background_opacity default +# map kitty_mod+delete clear_terminal reset active + +#: You can create shortcuts to clear/reset the terminal. For example:: + +#: # Reset the terminal +#: map kitty_mod+f9 clear_terminal reset active +#: # Clear the terminal screen by erasing all contents +#: map kitty_mod+f10 clear_terminal clear active +#: # Clear the terminal scrollback by erasing it +#: map kitty_mod+f11 clear_terminal scrollback active +#: # Scroll the contents of the screen into the scrollback +#: map kitty_mod+f12 clear_terminal scroll active + +#: If you want to operate on all windows instead of just the current +#: one, use all instead of active. + +#: It is also possible to remap Ctrl+L to both scroll the current +#: screen contents into the scrollback buffer and clear the screen, +#: instead of just clearing the screen, for example, for ZSH add the +#: following to ~/.zshrc: + +#: .. code-block:: sh + +#: scroll-and-clear-screen() { +#: printf '\n%.0s' {1..$LINES} +#: zle clear-screen +#: } +#: zle -N scroll-and-clear-screen +#: bindkey '^l' scroll-and-clear-screen + +# map kitty_mod+f5 load_config_file + +#: Reload kitty.conf, applying any changes since the last time it was +#: loaded. Note that a handful of settings cannot be dynamically +#: changed and require a full restart of kitty. You can also map a +#: keybinding to load a different config file, for example:: + +#: map f5 load_config /path/to/alternative/kitty.conf + +#: Note that all setting from the original kitty.conf are discarded, +#: in other words the new conf settings *replace* the old ones. + +# map kitty_mod+f6 debug_config + +#: Show details about exactly what configuration kitty is running with +#: and its host environment. Useful for debugging issues. + + +#: You can tell kitty to send arbitrary (UTF-8) encoded text to the +#: client program when pressing specified shortcut keys. For example:: + +#: map ctrl+alt+a send_text all Special text + +#: This will send "Special text" when you press the ctrl+alt+a key +#: combination. The text to be sent is a python string literal so you +#: can use escapes like \x1b to send control codes or \u21fb to send +#: unicode characters (or you can just input the unicode characters +#: directly as UTF-8 text). The first argument to send_text is the +#: keyboard modes in which to activate the shortcut. The possible +#: values are normal or application or kitty or a comma separated +#: combination of them. The special keyword all means all modes. The +#: modes normal and application refer to the DECCKM cursor key mode +#: for terminals, and kitty refers to the special kitty extended +#: keyboard protocol. + +#: Another example, that outputs a word and then moves the cursor to +#: the start of the line (same as pressing the Home key):: + +#: map ctrl+alt+a send_text normal Word\x1b[H +#: map ctrl+alt+a send_text application Word\x1bOH + +#: }}} + +#: }}} diff --git a/.vimrc b/.vimrc index 7f425b2..436dcaa 100644 --- a/.vimrc +++ b/.vimrc @@ -25,7 +25,7 @@ let g:go_list_type = "quickfix" let g:go_fmt_command = "gopls" let g:go_gopls_gofumpt = 1 let g:go_metalinter_command = "golangci-lint" -autocmd FileType go syntax on +"autocmd FileType go syntax on autocmd FileType go nmap b (go-build) autocmd FileType go nmap i (go-info) autocmd FileType go nmap r (go-run) -- cgit v1.2.3 From de9baa2ddebf828e57809cdb41dddc3ee56cb29e Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 1 Dec 2021 10:26:52 +0100 Subject: updates --- .bashrc | 3 +++ .config/kitty/kitty.conf | 6 +++--- .profile | 1 + .vimrc | 15 ++++----------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.bashrc b/.bashrc index bec9d86..5c0cdee 100644 --- a/.bashrc +++ b/.bashrc @@ -32,6 +32,9 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } #export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta) #export LESS_TERMCAP_ue=$'\E[0m' # end underline +# Less: use a 4-space tabulation +export LESS=Rx4 + # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf index eca0bdf..3777c68 100644 --- a/.config/kitty/kitty.conf +++ b/.config/kitty/kitty.conf @@ -511,9 +511,9 @@ focus_follows_mouse yes #: Window layout {{{ -# remember_window_size yes -# initial_window_width 640 -# initial_window_height 400 +remember_window_size no +initial_window_width c640 +initial_window_height c480 #: If enabled, the window size will be remembered so that new #: instances of kitty will have the same size as the previous diff --git a/.profile b/.profile index 3e36ae3..a2ba42f 100644 --- a/.profile +++ b/.profile @@ -16,3 +16,4 @@ fi . "/opt/homebrew/etc/profile.d/bash_completion.sh" eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)" +tabs -4 diff --git a/.vimrc b/.vimrc index 436dcaa..c2a5776 100644 --- a/.vimrc +++ b/.vimrc @@ -1,7 +1,7 @@ +" General vim defaults " set background= -"set t_te= t_ti= laststatus=2 set t_te= t_ti= ls=1 ruler - +set ai ts=4 sw=4 noet syntax off filetype on filetype plugin on @@ -35,21 +35,14 @@ autocmd FileType go nmap v (go-referrers) autocmd FileType go nmap n :cnext autocmd FileType go nmap p :cprevious autocmd FileType go nmap a :cclose -autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 +" autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "open" let g:netrw_gx = "" let g:netrw_banner = 0 -autocmd filetype javascript,html,json,yaml set ts=2 sts=2 sw=2 et +" autocmd filetype javascript,html,json,yaml set ts=2 sts=2 sw=2 et -" :set wm=2 linebreak -" :set term=ansi -":set modeline -":set modelines=5 -set autoindent -"set breakindent -" :set ts=2 sw=2 sts=2 et :set wrap :set linebreak :set nolist -- cgit v1.2.3 From ea345acc22fbb3a0ac36a7d1ea43de3dae0f51a1 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 2 Dec 2021 15:26:02 +0100 Subject: update --- .backupignore | 2 ++ .config/kitty/kitty.conf | 5 +++-- .vimrc | 3 ++- bin/backup | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.backupignore b/.backupignore index 8f44c0d..f899501 100644 --- a/.backupignore +++ b/.backupignore @@ -9,3 +9,5 @@ .npm/ .vm*/ go/pkg +*.lock +*.socket diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf index 3777c68..34dc1b5 100644 --- a/.config/kitty/kitty.conf +++ b/.config/kitty/kitty.conf @@ -24,6 +24,7 @@ #: bold_italic_font Operator Mono Medium Italic # font_size 11.0 +# font_family Fira Code font_size 14.0 #: Font size (in pts) @@ -512,8 +513,8 @@ focus_follows_mouse yes #: Window layout {{{ remember_window_size no -initial_window_width c640 -initial_window_height c480 +initial_window_width 640 +initial_window_height 480 #: If enabled, the window size will be remembered so that new #: instances of kitty will have the same size as the previous diff --git a/.vimrc b/.vimrc index c2a5776..092b7a1 100644 --- a/.vimrc +++ b/.vimrc @@ -41,7 +41,8 @@ let g:netrw_browsex_viewer = "open" let g:netrw_gx = "" let g:netrw_banner = 0 -" autocmd filetype javascript,html,json,yaml set ts=2 sts=2 sw=2 et +" python and yaml formatting: +autocmd filetype python,yaml set ts=2 sts=2 sw=2 et :set wrap :set linebreak diff --git a/bin/backup b/bin/backup index adce78d..9de097f 100755 --- a/bin/backup +++ b/bin/backup @@ -3,7 +3,7 @@ backup() { date=$(date +%Y%m%d_%H%M%S) - last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) + last=$(rsync --list-only "$dest/" 2>/dev/null | awk '{r=$NF} END {print r}') case $last in ([12]*) opt_link=--link-dest=../$last;; -- cgit v1.2.3 From 0ef8a62a84932a70be06686c55205793921b783b Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 4 Dec 2021 15:20:25 +0100 Subject: update --- .backupignore | 18 ++++++++++++++++++ .config/kitty/kitty.conf | 1 + 2 files changed, 19 insertions(+) diff --git a/.backupignore b/.backupignore index f899501..b4667fa 100644 --- a/.backupignore +++ b/.backupignore @@ -11,3 +11,21 @@ go/pkg *.lock *.socket +*.db-wal +*.db-shm +httpstorages.* +SiriAnalytics.db +Application Support/Knowledge/ +IdentityServices/ +Library/Biome/ +Library/Calendars/ +Library/Saved Application State/ +Containers/com.adguard.* +Containers/com.apple.Safari/ +CoreSpotlight/ +Google/DriveFS/ +GoogleSoftwareUpdate/ +Group Containers/group.com.apple.secure-control-center-preferences/ +Safari/Databases/ +Safari/LocalStorage/ +Safari/Template Icons/ diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf index 34dc1b5..c79faf1 100644 --- a/.config/kitty/kitty.conf +++ b/.config/kitty/kitty.conf @@ -482,6 +482,7 @@ focus_follows_mouse yes #: Terminal bell {{{ # enable_audio_bell yes +enable_audio_bell no #: Enable/disable the audio bell. Useful in environments that require #: silence. -- cgit v1.2.3 From 14b5c600034a9d52497af2974f30dafc21710282 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 6 Dec 2021 15:36:55 +0100 Subject: update --- .backupignore | 1 + .bashrc | 4 +- bin/backup | 57 ++++++++++++++---------- bin/backup-clean | 132 +++++++++++++++++++++++-------------------------------- 4 files changed, 91 insertions(+), 103 deletions(-) diff --git a/.backupignore b/.backupignore index b4667fa..a660b53 100644 --- a/.backupignore +++ b/.backupignore @@ -13,6 +13,7 @@ go/pkg *.socket *.db-wal *.db-shm +*- Google Drive httpstorages.* SiriAnalytics.db Application Support/Knowledge/ diff --git a/.bashrc b/.bashrc index 5c0cdee..c5bdc82 100644 --- a/.bashrc +++ b/.bashrc @@ -38,12 +38,12 @@ export LESS=Rx4 # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' +export BACKUP=bip:/home/backup/marc@m1 + # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' #export TERMINAL=xt - -alias bu='backup -uvd bip:/home/backup/m1' #alias cl='cf xft:Mono:size=12' #alias cp='cp --reflink' #alias ls='ls --color=auto -v' diff --git a/bin/backup b/bin/backup index 9de097f..3964927 100755 --- a/bin/backup +++ b/bin/backup @@ -1,38 +1,47 @@ #!/bin/sh -# Incremental backup using rsync(1). -backup() { - date=$(date +%Y%m%d_%H%M%S) - last=$(rsync --list-only "$dest/" 2>/dev/null | awk '{r=$NF} END {print r}') +usage() { + echo "Usage: $0 [-nv] [[[user@]host]:dir] - case $last in - ([12]*) opt_link=--link-dest=../$last;; - (*) opt_link=;; - esac +Incremental backup using rsync(1). If run as root, a full system +backup is performed. Otherwise, the user's home directory is backed. - rsync -HSxa$optv --exclude-from=$ignore $opt_link $volumes "$dest/$date" -} +Options: +-n dry-run +-v verbose -dest=/.history -ignore=/etc/backupignore -volumes='/ /boot' +Files: +- $HOME/.backupignore exclude files from user backup (non root) +- /etc/backupignore exclude files from system backup (root) + +Environment: +- BACKUP backup directory" +} -while getopts :d:i:nuv opt; do +while getopts :nv opt; do case $opt in - (d) dest="$OPTARG" ;; - (i) ignore="$OPTARG" ;; (n|v) optv="$opt$optv" ;; - (u) optu=1 volumes="$HOME" ignore="$HOME/.backupignore" ;; - (*) echo "Usage: $0 [-nuv] [-d [[user@]host:]dir] [clean|diff]"; exit 1 ;; + (*) usage; exit 1 ;; esac done shift $((OPTIND - 1)) -[ "$optu" ] || [ "$USER" = root ] || exec sudo "$0" "$@" +BACKUP=${1:-$BACKUP} +[ "$BACKUP" ] || { usage; exit 1; } -[ "$1" ] && cmd=$1 && shift || cmd="" -case $cmd in -(""|save) backup ;; -(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";; -(diff) exec diffdir "$@";; +[ "$USER" = root ] && + ignore=/etc/backupignore volumes='/ /boot' || + ignore="$HOME/.backupignore" volumes="$HOME" +[ -f "$ignore" ] && ignore="--exclude-from=$ignore" || ignore= + +last=$(rsync --list-only "$BACKUP/" 2>/dev/null | awk '{r=$NF} END {print r}') +case $last in +([12]*) opt_link=--link-dest=../$last;; +(*) opt_link=;; esac + +date=$(date +%Y-%m-%d-%H%M%S) + +[ "$optv" ] && echo "# Backup $volumes to $BACKUP/$date" + +exec rsync -HSxa$optv $ignore $opt_link $volumes "$BACKUP/$date" diff --git a/bin/backup-clean b/bin/backup-clean index 30d25db..f5baa29 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -1,89 +1,67 @@ #!/bin/sh -# backup garbage collector -[ "$USER" = root ] || exec sudo "$0" "$@" -# Durations, in number of seconds. -hd=3600 # hour duration: 60s * 60 -h12=43200 # 12h: hd * 12 -dd=86400 # day duration: hd * 24 -wd=604800 # week duration: dd * 7 -md=2592000 # month duration: dd * 30 -yd=31557600 # year duration: dd * 365.25 +usage() { + echo "Usage: $0 [-nv] [[[user@]host:]dir] -now=$(date +'%Y%m%d_%H%M%S') +$0 removes old backups and keeps: +- backups for the current day +- 1 backup per past day for the current month +- 1 backup per past month for the current year +- 1 backup per past year -# The following works only for busybox date, not coreutils -# Kept for reference only. -#date2ts() { d=${1%_*} t=${1#*_}; date -d "$d${t%??}" +%s; } +Options: +-n dry run +-v verbose -# Convert date to timestamp, using date from GNU coreutils, -# works also with busybox date. -date2ts() { - t=$1; r=${t#????}; Y=${t%$r} # Year (with century) - t=$r; r=${t#??}; m=${t%$r} # Month - t=$r; r=${t#??}; d=${t%$r} # Day - t=${r#_}; r=${t#??}; H=${t%$r} # Hour - t=$r; r=${t#??}; M=${t%$r} # Minute - S=${t#??} # Second - date -d "$Y-$m-$d $H:$M:$S" +%s - #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOS (not tested) +Environment variables: +- BACKUP - backup directory" } -ts2date() { date -d "@$1" +'%Y%m%d_%H%M%S'; } - -tsn=$(date2ts "$now") - -# Minimal retention delay in seconds, according to backup age, -# implemented using POSIX shell arithmetic. -retention_delay() { - d=$((tsn - $1)) - if [ $((d < h12)) = 1 ]; then - r=0 # keep all backups in the last 12 hours - elif [ $((d < dd)) = 1 ]; then - r=$hd # keep 1 backup per hour in the last day - elif [ $((d < wd)) = 1 ]; then - r=$dd # keep 1 backup per day in the last week - elif [ $((d < md)) = 1 ]; then - r=$wd # keep 1 backup per week in the last month - elif [ $((d < yd)) = 1 ]; then - r=$md # keep 1 backup per month in the last year - else - r=$yd # keep 1 backup per year in the previous years - fi - echo $r -} - -dest=/.history -while getopts :d:nv opt; do +while getopts :nv opt; do case $opt in - (d) tsn=$(date2ts "$OPTARG") ;; - (n) optn=1 ;; - (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [dir]"; exit 1 ;; + (n) optn=echo ;; + (v) optv=-t ;; + (*) usage; exit 1 ;; esac done -shift $((OPTIND - 1)) -[ "$1" ] && dest=$1 +shift $((OPTIND -1)) + +BACKUP=${1:-$BACKUP} +[ "$BACKUP" ] || { usage; exit 1; } -# Sorted list of backups, most recent first. -lbu=$(ls -rv "$dest") -lasy=${lbu##* +host=${BACKUP%:*} dir=${BACKUP#*:} +ls='ls -r' rm="xargs -r $optv $optn rm -rf" +[ "$host" = "$dir" ] || ls="ssh $host $ls" rm="ssh $host $rm" + +[ "$optv" ] && echo "# Cleaning backups on $BACKUP" + +$ls "$dir" | +awk -v now=$(date +%Y-%m-%d) -v dir="$dir" ' +BEGIN { + yn = substr(now, 1, 4) # Year now + mn = substr(now, 6, 2) # Month now + dn = substr(now, 9, 2) # Day now } -for d in $lbu; do - tsc=$(date2ts "$d") - if ! [ "$tsp" ]; then - [ "$optv" ] && echo "keep $dest/$d" - tsp=$tsc - continue - fi - mrd=$(retention_delay "$tsp") - dp=$((tsp - tsc)) - #if [ $((dp < mrd)) = 1 ]; then - if [ "$d" != "last" -a $((dp < mrd)) = 1 ]; then - [ "$optv" ] && echo "delete $dest/$d" - [ "$optn" ] || rm -rf "${dest:?}/$d" - else - [ "$optv" ] && echo "keep $dest/$d" - tsp=$tsc - fi -done +{ + yb = substr($0, 1, 4) # Year backup + mb = substr($0, 6, 2) # Month backup + db = substr($0, 9, 2) # Day backup + $0 = dir "/" $0 + + dy = yn - yb + dm = dy * 12 + mn - mb + # if (yb != yn) { + if (dm > 12) + if (yb in yearly) print; else yearly[yb] = 1 + next + } + # if (mb != mn) { + dd = dm * 30 + dn - db + if (dd > 30) { + if (mb in monthly) print; else monthly[mb] = 1 + next + } + if (db != dn) { + if (db in dayly) print; else dayly[db] = 1 + } +}' | $rm -- cgit v1.2.3 From 4233fc9c6bc0f2f136a495efcd497394edd5156b Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 7 Dec 2021 14:50:57 +0100 Subject: update --- .backupignore | 5 +++++ bin/backup | 3 +-- bin/backup-clean | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.backupignore b/.backupignore index a660b53..3834dfa 100644 --- a/.backupignore +++ b/.backupignore @@ -13,7 +13,12 @@ go/pkg *.socket *.db-wal *.db-shm +*.old +*.log +*.o *- Google Drive +build/*/ +login.keychain-db httpstorages.* SiriAnalytics.db Application Support/Knowledge/ diff --git a/bin/backup b/bin/backup index 3964927..d682849 100755 --- a/bin/backup +++ b/bin/backup @@ -42,6 +42,5 @@ esac date=$(date +%Y-%m-%d-%H%M%S) -[ "$optv" ] && echo "# Backup $volumes to $BACKUP/$date" - +echo "# Backup $volumes to $BACKUP/$date" exec rsync -HSxa$optv $ignore $opt_link $volumes "$BACKUP/$date" diff --git a/bin/backup-clean b/bin/backup-clean index f5baa29..34e6d97 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -33,7 +33,7 @@ host=${BACKUP%:*} dir=${BACKUP#*:} ls='ls -r' rm="xargs -r $optv $optn rm -rf" [ "$host" = "$dir" ] || ls="ssh $host $ls" rm="ssh $host $rm" -[ "$optv" ] && echo "# Cleaning backups on $BACKUP" +echo "# Cleaning backups on $BACKUP" $ls "$dir" | awk -v now=$(date +%Y-%m-%d) -v dir="$dir" ' @@ -51,7 +51,7 @@ BEGIN { dy = yn - yb dm = dy * 12 + mn - mb # if (yb != yn) { - if (dm > 12) + if (dm > 12) { if (yb in yearly) print; else yearly[yb] = 1 next } -- cgit v1.2.3 From 2285a119864b87bc136035efa6f650d14aacbf12 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 9 Dec 2021 20:44:13 +0100 Subject: update --- .backupignore | 2 +- .bash-powerline.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.backupignore b/.backupignore index 3834dfa..579b72d 100644 --- a/.backupignore +++ b/.backupignore @@ -18,7 +18,6 @@ go/pkg *.o *- Google Drive build/*/ -login.keychain-db httpstorages.* SiriAnalytics.db Application Support/Knowledge/ @@ -28,6 +27,7 @@ Library/Calendars/ Library/Saved Application State/ Containers/com.adguard.* Containers/com.apple.Safari/ +Containers/com.ranchero.NetNewsWire-Evergreen/ CoreSpotlight/ Google/DriveFS/ GoogleSoftwareUpdate/ diff --git a/.bash-powerline.sh b/.bash-powerline.sh index 626157a..6d2ee2d 100644 --- a/.bash-powerline.sh +++ b/.bash-powerline.sh @@ -23,7 +23,7 @@ __powerline() { elif test -f '/etc/hostname'; then host=$( Date: Fri, 10 Dec 2021 12:15:36 +0100 Subject: update --- .bashrc | 10 ---------- .profile | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.bashrc b/.bashrc index c5bdc82..1a05028 100644 --- a/.bashrc +++ b/.bashrc @@ -144,13 +144,3 @@ meteo() { # Display git status in prompt . ~/.bash-powerline.sh -# export PS1='; ' - -# load Nix config files (aka auto-completion etc.) -#export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" - -PATH="/Users/marc/perl5/bin${PATH:+:${PATH}}"; export PATH; -PERL5LIB="/Users/marc/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; -PERL_LOCAL_LIB_ROOT="/Users/marc/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; -PERL_MB_OPT="--install_base \"/Users/marc/perl5\""; export PERL_MB_OPT; -PERL_MM_OPT="INSTALL_BASE=/Users/marc/perl5"; export PERL_MM_OPT; diff --git a/.profile b/.profile index a2ba42f..9811256 100644 --- a/.profile +++ b/.profile @@ -15,5 +15,5 @@ fi #esac . "/opt/homebrew/etc/profile.d/bash_completion.sh" -eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)" + tabs -4 -- cgit v1.2.3 From ee915415941c712701d907fff92a73a7b296b682 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sat, 18 Dec 2021 11:31:04 +0100 Subject: disable gopls, revert to vim --- .bashrc | 4 ++-- .vimrc | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.bashrc b/.bashrc index 1a05028..8e0b339 100644 --- a/.bashrc +++ b/.bashrc @@ -49,8 +49,8 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date #alias ls='ls --color=auto -v' alias ls='ls -GF' alias ll='ls -AlGFhv' -alias vi='nvim' -alias view='nvim -R' +alias vi='vim' +alias view='vim -R' alias ldd='otool -L' alias ibrew='arch -x86_64 /usr/local/bin/brew' #alias op='xdg-open' diff --git a/.vimrc b/.vimrc index 092b7a1..f002a86 100644 --- a/.vimrc +++ b/.vimrc @@ -18,12 +18,15 @@ autocmd filetype vimki set autowrite autocmd filetype vimki nmap z :FZF ~/Wiki " vim-go plugin -let g:go_def_mode = "gopls" -let g:go_info_mode = "gopls" -let g:go_list_type = "quickfix" -" let g:go_fmt_command = "goimports" -let g:go_fmt_command = "gopls" -let g:go_gopls_gofumpt = 1 +"let g:go_def_mode = "gopls" +"let g:go_info_mode = "gopls" +"let g:go_list_type = "quickfix" +"let g:go_fmt_command = "gopls" +"let g:go_gopls_gofumpt = 1 + +let g:go_gopls_enabled = 0 +let g:go_def_mode = "godef" +let g:go_fmt_command = "goimports" let g:go_metalinter_command = "golangci-lint" "autocmd FileType go syntax on autocmd FileType go nmap b (go-build) -- cgit v1.2.3 From e200c8d78ca1d3388c25c1cef8892b1dd015bbf7 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 28 Jan 2022 12:19:59 +0100 Subject: update --- .bashrc | 6 ++++-- .profile | 2 +- bin/vm | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.bashrc b/.bashrc index 8e0b339..c977a96 100644 --- a/.bashrc +++ b/.bashrc @@ -86,8 +86,8 @@ alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/traefik/yaegi' #alias ty='go test -v -short ./interp' -alias ya='rlwrap -pblue yaegi' -alias dya='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' +alias y='rlwrap -pblue yaegi' +alias dy='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' alias wai='~/go/src/github.co/traefik/whoami/whoami' # yaegi debug @@ -144,3 +144,5 @@ meteo() { # Display git status in prompt . ~/.bash-powerline.sh + +export GITHUB_TOKEN=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 diff --git a/.profile b/.profile index 9811256..fb64b2e 100644 --- a/.profile +++ b/.profile @@ -1,6 +1,6 @@ # ~/.profile -PATH=~/bin:/opt/homebrew/bin:/opt/homebrew/opt/ruby/bin:$PATH:~/go/bin:~/.cargo/bin +PATH=~/bin:/opt/homebrew/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/opt/tcl-tk/bin:$PATH:~/go/bin:~/.cargo/bin if [ -z "$SSH_AUTH_SOCK" ] ; then eval `ssh-agent -s` diff --git a/bin/vm b/bin/vm index 97e3521..6b03d0e 100755 --- a/bin/vm +++ b/bin/vm @@ -242,7 +242,8 @@ start_vm() ( "$dir/vftool" \ ${kernel+-k "$kernel"} \ ${initrd+-i "$initrd"} \ - ${hdd+-d "$hdd"} \ + ${hda+-d "$hda"} \ + ${hdb+-d "$hdb"} \ ${iso+-c "$iso"} \ ${cpu+-p "$cpu"} \ ${ram+-m "$ram"} \ -- cgit v1.2.3