dot

packages and services management
Log | Files | Refs | README

commit 3929dc7fce2fe8ff45387e9bc28aa4a0e86a1a71
parent 1ae69d15ecaf89fe1b1424c4e81a0ed29a346eae
Author: josuah <mail@josuah.net>
Date:   Thu, 29 Dec 2016 17:00:03 +0100

changes

Diffstat:
M.config/dvtm/config.h | 37+++++++++++++++++++++++++++++++------
M.local/bin/dna | 34+++++++++++++++-------------------
M.local/bin/play | 5+++--
M.local/bin/version | 132+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
A.local/share/build/dash | 3+++
M.local/share/build/isync | 6++++++
M.profile | 112++++++++++++++++++++++++++++---------------------------------------------------
7 files changed, 172 insertions(+), 157 deletions(-)

diff --git a/.config/dvtm/config.h b/.config/dvtm/config.h @@ -274,10 +274,35 @@ static Action actions[] = { * sequences are generated in the output. */ static Editor editors[] = { - { .name = "vis", .argv = { "vis", "+%d", "-", NULL }, .filter = true, .color = false }, - { .name = "sandy", .argv = { "sandy", "-d", "-", NULL }, .filter = true, .color = false }, - { .name = "dvtm-editor", .argv = { "dvtm-editor", "-", NULL }, .filter = true, .color = false }, - { .name = "vim", .argv = { "vim", "+%d", "-", NULL }, .filter = false, .color = false }, - { .name = "less", .argv = { "less", "-R", "+%d", NULL }, .filter = false, .color = true }, - { .name = "more", .argv = { "more", "+%d", NULL }, .filter = false, .color = false }, + { + .name = "vis", + .argv = { "vis", "+%d", "-", NULL }, + .filter = true, + .color = false + }, { + .name = "sandy", + .argv = { "sandy", "-d", "-", NULL }, + .filter = true, + .color = false + }, { + .name = "dvtm-editor", + .argv = { "dvtm-editor", "-", NULL }, + .filter = true, + .color = false + }, { + .name = "less", + .argv = { "less", "-R", "+%d", NULL }, + .filter = false, + .color = true + }, { + .name = "vim", + .argv = { "vim", "+%d", "-", NULL }, + .filter = false, + .color = false + }, { + .name = "more", + .argv = { "more", "+%d", NULL }, + .filter = false, + .color = false + } }; diff --git a/.local/bin/dna b/.local/bin/dna @@ -69,8 +69,8 @@ T="\ random() ( - while date +%s | md5sum | tr -cd '0-9a-f\n' | fold -w 1 | - tr 0-9a-f ATCGATCGATCGATCG + while date +%s | md5sum | tr -cd '0-9a-f\n' | + tr 0-9a-f ATCGATCGATCGATCG | fold -w 1 do sleep 1 done | while read -r n @@ -81,24 +81,20 @@ random() ) -nucleotide() -( - nucleotide="$1" +main() +{ + [ -z "$1" ] && random - case $nucleotide in - A) printf %s "$A" ;; - C) printf %s "$C" ;; - T) printf %s "$T" ;; - G) printf %s "$G" ;; - esac -) + while [ "$1" ] + do + case "$1" in + ( A* ) printf %s "$A" ;; ( T* ) printf %s "$T" ;; + ( C* ) printf %s "$C" ;; ( G* ) printf %s "$G" ;; + esac + set -- "${1#?}" + done +} -[ -z "$1" ] && random -while [ ! -z "$dna" ]; do - i=$((i + 1)) - nucleotide=$(printf '%s' "$dna" | cut -c 1) - nucleotide "$nucleotide" - dna=$(printf '%s' "$dna" | cut -c 2-) -done +main "$@" diff --git a/.local/bin/play b/.local/bin/play @@ -1,6 +1,7 @@ -exec mplayer $( - IFS=' +IFS=' ' + +exec mplayer $( for path in "$@" do find "$path" -type f -name '*.flac' | sort diff --git a/.local/bin/version b/.local/bin/version @@ -1,7 +1,8 @@ #!/bin/sh +# mkdir find sort xargs md5sum tail rm test mv comm sed uniq grep printf -NL=' +TAB=' ' NL=' ' @@ -18,7 +19,7 @@ ${0##*/} m[erge] TREE merge current tree with foreign TREE die() { - printf '%s: %s\n' "${0##*/}" "$*" + printf '\033[31m%s: \033[1m%s\033[m\n' "${0##*/}" "$*" exit 1 } @@ -59,22 +60,24 @@ init() new() { - cd "$1" && [ -d .version ] || die "no .version dir in $1" + cd "$1" && [ -d .version ] || die "no .version dir in $PWD" find . -type f $(exclude .git .version) -print0 | sort -z | xargs -0 md5sum > .version/tmp - md5="$(md5sum .version/tmp | cut -d ' ' -f 1)" + hash="$(md5sum .version/tmp)" + hash="${hash%% *}" - if [ -f .version/history ] && - [ "$md5" = "$(tail -n 1 .version/history)" ] + if + [ -f .version/history ] && + [ "$hash" = "$(tail -n 1 .version/history)" ] then rm .version/tmp die 'already at latest version' fi - printf '%s\n' "$md5" >> .version/history - mv .version/tmp ".version/$md5" + printf '%s\n' "$hash" >> .version/history + mv .version/tmp ".version/$hash" } @@ -82,74 +85,83 @@ merge() { [ -d "$1/.version" ] || die "no .version dir in $PWD" [ -d "$2/.version" ] || die "no .version dir in $2" + [ -f "$1/.version/history" ] || die "no revision in $PWD" + [ -f "$2/.version/history" ] || die "no revision in $2" # find latest common revision - revision="$({ - find .version -type f ! -name history -maxdepth 1 - cd "$1" || exit - find .version -type f ! -name history -maxdepth 1 - } | sort -r | uniq -d | head -n 1)" - revision="${revision#*.version/}" + revision="$( + comm -12 "$1/.version/history" "$2/.version/history" | tail -1 + )" + [ "$revision" ] || die "no revision common to $1 and $2" # generate a diff for both trees for root in "$1" "$2" do - printf '\n%s:\n' "$root" - [ -f "$root/.version/history" ] || die "no revision in $root" + printf '\n\n\n%s\n' "$root" - # get all changes since "$revision" - revisions="$(cat "$root/.version/history")$NL" - revisions="${revisions##*$revision$NL}" - - # generate a diff of every revision with next one - prev="$revision" - for next in $revisions - do - makediff "$root" "$prev" "$next" - prev="$next" - done - - done + done | less } # -# 1: root of the tree for which make a diff -# 2: previous revision for the diff -# 3: next revision for the diff +# 1: 2: revisions for the diff +# 3: root of the tree for which make a diff # makediff() { - printf ' %s -> %s\n' "$2" "$3" -} + printf '\n\n: %s %s\n\n' "$1" "$2" + # i: identical: same hash and same name + comm -12 "$root/.version/$1" "$root/.version/$2" | sed 's/^/i /' -# -# Returns a string describing the change between for "$md5 $name" since last -# revision: "[c|d|m|r|x|e] <md5sum> <filename>" -# -# with m: modification r: rename x: unexistant e: equal -# -event() -{ - root="$1" revision="$2" md5="$3" name="$4" new_md5='' new_name='' + # m: modified: same name, different content + comm -3 "$root/.version/$1" "$root/.version/$2" | sed 's/^\t//' | + sort -b -t "$NL" -k 1.35 | uniq -ds 34 | sed 's/^/m /' - while read -r m n + # r: renamed: same hash, different name + comm -3 "$root/.version/$1" "$root/.version/$2" | sed 's/^\t//' | + while read -r hash name + do + grep -F "$hash" "$root/.version/$1" | sed 's/^/r /' + done + + # d: deleted: neither name nor hash present in the next revision + while read -r hash name do - match='' event='' + ! grep -F "$hash" "$root/.version/$2" > /dev/null && + ! grep -F "$name" "$root/.version/$2" > /dev/null && + printf 'd %s %s\n' "$hash" "$name" + done < "$root/.version/$1" - [ "$m" = "$md5" ] && match="${match}m" - [ "$n" = "$name" ] && match="${match}n" + # c: created: neither name nor hash present in the previous + while read -r hash name + do + ! grep -F "$hash" "$root/.version/$1" > /dev/null && + ! grep -F "$name" "$root/.version/$1" > /dev/null && + printf 'c %s %s\n' "$hash" "$name" + done < "$root/.version/$2" +} - case "${event:-x}-$match" in - ( [xrmn]-mn ) event=e; break new_md5="$md5" new_name="$name" ;; - ( [xrm]-m ) event=r; new_md5="$m" ;; - ( [xrn]-n ) event=m; new_name="$n" ;; - ( x- ) event=x; ;; - esac - done < "$root/.version/$revision" - printf '%s %s %s\n' "$event" "${new_md5:-$md5}" "${new_name:-$name}" +# +# 1: 2: revisions between which generate each diff +# 3: root of the tree for which make a diff +# +tracediff() +{ + # get all changes since "$1" + revisions="$(cat "$3/.version/history")$NL" + revisions="${revisions##*${1:-$( + sed + )}$NL}" + + # generate a diff of every revision with next one + prev="$revision" + for next in $revisions + do + makediff "$prev" "$next" "$root" + prev="$next" + done } @@ -158,12 +170,18 @@ main() root="$(root)" case "$1" in - ( i | init ) [ $# -ne 1 ] && usage + ( i | init ) [ $# -ne 1 ] && usage init "$root" ;; - ( n | new ) [ $# -ne 1 ] && usage + ( n | new ) [ $# -ne 1 ] && usage new "$root" ;; + ( d | diff ) + [ $# -gt 2 ] && [ ! -f ".version/$1" ] || + [ $# -eq 3 ] && [ ! -f ".version/$2" ] || + [ $# -gt 3 ] && usage + tracediff "$2" "$3" "$root" + ;; ( m | merge ) [ $# -ne 2 ] && usage merge "$root" "$2" ;; diff --git a/.local/share/build/dash b/.local/share/build/dash @@ -0,0 +1,3 @@ +# debian almquist shell + +tar=http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.9.tar.gz diff --git a/.local/share/build/isync b/.local/share/build/isync @@ -1,3 +1,9 @@ # Sync IMAP to Maildir tar=http://downloads.sourceforge.net/project/isync/isync/1.2.1/isync-1.2.1.tar.gz + +build() +{ + ./configure --prefix="$PREFIX" --with-ssl="/home/josuah/.local/lib/" + make PREFIX="$PREFIX" install clean +} diff --git a/.profile b/.profile @@ -1,18 +1,10 @@ -# Shell configuration for any POSIX shell 2016-11-28 -# _ -# _ _ _ /_ . | _ -# . |_) | (_) | | | (/_ -# | -#_______________________________________________________________________________ +# Shell configuration for any POSIX shells # Prevents to be run twice per session [ "$PROFILE" ] && return 0 || PROFILE=1 -# Environment variables -#_______________________________________________________________________________ - . ~/.local/bin/build export ENV="$HOME/.profile" @@ -23,17 +15,14 @@ export NAME='Josuah Demangeon' export EMAIL='mail@josuah.net' export MAIL="$HOME/mail/INBOX" +# default commands +export EDITOR='vim' VISUAL="$EDITOR" FCEDIT="$EDITOR" +export PAGER='less' MANPAGER="$PAGER" + # dvtm export DVTM_TERM='ansi' export DVTM_EDITOR="$PAGER" -# default commands -export EDITOR="vim" -export VISUAL="$EDITOR" -export FCEDIT="$EDITOR" -export PAGER="less" -export MANPAGER="$PAGER" - # xdg base directory export XDG_DATA_HOME="$HOME/.local/share" export XDG_CONFIG_HOME="$HOME/.config" @@ -45,7 +34,7 @@ export PS1='$( [ $? -eq 0 ] && color=2 || color=1 [ -z "${PWD##$HOME*}" ] && pwd="~${PWD#$HOME}" || pwd="$PWD" - printf "\a\n \033[?6c\033[30;1m%s\033[m" "$pwd" + printf "\a\033[?6c\n \033[30;1m%s\033[m" "$pwd" git-prompt printf "\n \033[1;30m>\033[0;3%sm>\033[1m>\033[m " "$color" )' @@ -53,14 +42,13 @@ export PS2=' > ' export PS3=' > ' -# Aliases -#_______________________________________________________________________________ - # coreutils -alias l='list -lh --color' -alias la='list -Alh --color' +alias p='page' +alias l='page ls -lh --color' +alias la='page ls -Alh --color' alias cl='printf "\033[H\033[2J"' -alias bh='busybox --help' +alias bh='page busybox --help' +alias grep='page grep' # iomenu alias a='io-abduco' @@ -81,16 +69,9 @@ alias myip='curl icanhazip.com' alias lines='find . -name "*.[ch]" | xargs wc -l' -# Functions -#_______________________________________________________________________________ - - -list() +page() { - { - printf '\n\n' - ls "$@" - } | more + "$@" | less -ER } @@ -98,7 +79,7 @@ color() { for i in 1 2 3 4 5 6 7 do - printf ' \033[3%sm///\033[1m///\033[0m' $i + printf ' \033[3%sm___\033[1m___\033[0m' $i done printf '\n' } @@ -107,30 +88,24 @@ color() extract() { case "$1" in - *.tar.bz2) tar xvjf "$1" ;; - *.tar.gz ) tar xvzf "$1" ;; - *.bz2 ) bunzip2 "$1" ;; - *.rar ) unrar x "$1" ;; - *.gz ) gunzip "$1" ;; - *.tar ) tar xvf "$1" ;; - *.tbz2 ) tar xvjf "$1" ;; - *.tgz ) tar xvzf "$1" ;; - *.zip ) unzip "$1" ;; - *.Z ) uncompress "$1" ;; - *.7z ) 7z x "$1" ;; - *.xz ) xz -d "$1" ;; - *.deb ) ar vx "$1" ;; - * ) printf 'extract: Unknown archive type\n';; + ( *.tar.gz ) tar xvzf "$1" ;; + ( *.tgz ) tar xvzf "$1" ;; + ( *.tar.bz2 ) tar xvjf "$1" ;; + ( *.tbz2 ) tar xvjf "$1" ;; + ( *.tar ) tar xvf "$1" ;; + ( *.bz2 ) bunzip2 "$1" ;; + ( *.rar ) unrar x "$1" ;; + ( *.zip ) unzip "$1" ;; + ( *.gz ) gunzip "$1" ;; + ( *.Z ) uncompress "$1" ;; + ( *.7z ) 7z x "$1" ;; + ( *.xz ) xz -d "$1" ;; + ( *.deb ) ar vx "$1" ;; + ( * ) printf 'extract: Unknown archive extension\n';; esac } -weather() -{ - curl -4 "wttr.in/$1" -} - - # # Sudo, sudo, sudo, sudo, sudo, screen brightness, sudo, sudo... # @@ -158,10 +133,7 @@ mnt() rotate() { case "$1" in - u | up ) printf 0 ;; - r | right ) printf 1 ;; - d | down ) printf 2 ;; - l | left ) printf 3 ;; + ( u ) printf 0 ;; ( r ) printf 1 ;; ( d ) printf 2 ;; ( l ) printf 3 ;; esac | sudo tee /sys/class/graphics/fbcon/rotate_all > /dev/null } @@ -171,30 +143,24 @@ rotate() # fbv() { - local x="$(sed 's/,.*//' /sys/class/graphics/fb0/virtual_size)" - local y="$(sed 's/.*,//' /sys/class/graphics/fb0/virtual_size)" - local video="$1" - - trap "kill -9 0" INT EXIT - - mplayer -vm -vo fbdev2 "$video" -vf scale -zoom -x "$x" -y "$y" + mplayer -vm -vo fbdev2 "$1" -vf scale -zoom -x "$( + sed 's/,.*//' /sys/class/graphics/fb0/virtual_size + )" -y "$( + sed 's/.*,//' /sys/class/graphics/fb0/virtual_size + )" } screencast() { - local x="$(sed 's/,.*//' /sys/class/graphics/fb0/virtual_size)" - local y="$(sed 's/.*,//' /sys/class/graphics/fb0/virtual_size)" - local video="$1" - - ffmpeg -video_size "${x}x${y}" -framerate 25 -f x11grab -i :0.0 \ - ~/${video:-screencast}.mp4 + ffmpeg -framerate 25 -f x11grab -i :0.0 -video_size "$( + sed 's/,.*//' /sys/class/graphics/fb0/virtual_size + )x$( + sed 's/.*,//' /sys/class/graphics/fb0/virtual_size + )" ~"/${1:-screencast}.mp4" } -# Startup -#_______________________________________________________________________________ - main() { if [ "$TERM" = 'linux' ]