tfirst commit - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 22d96d4db3e5bdb2630ab011a213f16e9c256873
(HTM) Author: Willy Goiffon <w.goiffon@gmail.com>
Date: Tue, 28 May 2013 11:20:52 +0200
first commit
Diffstat:
A backup | 43 ++++++++++++++++++++++++++++++
A invaders | 39 +++++++++++++++++++++++++++++++
A statusline.sh | 29 +++++++++++++++++++++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/backup b/backup
t@@ -0,0 +1,43 @@
+#!/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/invaders b/invaders
t@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# ANSI color scheme script featuring Space Invaders
+#
+# Original: http://crunchbanglinux.org/forums/post/126921/#p126921
+# Modified by lolilolicon
+#
+
+f=3 b=4
+for j in f b; do
+ for i in {0..7}; do
+ printf -v $j$i %b "\e[${!j}${i}m"
+ done
+ done
+ bld=$'\e[1m'
+ rst=$'\e[0m'
+
+cat << EOF
+
+$f1 ▀▄ ▄▀ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4 ▀▄ ▄▀ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
+$f1 ▄█▀███▀█▄ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4 ▄█▀███▀█▄ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
+$f1█▀███████▀█ $f2▀▀███▀▀███▀▀ $f3▀█▀██▀█▀ $f4█▀███████▀█ $f5▀▀███▀▀███▀▀ $f6▀█▀██▀█▀$rst
+$f1▀ ▀▄▄ ▄▄▀ ▀ $f2 ▀█▄ ▀▀ ▄█▀ $f3▀▄ ▄▀ $f4▀ ▀▄▄ ▄▄▀ ▀ $f5 ▀█▄ ▀▀ ▄█▀ $f6▀▄ ▄▀$rst
+
+$bld$f1▄ ▀▄ ▄▀ ▄ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4▄ ▀▄ ▄▀ ▄ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
+$bld$f1█▄█▀███▀█▄█ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4█▄█▀███▀█▄█ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
+$bld$f1▀█████████▀ $f2▀▀▀██▀▀██▀▀▀ $f3▀▀█▀▀█▀▀ $f4▀█████████▀ $f5▀▀▀██▀▀██▀▀▀ $f6▀▀█▀▀█▀▀$rst
+$bld$f1 ▄▀ ▀▄ $f2▄▄▀▀ ▀▀ ▀▀▄▄ $f3▄▀▄▀▀▄▀▄ $f4 ▄▀ ▀▄ $f5▄▄▀▀ ▀▀ ▀▀▄▄ $f6▄▀▄▀▀▄▀▄$rst
+
+
+ $f7▌$rst
+
+ $f7▌$rst
+
+ $bld$f7 ▄█▄ $rst
+ $bld$f7▄█████████▄$rst
+ $bld$f7▀▀▀▀▀▀▀▀▀▀▀$rst
+
+EOF
(DIR) diff --git a/statusline.sh b/statusline.sh
t@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# status line for tmux.
+# prints out a line formatted for tmux status.
+
+
+w='#[fg=white,nobold]'
+B='#[fg=black,bold]'
+
+SEP="$w»$B"
+# SEP="$w>$B>$B"
+
+
+TEMP=$(acpi -t | awk '{print $4}')
+LOAD=$(uptime | sed 's/^.*average: \([^ ]*\),.*$/\1/')
+TIME=$(date "+%H:%M")
+DATE=$(date "+%a%d")
+
+ramused() {
+ ramtotal=$(free -m| sed -n '2p'| awk '{print $2}')
+ ramused=$(free -m| sed -n '3p'| awk '{print $3}')
+
+ ram_perc=$(((100*$ramused)/$ramtotal))
+ echo $ram_perc
+}
+
+
+echo "$B$(ramused)% $SEP $LOAD $SEP $TEMP°C $SEP $DATE $w$TIME"
+