dot

packages and services management
Log | Files | Refs | README

commit ce173dffc8c3167a403e5fc3eeed26a898d2347c
parent dfc4e7bf23948816cbfcad5a20b883453439ab36
Author: josuah <mail@josuah.net>
Date:   Sat,  8 Oct 2016 22:28:19 -0400

Reorganized the shell profile

Diffstat:
Aagenda/bin/agenda | 287+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbin/buffers | 8++++----
Abkm/bin/bkm | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbuild.sh | 19++++++++++---------
Afeeds/bin/feeds | 193+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlink.sh | 17++++++++++++++++-
Ashell/config/environment | 46++++++++++++++++++++++++++++++++++++++++++++++
Ashell/config/functions | 169+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dshell/pam_environment | 43-------------------------------------------
Mshell/profile | 222++++++++++---------------------------------------------------------------------
Atodo/bin/todo | 26++++++++++++++++++++++++++
Mzathura/config/zathurarc | 8++++----
12 files changed, 838 insertions(+), 256 deletions(-)

diff --git a/agenda/bin/agenda b/agenda/bin/agenda @@ -0,0 +1,287 @@ +#!/bin/sh +# | +# ,--. ,--, ,--. ---. .--| ,--. +# ,--| | | |--' | | | | ,--| +# `--` `--| `--' ' ' `--` `--` 2016-10-08 +#------`--'--------------------------------------------------------------------- +# Agenda from the command line + +AGENDA="${AGENDA-$HOME/.cache/agenda}" +COLUMNS="$(stty size | cut -d ' ' -f 2)" + +help="NAME + agenda - Agenda from the command line. + +SYNTAX + agenda COMMAND [-d DATE] [-i ICAL] + +DESCRIPTION + -d Set date to use + -i Import an ICAL to $AGENDA + a, agenda + for next event starting from DATE or today. + c, calendar + for current week and next events highlihted. + + +FILES + \$AGENDA: $AGENDA + File storing the agenda, with each entry on a line, and each + field separated by a tab, in this order: + + 1. Start date (yyyy-mm-dd HH:MM:SS) + 2. End date (yyyy-mm-dd HH:MM:SS) + 3. Name + 4. Location + 5. Description +" + + +# AWK SCRIPTS +# ------------------------------------------------------------------------------ + +awk_ical=' +BEGIN { + FS = ":"; +} + +/BEGIN:VEVENT/,/END:VEVENT/ { + if (substr($0, 1, 1) != " ") { + type = $1; + vevent[type] = $2; + } else + vevent[type] = vevent[type] substr($0, 2, length($0) - 1); + + if ($0 == "BEGIN:VEVENT") { + date = vevent["DTSTART"] + printf("%s-%s-%s %s:%s:%s\t", + substr(date, 1, 4), # Year + substr(date, 5, 2), # Month + substr(date, 7, 2), # Day + substr(date, 10, 2), # Hour + substr(date, 12, 2), # Minute + substr(date, 14, 2)); # Second + + date = vevent["DTEND"] + printf("%s-%s-%s %s:%s:%s\t", + substr(date, 1, 4), # Year + substr(date, 5, 2), # Month + substr(date, 7, 2), # Day + substr(date, 10, 2), # Hour + substr(date, 12, 2), # Minute + substr(date, 14, 2)); # Second + + printf("%s\t", vevent["SUMMARY"]); + printf("%s\t", vevent["LOCATION"]); + printf("%s\n", vevent["DESCRIPTION"]); + } +}' + +awk_agenda=' +BEGIN { + FS = "\t"; +} + +{ + "date +%s -d '\''"$1"'\''" | getline event_date; +} + +(now <= event_date) { + beg = $1; end = $2; sum = $3; loc = $4; des = $5; + + beg_Y = substr(beg, 1, 4); sub(/^0/, " ", beg_Y); + beg_m = substr(beg, 6, 2); sub(/^0/, " ", beg_m); + beg_d = substr(beg, 9, 2); sub(/^0/, " ", beg_d); + beg_R = substr(beg, 12, 5); sub(/^0/, " ", beg_R); + end_Y = substr(end, 1, 4); sub(/^0/, " ", end_Y); + end_m = substr(end, 6, 2); sub(/^0/, " ", end_m); + end_d = substr(end, 9, 2); sub(/^0/, " ", end_d); + end_R = substr(end, 12, 5); sub(/^0/, " ", end_R); + + sub(/^\\n/, "", des); + gsub(/\\n/, " - ", des); + gsub(/\\/, "", sum); gsub(/\\/, "", loc); gsub(/\\/, "", des); + + # Header line + if (last_beg_Y != beg_Y) { + printf("_%4s_________Summary__________________________________"\ + "Location____________________________________________" \ + "____________________________________________________" \ + "\n |\n", + beg_Y); + } + + # First line + if (last_beg_m != beg_m) {printf("%2s ", beg_m);} else {printf(" ");} + if (last_beg_d != beg_d) {printf("%2s ", beg_d);} else {printf(" ");} + + printf("%5s | %-40s %s\n", beg_R, sum, loc); + + # Second line + if (beg_m != end_m) {printf("%2s ", end_m);} else {printf(" ");} + if (beg_d != end_d) {printf("%2s ", end_d);} else {printf(" ");} + if (beg_R != end_R) {printf("%5s ", end_R);} else {printf(" ");} + + printf("|\033[30;1m %s", des); + + printf("\n\033[0m |\n"); + + last_beg_Y = beg_Y; + last_beg_m = beg_m; + last_beg_d = beg_d; +}' + +awk_calendar=' +BEGIN { + FS = "\t"; + + header = " "; + row[0] = " Mon "; + row[1] = " Tue "; + row[2] = " Wed "; + row[3] = " Thu "; + row[4] = " Fri "; + row[5] = " Sat "; + row[6] = " Sun "; + + # fill the empty days with spaces + for (i = 0; i < w; i++) + row[i] = row[i] " "; + + # month name offset + if (w == 0) offset = 0; + else offset = 1; + + # increase date for every day + for (j = 0; j <= range; j++) { + + # day of week + if ((j + w) % 7 == 0) { + offset++; + } + + if (d < 28 \ + || (d == 28 && m == 2 && Y % 4 == 0) \ + || (d < 30 && ((m <= 7 && m % 2 == 0) \ + || (m >= 8 && m % 2 == 1)) && m != 2) \ + || (d < 31 && ((m <= 7 && m % 2 == 1) \ + || (m >= 8 && m % 2 == 0)) && m != 2)) { + d++; + } else { + d = 1; + + if (m < 12) { + m++; + } else { + m = 1; Y++; + } + + if (m == 1) month = "Jan"; + else if (m == 2) month = "Feb"; + else if (m == 3) month = "Mar"; + else if (m == 4) month = "Apr"; + else if (m == 5) month = "May"; + else if (m == 6) month = "Jun"; + else if (m == 7) month = "Jul"; + else if (m == 8) month = "Aug"; + else if (m == 9) month = "Sep"; + else if (m == 10) month = "Oct"; + else if (m == 11) month = "Nov"; + else if (m == 12) month = "Dec"; + + header = sprintf("%s%" offset * 3 - 3 "s%s", \ + header, "", month); + offset = 0; + } + + date = sprintf("%04d-%02d-%02d", Y, m, d); + + # while event end is in the past, get next event if any + while (substr($2, 0, 10) < date) + if (! getline) break; + + # add a leading space + row[(j + w) % 7] = row[(j + w) % 7] " "; + + # if it begins in the past and ends in the future + if (substr($1, 0, 10) <= date && date <= substr($2, 0, 10)) + row[(j + w) % 7] = row[(j + w) % 7] "\033[7m"; + + # current day + if (date == today) + row[(j + w) % 7] = row[(j + w) % 7] "\033[31;1m"; + + # day number + row[(j + w) % 7] = row[(j + w) % 7] sprintf("%2s\033[0m", d); + } + + print header; + for (i = 0; i <= 6; i++) { + print row[i]; + } +}' + + +# FUNCTIONS +# ------------------------------------------------------------------------------ + +import_ical() +{ + local ical="$1" + + sed -i 's/\r//; s/\t/ /g' "$ical" + awk "$awk_ical" "$ical" | cat - "$AGENDA" | sort | uniq > "$AGENDA" +} + +agenda() +{ + awk -v now="$SEC" "$awk_agenda" "$AGENDA" | cut -c 1-"$COLUMNS" +} + +calendar() +{ + awk \ + -v Y="$(date +'%Y' -d "@$SEC")" \ + -v m="$(date +'%m' -d "@$SEC")" \ + -v d="$(date +'%d' -d "@$SEC")" \ + -v w="$(date +'%w' -d "@$SEC")" \ + -v now="$(date +'%Y-%m-%d' -d "@$SEC")" \ + -v range="$(($COLUMNS * 7 / 3 - 26))" \ + "$awk_calendar" "$AGENDA" +} + + +# ALGORYTHM +# ------------------------------------------------------------------------------ + +[ $# = 0 ] && set -- help +while [ $# -gt 0 ] +do + case $1 in + a | agenda) + action="agenda" + shift + ;; + c | calendar) + action="calendar" + shift + ;; + -i ) + action="import_ical $2" + shift 2 + ;; + -d ) + DATE="$2" + + shift 2 + ;; + * ) + printf '%s\n' "$help" + exit 0 + ;; + esac + + [ "$DATE" ] && SEC="$(date +%s -d "$DATE")" || SEC="$(date +%s)" +done + +$action diff --git a/bin/buffers b/bin/buffers @@ -1,8 +1,8 @@ #/bin/sh -# | ,-- ,-- -# |--. , , |- |- ,--. .,-- ,--- -# | | | | | | |--' | `--. -# '--' `--` ' ' `--' ' ---' 2016-10-07 +# ---. ,-- ,-- +# |__/ , , |- |- ,--. .,-- ,--- +# | \ | | | | |--' | `--. +# ---' `--` ' ' `--' ' ---' 2016-10-08 #------------------------------------------------------------------------------- # Run commands in detachable buffers # diff --git a/bkm/bin/bkm b/bkm/bin/bkm @@ -0,0 +1,56 @@ +#!/bin/sh +# | | +# |--. | / --.-. +# | | |-< | | | +# '--' ' ` ' ' ' 2016-10-08 +#------------------------------------------------------------------------------- +# Tiny shell bookmark manager + +BOOKMARKS="${BKM:-$HOME/.cache/bkm}" + +if [ "$#" -eq 0 ] +then + url="$(fzf < $BOOKMARKS)" + [ "${url##* }" ] && TERM=screen $BROWSER "${url##* }" + + printf '\n\n\n\n\n\n\n' + exit 0 +fi + +printf 'url: '; read url +printf 'description: '; read description +tag="$( + sed -r 's/^([^ ]*).*/\1/' "$BOOKMARKS" | uniq | fzf | tr '[a-z]' '[A-Z]' +)" + +printf '%s %s %s\n' "$tag" "$description" "$url" >> "$BOOKMARKS" + +bookmarks="$( + awk 'BEGIN{ + max1=0; + max2=0; + } + + { + l++; + + c1[l] = $1; # First column + + for (i=2; i < NF; i++) { # Middle column + c2[l] = c2[l]$(i)(i<NF?OFS:""); + } + + c3[l] = $NF; # Last column + + max1 = ((length(c1[l]) > max1) ? length(c1[l]) : max1); + max2 = ((length(c2[l]) > max2) ? length(c2[l]) : max2); + } + + END { + for (i = 1; i <= l; i++) { + printf("%-"max1"s %-"max2"s %s\n", c1[i], c2[i], c3[i]); + } + }' "$BOOKMARKS" | sort +)" + +[ "$bookmarks" ] && printf '%s\n' "$bookmarks" > "$BOOKMARKS" diff --git a/build.sh b/build.sh @@ -1,7 +1,8 @@ #!/bin/sh -# ,--- .,-- ,--. -# `--. | | -# ---' ' `--' 2016-10-07 +# ---. * | | +# |__/ , , , | .--| +# | \ | | | | | | +# ---' `--` ' ' `--` 2016-10-08 #------------------------------------------------------------------------------- # Install sources using crux-like package declaration. @@ -41,13 +42,13 @@ FILES - Optionnaly a \"build\" function building it in \$PREFIX. PACKAGES" - ls "$CONFIG" | while read name + find "$CONFIG/build" -type f | while read file do - if [ -f "$CONFIG/$name/build.sh" ] - then - printf '\t%-14s ' "$name" - sed '1 {s/^# //; q}' "$CONFIG/$name/build.sh" - fi + name="${file#$CONFIG/build/}" + name="${name%.sh}" + + printf '\t%-14s ' "$name" + sed '1 {s/^# //; q}' "$file" done exit 0 } diff --git a/feeds/bin/feeds b/feeds/bin/feeds @@ -0,0 +1,193 @@ +#!/bin/sh +# ,-- | +# |- ,--. ,--. .--| ,--- +# | |--' |--' | | `--. +# ' `--' `--' `--` ---' 2016-10-07 +#------------------------------------------------------------------------------- +# Simple RSS/ATOM feed reader + +FEEDS="${FEEDS-$HOME/.config/feeds}" +BROWSER="${BROWSER-firefox}" +CACHE="${CACHE-$HOME/.cache/feeds}" + +help=" +NAME + feeds - Simple RSS/ATOM fead reader + +SYNTAX + feeds COMMAND + +DESCRIPTION + view Choose a feed to read in $BROWSER + get Get/Update the feeds and the read/unread marks. + +ENVIRONMENT + FEEDS Path to the directory of feeds (./urls) and read (./read) list. + BROWSER Command to open the url of the feeds. + CACHE Path to the cache directory. + +FILES + $FEEDS/urls + List of RSS/ATOM urls, one link per line. + + $FEEDS/read + List of links already opened. + + $CACHE/* + Content of the RSS/ATOM files parsed by the rss.awk or atom.awk. + +" + + +# SCRIPTS +#-------------------------------------------------------------------------------- + +awk_format_columns=' +BEGIN{ + max1=0; + max2=0; +} + +{ + l++; + + c1[l] = $1; # First column + + for (i=2; i < NF; i++) { # Middle column + c2[l] = c2[l]$(i)(i<NF?OFS:""); + } + + c3[l] = $NF; # Last column + + max1 = ((length(c1[l]) > max1) ? length(c1[l]) : max1); + max2 = ((length(c2[l]) > max2) ? length(c2[l]) : max2); +} + +END { + for (i = 1; i <= l; i++) { + printf("%-"max1"s %-"max2"s %s\n", c1[i], c2[i], c3[i]); + } +}' + +# FUNCTIONS +#-------------------------------------------------------------------------------- + +# +# Check if feeds have been seen, and add a 'N' to the beginning of the line if +# so, and a '-' if not. Read stdin and print stdout. +# +check_read() +{ + while read line + do + read=0 + url="$(printf '%s' "$line" | awk '{ print $NF }')" + + if [ -z "$(grep -F "$url" "$FEEDS/read")" ] + then + printf '%s\n' "N $line" + else + printf '%s\n' "- $line" + fi + done +} + +# +# Check if the feed is RSS or ATOM, and transforms it in a list. +# +parse() +{ + local content="$1" + + if [ ! -z "$(printf '%s' "$content" | sed -n '/<rss[^>]*>/ p' )" ] + then RS='<[/]?item[^>]*>' ; begin='.*<link[^>]>'; end='<\/link>.*' + else RS='<[/]?entry[^>]*>'; begin='.*href=\42' ; end='\42.*' + fi + + printf '%s' "$content" | awk -v RS="$RS" ' +BEGIN { + max1=0; + max2=0; +} + +NR > 1 && NR < $(NR-1) { + title = $0 + sub(/.*<title[^>]*>/, "", title) + sub(/<\/title>.*/, "", title) + + url = $0 + sub(/'"$begin"'/, "", url) + sub(/'"$end"'/, "", url) + + printf("%s %s\n", title, url) +}' +} + +# +# Download each URL from $FEEDS/urls, parse them, check for read/unread, and +# store the generated list in $FEEDS/feeds/$title. +# +get() +{ + sed -r '/^(#.*)?$/ d' "$FEEDS/urls" | while read feed + do + content="$(wget -qO - $feed)" + title="$(printf '%s' "$content" \ + | sed 's/<\/title>.*//' \ + | sed -n 's/.*<title[^>]*>// p' \ + | sed 1q \ + | tr ' [A-Z]' '_[a-z]' \ + | tr -cd '[a-z][1-9_.,-]')" + printf '%s\n' "$title" + + parse "$content" | check_read | awk "$awk_format_columns" \ + > "$CACHE/$title" + done +} + +# +# List and pompt the feed for displaying articles. +# +view() +{ + tempfile="$(mktemp)" + + for feed in $(ls "$CACHE") + do + # count number of unread items + printf '%4s %s\n' \ + "$(sed -n '/^N / p' "$CACHE/$feed" | wc -l)" \ + "$feed" >> "$tempfile" + + # update the read/unread marks + printf '%s' "$(cat "$CACHE/$feed" \ + | cut -c 3- \ + | check_read)" > "$CACHE/$feed" + done + + sort -ro "$tempfile" "$tempfile" + + selection="$(cat "$CACHE/$(cat "$tempfile" \ + | fzf \ + | sed 's/ *[0-9]* //')" \ + | fzf \ + | awk '{ print $NF }')" + + rm "$tempfile" + + printf '%s\n' "$selection" >> "$FEEDS/read" + + $BROWSER "$selection" +} + +#===[ ALGORYTHM ]=============================================================== + +[ ! -d "$CACHE" ] && mkdir -p "$CACHE" +touch "$FEEDS/read" +touch "$FEEDS/urls" + +case $1 in + g | get ) get;; + v | view ) view;; + * ) printf '%s\n' "$help" +esac diff --git a/link.sh b/link.sh @@ -1,10 +1,11 @@ # , * | # | , ---. | , # | | | | |-< -# '--- ' ' ' ' ` +# '--- ' ' ' ' ` 2016-10-08 #------------------------------------------------------------------------------- CONFIG="${CONFIG:-$HOME/Config}" +LOCAL="${LOCAL:-$LOCAL}" # # Link config files that follow xdg @@ -48,3 +49,17 @@ do mkdir -p "$(dirname "$destination")" ln -sf "$path" "$destination" done + +# +# Link embedded executables +# +mkdir -p "$LOCAL/bin" + +find "$CONFIG" -type f -path '*/bin/*' \ +| while read path +do + file="${path##*/}" + destination="$LOCAL/bin/$file" + + ln -sf "$path" "$destination" +done diff --git a/shell/config/environment b/shell/config/environment @@ -0,0 +1,46 @@ +# ---- * | +# |__ ---. . , , .,-- ,--. ---. --.-. ,--. ---. |-- +# | | | \ / | | | | | | | | | |--" | | | +# ---- " " " " " `--" " " " " " `--" " " " +# ------------------------------------------------------------------------------ +# Environment variables. +# +# The right place would have been '.pam_environment', but setting the PATH +# here is not supported by Debian, that consider that it would be a +# security risk. + +export EMAIL="mail@josuah.net" + + +# COMMANDS +#------------------------------------------------------------------------------- + +export EDITOR="vim" +export ALTERNATE_EDITOR="vi" +export VISUAL="${EDITOR}" +export FCEDIT="${EDITOR}" +export PAGER="more" # Within tmux, less useless +export FILTER="peax" # Like fzy, fzf, dmenu... + + +# DIRECTORIES +#------------------------------------------------------------------------------- + +export MAIL="${HOME}/Mail/INBOX" +export CONFIG="${HOME}/Config" +export LOCAL="${HOME}/.local" +export ENV="${HOME}/.profile" +export XDG_CONFIG_HOME="${HOME}/.config" # If it is not set by default. +export XDG_CACHE_HOME="${HOME}/.cache" +export XDG_DATA_HOME="${HOME}/.local/share" +export ABDUCO_SOCKET_DIR="${XDG_CACHE_HOME}/" # With a trailing backslash. + + +# PATHS +#------------------------------------------------------------------------------- + +export PATH="${LOCAL}/bin:${CONFIG}/bin:${PATH}" +export MANPATH="${LOCAL}/share/man:${LOCAL}/man:${MANPATH}" +export CPATH="${LOCAL}/include:${CPATH}" +export LD_LIBRARY_PATH="${LOCAL}/lib:${LD_LIBRARY_PATH}" +export LD_RUN_PATH="${LOCAL}/lib:${LD_LIBRARY_PATH}" diff --git a/shell/config/functions b/shell/config/functions @@ -0,0 +1,169 @@ +# ---- | * +# |__ , , ---. ,--. |-- , ,--. ---. ,--- +# | | | | | | | | | | | | `--. +# ' `--` ' ' `--' ' ' `--' ' ' ---' 2016-10-08 +#------------------------------------------------------------------------------- +# Shell-agnostic functions for interactive use. + + +# APPEARANCE +#------------------------------------------------------------------------------- + +theme() +{ + printf "$(printf %s "$THEMES" | sed -n "/${1-$( + printf '%s' "$THEMES" | sed 's/ .*$//' | fzf --margin=10,20 + )}/ s/P/\\\\033]P/g p")" + + clear +} + +color() +{ + for in in in in + do + for i in 1 2 3 4 5 6 7 + do printf ' \033[3%sm██\033[1mâ–ˆ\033[0m\033[3%sm██' $i $i + done + printf '\n' + done + +} + + +# MANAGE PROJECTS +#------------------------------------------------------------------------------- + +gitall() +{ + find "$HOME" -name '.git' -type d | while read git + do + git="${git%/*}" + printf '\n\n\033[1m%s\033[0m\n' "~${git#$HOME}" + cd "$git" + git status --porcelain + cd "$HOME" + done +} + +buildit() +{ + [ -f './autogen.sh' ] && ./autogen.sh + [ -f './configure' ] && ./configure --prefix="$PREFIX" + make && make clean PREFIX=$PREFIX install clean +} + +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';; + esac +} + + +# INTERACTION +#------------------------------------------------------------------------------- + +h() +{ + for field in $@; do local cmd="$cmd $field"; done + tmp="$(mktemp)" + eval "$cmd 2>&1 | tee "$tmp" | $PAGER" + tee < "$tmp" +} + +weather() +{ + curl -4 "wttr.in/$1" +} + + +# RENAMING FILES +#------------------------------------------------------------------------------- + +# +# Remove spaces and other nasty characters from $1, recursively +# +sanitize() +{ + find . -mindepth 1 | tac | while IFS= read -r p + do mv "$p" "${p%/*}/$(printf %s "${p##*/}" \ + | sed 's/[^[:alnum:],._/+-]/_/g' + )" + done +} + +# +# Transform a separator ($1) into '/': directory and subdirectory +# +split_at() +{ + find . | while read -r f + do + mkdir -p "${f%%$1*}" + mv "$f" "${f%%$1*}/${f#*$1}" + done +} + +# +# Remove prefix from all files in current directory up to "$1" separator +# +remove_prefix() +{ + find . | while read -r f + do mv "$f" "${f#*$1}" + done +} + +# +# FrameBuffer Video player based on mplayer +# +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" +} + + +# HARDWARE +#------------------------------------------------------------------------------- + +light() +{ + printf '%s\n' "$1" | sudo tee "$( + sudo find -L /sys/class/backlight/ -maxdepth 2 -name brightness + )" +} + +mnt() +{ + sudo mount -o uid=$USER -o rw "${1-/dev/sdb1}" "${2-/mnt}" +} + +rotate() +{ + case "$1" in + u | up ) printf 0 ;; + r | right ) printf 1 ;; + d | down ) printf 2 ;; + l | left ) printf 3 ;; + esac | sudo tee /sys/class/graphics/fbcon/rotate_all > /dev/null +} diff --git a/shell/pam_environment b/shell/pam_environment @@ -1,43 +0,0 @@ -# ---- * | -# | ---. . , , .,-- ,--. ---. --.-. ,--. ---. |-- -# |-- | | \ / | | | | | | | | | |--' | | | -# | ' ' ' ' ' `--' ' ' ' ' ' `--' ' ' ' 2016-10-08 -# ---- ------------------------------------------------------------------------- -# Environment variables put at the right place - -EMAIL OVERRIDE="mail@josuah.net" - - -# COMMANDS -#------------------------------------------------------------------------------- - -EDITOR OVERRIDE=vim -ALTERNATE_EDITOR OVERRIDE=vi -VISUAL OVERRIDE=${EDITOR} -FCEDIT OVERRIDE=${EDITOR} -PAGER OVERRIDE="less -Ri" -BROWSER OVERRIDE=w3m -FILTER OVERRIDE=peax - - -# DIRECTORIES -#------------------------------------------------------------------------------- - -MAIL OVERRIDE=@{HOME}/Mail/INBOX -CONFIG OVERRIDE=@{HOME}/Config -LOCAL OVERRIDE=@{HOME}/.local -ENV OVERRIDE=@{HOME}/.profile -XDG_CONFIG_HOME OVERRIDE=@{HOME}/.config -XDG_CACHE_HOME OVERRIDE=@{HOME}/.cache -XDG_DATA_HOME OVERRIDE=@{HOME}/.local/share -ABDUCO_SOCKET_DIR OVERRIDE=${XDG_CACHE_HOME}/ - - -# PATHS -#------------------------------------------------------------------------------- - -PATH OVERRIDE=${LOCAL}/bin:${CONFIG}/bin:${PATH} -MANPATH OVERRIDE=${LOCAL}/share/man:${LOCAL}/man:${MANPATH} -CPATH OVERRIDE=${LOCAL}/include:${CPATH} -LD_LIBRARY_PATH OVERRIDE=${LOCAL}/lib:${LD_LIBRARY_PATH} -LD_RUN_PATH OVERRIDE=${LOCAL}/lib:${LD_LIBRARY_PATH} diff --git a/shell/profile b/shell/profile @@ -1,27 +1,18 @@ -#!/bin/sh # ---. ,-- * | -# | | .,-- ,--. |- , | ,--. -# |--' | | | | | | |--' -# | ' `--' ' ' ' `--' 2016-10-05 -# ' ---------------------------------------------------------------------------- +# |__' .,-- ,--. |- , | ,--. +# | | | | | | | |--' +# ' ' `--' ' ' ' `--' 2016-10-08 +#------------------------------------------------------------------------------- # Shell configuration for any shell (dash, zsh, mksh, bash, busybox's ash...) +# Source other parts of shell configuration +. ~/.config/shell/environment +. ~/.config/shell/functions + # VARIABLES #------------------------------------------------------------------------------- -# Parse and merge ~/.pam_environment -IFS=' -' -for variable in $(sed -r ' - /^ *(#.*|\s*)$/ d # Remove comments and empty lines - s/@/$/g # Convert variable notation. - s/ *([^ ]*) *[^ ]*=/\1=/ # Remove aditionnal pam keywords. -' ~/.pam_environment) -do eval "$variable" -done -unset IFS - # Black Red Green Yellow Blue Purple Cyan White THEMES="\ solarized_light \ @@ -61,35 +52,10 @@ P0191d1b P19C6363 P260b48a P3dfaf8f P4506070 P5dc8cc3 P68cd0d3 P7dcdccc\ P8709080 P9dca3a3 PAbfebbf PBf0dfaf PC94bff3 PDec93d3 PE93e0e3 PFffffff\ " -# Prompt -export PS1='$(ps1)' -export PS2='| ' - -# ALIAS 2016-10-05 +# PROMPT #------------------------------------------------------------------------------- -alias l='ls -F -w 80 --color' -alias ll='l -lh' -alias la='l -A' -alias lla='l -Alh' -alias v='$VISUAL' -alias p='$PAGER' -alias t='tmux attach &>/dev/null || tmux new' -alias f='find . -type f ! -path "*/.git/*" | fzf --margin=3,6' -alias d='find . -type d ! -path "*/.git/*" | fzf --margin=3,6' -alias c='cd "$(find . -maxdepth 4 -mindepth 1 -type d | fzf --margin=3,6)"' -alias g='grep --color=always' -alias myip='curl icanhazip.com' -alias lines='find . -name "*.[ch]" | xargs wc -l' - - -# FUNCTIONS 2016-10-05 -#------------------------------------------------------------------------------- - - -# APPEARANCE - ps1() { code="$?" @@ -102,163 +68,29 @@ ps1() [ "$TMUX" ] && tmux refresh-client -S } -theme() -{ - printf "$(printf %s "$THEMES" | sed -n "/${1-$( - printf '%s' "$THEMES" | sed 's/ .*$//' | fzf --margin=10,20 - )}/ s/P/\\\\033]P/g p")" - - clear -} - -color() -{ - for in in in in - do - for i in 1 2 3 4 5 6 7 - do printf ' \033[3%sm██\033[1mâ–ˆ\033[0m\033[3%sm██' $i $i - done - printf '\n' - done - -} - - -# MANAGE PROJECTS - -gitall() -{ - find "$HOME" -name '.git' -type d | while read git - do - git="${git%/*}" - printf '\n\n\033[1m%s\033[0m\n' "~${git#$HOME}" - cd "$git" - git status --porcelain - cd "$HOME" - done -} - -buildit() -{ - [ -f './autogen.sh' ] && ./autogen.sh - [ -f './configure' ] && ./configure --prefix="$PREFIX" - make && make clean PREFIX=$PREFIX install clean -} - -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';; - esac -} - - -# INTERACTION - -h() -{ - for field in $@; do local cmd="$cmd $field"; done - tmp="$(mktemp)" - eval "$cmd 2>&1 | tee "$tmp" | $PAGER" - tee < "$tmp" -} - -weather() -{ - curl -4 "wttr.in/$1" -} - - -# RENAMING FILES - -# -# Remove spaces and other nasty characters from $1, recursively -# -sanitize() -{ - find . -mindepth 1 | tac | while IFS= read -r p - do mv "$p" "${p%/*}/$(printf %s "${p##*/}" \ - | sed 's/[^[:alnum:],._/+-]/_/g' - )" - done -} - -# -# Transform a separator ($1) into '/': directory and subdirectory -# -split_at() -{ - find . | while read -r f - do - mkdir -p "${f%%$1*}" - mv "$f" "${f%%$1*}/${f#*$1}" - done -} - -# -# Remove prefix from all files in current directory up to "$1" separator -# -remove_prefix() -{ - find . | while read -r f - do mv "$f" "${f#*$1}" - done -} - -# -# FrameBuffer Video player based on mplayer -# -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" -} - - -# HARDWARE +export PS1='$(ps1)' +export PS2='│ ' -light() -{ - printf '%s\n' "$1" | sudo tee "$( - sudo find -L /sys/class/backlight/ -maxdepth 2 -name brightness - )" -} -mnt() -{ - sudo mount -o uid=$USER -o rw "${1-/dev/sdb1}" "${2-/mnt}" -} +# ALIAS +#------------------------------------------------------------------------------- -rotate() -{ - case "$1" in - u | up ) printf 0 ;; - r | right ) printf 1 ;; - d | down ) printf 2 ;; - l | left ) printf 3 ;; - esac | sudo tee /sys/class/graphics/fbcon/rotate_all > /dev/null -} +alias l='ls -F -w 80 --color' +alias ll='l -lh' +alias la='l -A' +alias lla='l -Alh' +alias v='$VISUAL' +alias p='$PAGER' +alias t='tmux attach &>/dev/null || tmux new' +alias f='find . -type f ! -path "*/.git/*" | fzf --margin=3,6' +alias d='find . -type d ! -path "*/.git/*" | fzf --margin=3,6' +alias c='cd "$(find . -maxdepth 4 -mindepth 1 -type d | fzf --margin=3,6)"' +alias g='grep --color=always' +alias myip='curl icanhazip.com' +alias lines='find . -name "*.[ch]" | xargs wc -l' -# STARTUP 2016-10-05 +# STARTUP #------------------------------------------------------------------------------- [ "$TERM" = 'linux' ] && theme gruvbox diff --git a/todo/bin/todo b/todo/bin/todo @@ -0,0 +1,26 @@ +#!/bin/sh +# | | +# |-- ,--. .--| ,--. +# | | | | | | | +# ' `--' `--` `--' 2016-10-08 +#------------------------------------------------------------------------------- +# Small todo list implementation + +todo="$HOME/.cache/todo" t='' cmd='' + +if [ "$1" = e ]; then $EDITOR "$todo"; return 0; fi + +case "$1" in +-d ) shift + for n in $@; do cmd="$n d; $cmd"; done + sed "$cmd" -i "$todo" + ;; +'' ) + ;; +* ) + for w in $@; do t="$t $w"; done + printf '%s\n' "${t# }" >> "$todo" + ;; +esac + +sed '=' "$todo" | sed 'N; s/\n/\t/' diff --git a/zathura/config/zathurarc b/zathura/config/zathurarc @@ -1,7 +1,7 @@ -# | | -# ---, ,--. |-- |--. , , .,-- ,--. .,-- ,--. -# ,' ,--| | | | | | | ,--| | | -# '--- `--` ' ' ' `--` ' `--` ' `--' 2016-10-08 +# ---, | | +# / ,--. |-- |--. , , .,-- ,--. +# / ,--| | | | | | | ,--| +# '--- `--` ' ' ' `--` ' `--` 2016-10-08 #------------------------------------------------------------------------------- set recolor true