tMerge branch 'master' of z3bra.org:scripts - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit abebf2eb87353469ebe8adb5e54dd89260936be0
 (DIR) parent d40620035f07e51240b341fb99e3951b8e904cdc
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Thu,  4 Sep 2014 21:23:20 +0200
       
       Merge branch 'master' of z3bra.org:scripts
       
       Diffstat:
         D backup                              |      43 ------------------------------
         M cdump                               |      20 ++++++++++----------
         M chan                                |      16 +++++++++++-----
         M cpuload                             |       3 ++-
         D deptree.sh                          |      47 -------------------------------
         M gamma                               |       4 ++--
         M hm                                  |       4 ++--
         M human                               |       6 +++---
         M imgurup                             |       2 +-
         M instagram                           |       2 +-
         M memory                              |       2 +-
         M mkbar                               |       2 +-
       
       12 files changed, 34 insertions(+), 117 deletions(-)
       ---
 (DIR) diff --git a/backup b/backup
       t@@ -1,43 +0,0 @@
       -#!/bin/bash
       -
       -##
       -## Backup the content of a directory in an other directory
       -#
       -
       -usage() {
       -    cat << EOF_HELP
       -    usage : $0 <source> [<destination>]
       -
       -    DESCRIPTION :
       -        Backup <source> in /backup/<destination>.
       -
       -    OUTPUT :
       -        The backup will be an archive named :
       -        <source>-<username>-<date>.tar.gz
       -
       -    PARAMETERS :
       -        <source>      : What you want to backup
       -        <destination> : (optional) use another directory than /backup/<username>
       -        --help        : Display this help
       -EOF_HELP
       -}
       -
       -if [[ $# -lt 1 || "$1" == "--help" || "$1" == "-h" ]]; then
       -    usage
       -    exit 0
       -fi
       -
       -DIR=$1
       -DEST=/backup
       -# NAME=$(echo $DIR | sed 's/\/$//' | sed 's/.*\///')
       -NAME=$(echo $DIR | sed 's#.*/\([^?./]*\)/$#\1#')
       -
       -if [ -n "$2" ]; then
       -    DEST=$DEST/$2
       -else
       -    DEST=$DEST/$USER
       -fi
       -
       -# Create a compressed archive with the same permission that the original directory
       -# untar with `tar xzf <archive>.tar.gz`
       -tar cpzf $DEST/$USER-$NAME-$(date +%y-%m-%d).tar.gz $DIR
 (DIR) diff --git a/cdump b/cdump
       t@@ -3,21 +3,21 @@
        FILE=$HOME/etc/Xresources
        FILE=$HOME/etc/theme/bow
        
       -for NUM in {0..7}; do
       +for NUM in $(seq 0 7); do
              CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
       -      echo -en "\e[0;3${NUM}m$CN\e[m "
       +      printf    "\e[0;3${NUM}m%s " $CN
        done
        echo
       -for NUM in {0..7}; do
       -      echo -en "\e[0;3${NUM}m▉▉▉▉▉▉▉\e[m "
       +for NUM in $(seq 0 7); do
       +      printf    "\e[0;3${NUM}m||||||| "
        done
        echo
       -for NUM in {0..7}; do
       -      echo -en "\e[1;3${NUM}m▉▉▉▉▉▉▉\e[m "
       +for NUM in $(seq 0 7); do
       +      printf    "\e[1;3${NUM}m||||||| "
        done
        echo
       -for NUM in {0..7}; do
       -    CN=$(grep "^\*color$((${NUM}+8)):" $FILE| cut -d':' -f2 | tr -d ' ')
       -    echo -en "\e[1;3${NUM}m$CN\e[m "
       +for NUM in $(seq 0 7); do
       +      CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
       +      printf    "\e[1;3${NUM}m%s " $CN
        done
       -echo
       +printf "\e[0m\n"
 (DIR) diff --git a/chan b/chan
       t@@ -1,4 +1,4 @@
       -#!/usr/bin/bash
       +#!/bin/sh
        
        ## ii directory
        ROOT=~/var/irc
       t@@ -15,8 +15,8 @@ usage() {
        EOF
        }
        
       -[[ -n "$1" ]] && CHAN=$1
       -[[ -n "$2" ]] && NICK=$2
       +test -n "$1" && CHAN=$1
       +test -n "$2" && NICK=$2
        
        while getopts ":hn:c:s:" opt; do
            case $opt in
       t@@ -35,12 +35,18 @@ JOIN="/j $CHAN hai $CHAN!"
        # spawn ii
        ii -i $ROOT -n $NICK -s $SERV -p $PORT &
        
       -while [ ! -p $ROOT/$SERV/in ];do echo awaiting connection to $SERV...; sleep 2; done
       +while [ ! -p $ROOT/$SERV/in ]; do
       +    echo awaiting connection to $SERV...;
       +    sleep 2;
       +done
        
        # launch commands at start
        echo "$JOIN" > $ROOT/$SERV/in
        
       -while [ ! -p $ROOT/$SERV/$CHAN/in ];do echo Starting chatting with $CHAN; sleep 1; done
       +while [ ! -p $ROOT/$SERV/$CHAN/in ]; do
       +    echo Starting chatting with $CHAN;
       +    sleep 1;
       +done
        
        cd $ROOT/$SERV/$CHAN
        tmux new-session -d -s irc 'tail -f out' \; split-window -l 1 'ptii' \; attach
 (DIR) diff --git a/cpuload b/cpuload
       t@@ -12,7 +12,8 @@ EOF
        
        cpuperc () {
            LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
       -    echo "`bc <<< $LINE`%"
       +
       +    echo "`echo $LINE | bc`%"
        }
        
        case $1 in
 (DIR) diff --git a/deptree.sh b/deptree.sh
       t@@ -1,47 +0,0 @@
       -#!/bin/bash
       -#
       -# (c) wtfpl by z3bra
       -# deptree; List dependencies that are installed ONLY for <packages>
       -
       -
       -test $# -ne 1 && echo "`basename $0 <package>`" && exit 1
       -
       -deplist=''
       -level=0
       -
       -# needless to bother with any f**king locale here
       -export LC_ALL=en_US
       -
       -indent() {
       -    for i in `seq 0 $1`; do
       -        echo -n '  '
       -    done
       -}
       -
       -dependent() {
       -    IFS=' ><=' read pkg version<<< "$1"
       -
       -    exec 2>/dev/null
       -    dep=`pacman -Qi $pkg | grep 'Required By' | sed 's/^.*: //'`
       -    opt=`pacman -Qi $pkg | grep 'Optional Deps' | sed 's/^.*: //'`
       -
       -    test "$dep" = "None" && echo $opt || echo $dep
       -}
       -
       -deplist() {
       -    IFS=' ><=' read pkg version<<< "$1"
       -
       -    exec 2>/dev/null
       -    pacman -Qi $pkg | grep 'Depends On' | sed 's/^.*: //' | grep -Ev 'None|--'
       -}
       -
       -listdep() {
       -    list=`deplist $1 | sed 's/[<>=]*[.0-9]*//g'`
       -
       -    for pkg in $list; do
       -        isdep=`dependent $pkg`
       -        test "$1" = "$isdep" && echo $pkg
       -    done
       -}
       -
       -listdep $1
 (DIR) diff --git a/gamma b/gamma
       t@@ -12,8 +12,8 @@ old=$gamma
        
        case $1 in
            get)  echo $gamma; exit ;;
       -    up)   gamma=`bc <<< "$gamma + $amount"` ;;
       -    down) gamma=`bc <<< "$gamma - $amount"` ;;
       +    up)   gamma=$( echo "$gamma + $amount" | bc) ;;
       +    down) gamma=$( echo "$gamma - $amount" | bc) ;;
            reset)gamma="1.000000" ;;
            *) usage && exit ;;
        esac
 (DIR) diff --git a/hm b/hm
       t@@ -88,8 +88,8 @@ check() {
            for dir in ${basedir}/* ; do
                for file in ${dir}/*; do
                    if diff $file ${cin} >/dev/null 2>&1; then
       -                echo -en "${fgd}`basename ${dir}`${nofg}/"
       -                echo -e  "${fgh}`basename ${file}`${nofg}"
       +                printf "${fgd}`basename ${dir}`${nofg}/"
       +                printf  "${fgh}`basename ${file}`${nofg}\n"
                        found=1
                    fi
                done
 (DIR) diff --git a/human b/human
       t@@ -4,7 +4,7 @@
        
        usage () {
            cat <<EOF
       -usage: $(basename $0) [-hfbmgt] <number>
       +usage: `basename $0` [-hfbmgt] <number>
            -h : print help
            -f : detect best factorisation to use (default)
            -b : force output in Bytes
       t@@ -43,7 +43,7 @@ humanize () {
                *) pow=0; unit= ;;
            esac
        
       -    num=`bc <<< "scale=${SCALE}; ${num} / (1024 ^ ${pow})"`
       +    num=`echo "scale=${SCALE}; ${num} / (1024 ^ ${pow})" | bc`
        
            echo "${num}${unit}"
        }
       t@@ -62,6 +62,6 @@ case $1 in
                test $# -lt 1 && usage && exit 1
        
        
       -         humanize $(factorize $1) $1
       +         humanize `factorize $1` $1
                 ;;
         esac
 (DIR) diff --git a/imgurup b/imgurup
       t@@ -25,7 +25,7 @@ for IMG in "$@"; do
            URL=$(echo $RESP | sed 's|.*<original_image>\(.*\)</original_image>.*|\1|')
            DELETEURL=$(echo $RESP | sed 's|.*<delete_page>\(.*\)</delete_page>.*|\1|')
        
       -    tee $LOG <<< "$URL" | $CLIP
       +    echo  $URL" | tee $LOG | $CLIP
            echo "$DELETEURL" >> $LOG
            echo "$URL"
        done
 (DIR) diff --git a/instagram b/instagram
       t@@ -1,4 +1,4 @@
       -#!/bin/sh
       +#!/bin/bash
        #
        # 2013 z3bra <willy at mailoo dot org>
        # INSTAGRAM - screenshot taker / manager
 (DIR) diff --git a/memory b/memory
       t@@ -1,4 +1,4 @@
       -#!/bin/sh
       +#!/bin/bash
        #
        # z3bra - (c) wtfpl 2014
        
 (DIR) diff --git a/mkbar b/mkbar
       t@@ -1,4 +1,4 @@
       -#!/bin/sh
       +#!/bin/bash
        #
        # z3bra - (c) wtfpl 2014
        # Fetch infos on your computer, and print them to stdout every second.