summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2020-02-21 19:06:25 +0100
committerMarc Vertes <mvertes@free.fr>2020-02-21 19:06:25 +0100
commitd1622279f7eca5bb2e49c38d6faa5638d1517b82 (patch)
tree865e4640eb14d05676e418ab9b0d36c330053437
parentc451245564f6b0ca125a431a516510d7a7c8aa7d (diff)
update lt, i3, gitconfig
-rw-r--r--.config/i3/config3
-rw-r--r--.gitconfig1
-rwxr-xr-xbin/lt65
3 files changed, 45 insertions, 24 deletions
diff --git a/.config/i3/config b/.config/i3/config
index 58a48f3..4420d2e 100644
--- a/.config/i3/config
+++ b/.config/i3/config
@@ -50,13 +50,14 @@ for_window [class="Chromium"] floating enable
for_window [instance="Task Manager - Chromium"] floating enable
for_window [instance="DOTTY"] floating enable
for_window [class="discord"] floating enable
-for_window [class="display"] floating enable
+for_window [class="Display"] floating enable
for_window [class="feh"] floating enable
for_window [class="firefox"] floating enable
for_window [class="gnuplot_qt"] floating enable
for_window [class="Geeqie"] floating enable
for_window [class="Gitk"] floating enable
for_window [class="Keybase"] floating enable
+for_window [class="libreoffice"] floating enable
for_window [class="MuPDF"] floating enable
for_window [class="Pavucontrol"] floating enable
for_window [class="Slack"] floating enable
diff --git a/.gitconfig b/.gitconfig
index c604c43..82d1f09 100644
--- a/.gitconfig
+++ b/.gitconfig
@@ -6,6 +6,7 @@
cob = checkout -b
do = diff origin/master
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%an]" --decorate
+ st = status -s
[user]
email = mvertes@free.fr
name = Marc Vertes
diff --git a/bin/lt b/bin/lt
index 808b9f0..f09f3b7 100755
--- a/bin/lt
+++ b/bin/lt
@@ -7,10 +7,21 @@ unset CDPATH
export LC_ALL=C IFS='
'
+help() {
+ echo "Lt is a tool for creating link trees.
+
+Usage:
+ lt [-Vn] src dest
+
+Options:
+ -V print version and exit
+ -n print actions but not execute"
+}
+
# ca returns the common ancestor between 2 paths
-# ca /h/u/a/b /h/u/c/d => /h/u
+# i.e. ca /h/u/a/b /h/u/c/d => /h/u
ca() {
- ca_p1=${1#/} ca_p2=${2#/} ca_r1= ca_r2= R1=/
+ ca_p1=${1#/} ca_p2=${2#/} ca_r1='' ca_r2='' R1=/
while true; do
[ "$ca_p1" ] || [ "$ca_p2" ] || break
ca_r1=$ca_r1/${ca_p1%%/*} ca_p1=${ca_p1#*/}
@@ -20,53 +31,61 @@ ca() {
done
}
-#echo ca $1 $2 && ca $1 $2 && echo "$R1"
-
-# bp returns the relative path from source to base
-bp() {
- bp_s=$1 bp_b=$2 R1=
+# pp returns the relative path from child to parent
+# i.e. pp /h/u/a /h/u => ..
+pp() {
+ pp_s=$1 pp_b=$2 R1=''
while true; do
- [ "$bp_b" = "$bp_s" ] && break
- bp_s=${bp_s%/*}
+ [ "$pp_b" = "$pp_s" ] && break
+ pp_s=${pp_s%/*}
[ "$R1" ] && R1=$R1/.. || R1=..
done
}
-#echo bp /h/u/a /h/u && bp /h/u/a /h/u && echo "$R1"
-
# rp returns the relative path between src and base
-# rp /h/u/a/b/f /h/u/b/f [/h/u] ../a/b/f
+# i.e. rp /h/u/a/b/f /h/u/b/f [/h/u] ../a/b/f
rp() {
rp_s=$1 rp_d=$2 rp_c=$3
! [ "$rp_c" ] && ca "$1" "$2" && rp_c=$R1
- rp_bd=${rp_d#$rp_c/}
rp_bs=${rp_s#$rp_c/}
- bp "$rp_d" "$rp_c" && R1=$R1/$rp_bs && R1=${R1#../}
+ pp "$rp_d" "$rp_c" && R1=$R1/$rp_bs && R1=${R1#../}
}
-#rp /h/u/a/b /h/u/b && echo $R1
-
skip=".git .gitignore .*.swp Makefile README.md"
-# link tree src dest
+# lt links src tree to dest (each file is a link)
lt() {
d=$(mkdir -p "$2" && cd "$2" && pwd)
- cd "$1" && s=$PWD
+ cd "$1" && s=$PWD &&
find . ! -type d -print | {
- cd "$d"
- while read f; do
+ cd "$d" &&
+ while read -r f; do
for k in $skip; do
case $f in (./$k|./$k/*) continue 2;; esac
done
- f=${f#./}
- fd=$d/$f; fd=${fd%/*}
+ f=${f#./}; fd=$d/$f; fd=${fd%/*}
test -d "$fd" || $trace mkdir -p "$fd"
rp "$s/$f" "$d/$f" && $trace ln -sf "$R1" "$d/$f"
done
}
}
-#trace=echo
+while getopts :nvV opt; do
+ case $opt in
+ (n) trace='echo' ;;
+ (V) echo "$lt_version"; exit ;;
+ (*) help; exit 1;;
+ esac
+done
+shift $((OPTIND -1))
+
lt "$1" "$2"
#echo $1 $2 $3 && $1 $2 $3 && echo $R1
+
+# Shell coding style:
+# - standard POSIX shell, to be used as-is on Unix, Linux (busybox), *BSD*
+# - no bashism, GNUism, etc.
+# - local variables in same process are prefixed with function name, to avoid collisions
+# - same process functions return values in R1, R2, ... global vars.
+# - self-documented, self-tested