浏览代码

Scripts en vrac

David Marec 10 月之前
父节点
当前提交
44cdde731d
共有 10 个文件被更改,包括 355 次插入0 次删除
  1. 138 0
      dot.zshrc
  2. 8 0
      vrac/nestX.sh
  3. 2 0
      vrac/recording
  4. 57 0
      vrac/rename.sh
  5. 10 0
      vrac/ripping.sh
  6. 2 0
      vrac/unpinrox.sh
  7. 10 0
      vrac/utf8.sh
  8. 63 0
      vrac/vmstat.pl
  9. 48 0
      vrac/vmstatm.pl
  10. 17 0
      vrac/withinajail.sh

+ 138 - 0
dot.zshrc

@@ -0,0 +1,138 @@
+
+# The following lines were added by compinstall
+
+zstyle ':completion:*' completer _complete _ignored
+zstyle :compinstall filename '/home/david/.zshrc'
+
+autoload -Uz compinit
+compinit
+# End of lines added by compinstall
+# Lines configured by zsh-newuser-install
+HISTFILE=~/.histfile
+HISTSIZE=100
+SAVEHIST=100
+setopt autocd extendedglob notify
+setopt EXTENDED_HISTORY      # Write the history file in the ':start:elapsed;command' format.
+#setopt INC_APPEND_HISTORY    # Write to the history file immediately, not when the shell exits.
+setopt SHARE_HISTORY         # Share history between all sessions.
+setopt HIST_IGNORE_DUPS      # Do not record an event that was just recorded again.
+setopt HIST_IGNORE_ALL_DUPS  # Delete an old recorded event if a new event is a duplicate.
+setopt HIST_IGNORE_SPACE     # Do not record an event starting with a space.
+setopt HIST_SAVE_NO_DUPS     # Do not write a duplicate event to the history file.
+setopt HIST_VERIFY           # Do not execute immediately upon history expansion.
+setopt APPEND_HISTORY        # append to history file (Default)
+setopt HIST_NO_STORE         # Don't store history commands
+setopt HIST_REDUCE_BLANKS    # Remove superfluous blanks from each command line being added to the history.
+unsetopt beep nomatch
+# End of lines configured by zsh-newuser-install
+#
+
+zstyle ':completion:*' completer _expand _complete _correct _approximate _history
+zstyle ':completion:*' matcher-list '' '' 'l:|=* r:|=*' 'l:|=* r:|=*'
+zstyle ':completion:*' list-colors ''
+zstyle ':completion:*' users root
+zstyle ':completion:*' menu select
+zstyle :compinstall filename '~/.zshrc'
+autoload -Uz compinit
+autoload -U colors && colors   compinit
+setopt auto_menu
+
+export LSCOLORS='exExcxdxcxexhxhxhxbxhx'
+export LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32'
+alias ls='ls -G'
+alias la='ls -A'
+alias ll='ls -l'
+alias solarized='export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD'
+alias basiccolor='export LSCOLORS= CxGxGgFxBxgefxBHxfdead'
+
+export TZ=Europe/Paris
+export GREP_COLOR='1;32'
+export GREP_COLORS='1;32'
+export GREP_OPTIONS='--color=auto'
+alias grep='grep --color'
+alias egrep='egrep --color'
+alias tounafon='mixer vol 100:100 pcm 100:100'
+alias shutup="service musicpd stop"
+alias vidoc='vim -c "set fileencoding=latin1"'
+alias getmails='imapfilter && mutt'
+alias ridetheflume='echo -n "password:" && irssi -c irc.freenode.org -n TurtleCrazy -w $<'
+alias thereisnoneedtoshout='musicpd && ncmpc'
+alias mycodes='openssl enc -bf -pbkdf2 -in ~/Dossiers/codes/Codes.enc -d -a | grep \!:1'
+alias listcodes='openssl enc -bf -pbkdf2 -in ~/Dossiers/codes/Codes.enc -d -a' 
+alias meteo='curl -4 wttr.in/toulouse'
+alias sante='finger status@popeye.lapinbilly.eu'
+
+
+bindkey '^[[A' up-line-or-search
+bindkey '^[[B' down-line-or-search
+bindkey "^R" history-incremental-search-backward
+
+bindkey "^A" beginning-of-line
+bindkey "^E" end-of-line 
+case "${TERM}" in
+	(cons25*|linux)	# PLAIN BSD/LINUX CONSOLE
+		bindkey '\e[H'    beginning-of-line   # HOME
+		bindkey '\e[F'    end-of-line         # END
+		bindkey '\e[5~'   delete-char         # DELETE
+		bindkey '[D'      emacs-backward-word # ESC+LEFT
+		bindkey '[C'      emacs-forward-word  # ESC+RIGHT
+		;;
+	(*rxvt*)       # RXVT DERIVATIVES
+		precmd () { print -Pn "\e]0;%T %n@%m %c\a" }
+		bindkey '\e[3~'   delete-char         # DELETE
+		bindkey '\eOc'    forward-word        # CTRL+RIGHT
+		bindkey '\eOd'    backward-word       # CTRL+LEFT
+		# RXVT WORKAROUND FOR screen(1) UNDER urxvt(1)
+		bindkey '\e[7~'   beginning-of-line   # HOME
+		bindkey '\e[8~'   end-of-line         # END 
+		bindkey '^[[1~'   beginning-of-line   # HOME
+		bindkey '^[[4~'   end-of-line         # END
+		;;
+	(*xterm*)       # XTERM DERIVATIVES
+		precmd () { print -Pn "\e]0;%T %n@%m %c\a" }
+		bindkey '\e[H'    beginning-of-line   # HOME
+		bindkey '\e[F'    end-of-line         # END
+		bindkey '\e[3~'   delete-char         # DELETE
+		bindkey '\e[1;5C' forward-word        # CTRL+RIGHT
+		bindkey '\e[1;5D' backward-word       # CTRL+LEFT
+		# XTERM WORKAROUND FOR screen(1) UNDER xterm(1)
+		bindkey '\e[1~'   beginning-of-line   # HOME
+		bindkey '\e[4~'   end-of-line         # END
+		;;
+	(screen)       # GNU SCREEN
+		bindkey '^[[1~'   beginning-of-line   # HOME
+		bindkey '^[[4~'   end-of-line         # END
+		bindkey '\e[3~'   delete-char         # DELETE
+		bindkey '\eOc'    forward-word        # CTRL+RIGHT
+
+		bindkey '\eOd'    backward-word       # CTRL+LEFT
+		bindkey '^[[1;5C' forward-word        # CTRL+RIGHT
+		bindkey '^[[1;5D' backward-word       # CTRL+LEFT
+		;;
+esac
+
+#if [ -n "${SSH_AGENT_PID}" ]; then
+#	echo "SSH session: ${SSH_AGENT_PID} / ${SSH_AUTH_SOCK}"
+#	ssh-add ${HOME}/.ssh/llanura
+#fi
+
+# [ "${TTY}" = "/dev/ttyv1" ] && exec top -s1
+
+# COLOR PROMPT
+cSRV="%F{magenta}"
+cUSR="%F{green}%B"
+cPMT=""
+cTIM="%F{cyan}%B"
+cPWD="%F{magenta}%B"
+cSTD="%b%f"
+export PS1="$cSRV%m$cSTD $cUSR%n$cSTD $cPWD%~$cSTD $cPMT%#$cSTD "
+export PS2="$cSTD $cUSR>$cSTD $cPWD"
+
+export EDITOR=vim
+export PAGER=less
+export BLOCKSIZE=K
+export NNTPSERVER=news.gegeweb.org
+
+export EMAIL=david@dmarec.fr
+export VISUAL=${EDITOR}
+

+ 8 - 0
vrac/nestX.sh

@@ -0,0 +1,8 @@
+#! /bin/sh
+Xephyr -ac -screen 1280x1024 -br -reset :1&
+export DISPLAY=:1.0
+#start-lumina-desktop
+enlightenment_start
+pkill Xephyr 
+
+

+ 2 - 0
vrac/recording

@@ -0,0 +1,2 @@
+#!/bin/sh
+cdrecord -v speed=1 dev=0,0 -dao -useinfo -audio -pad myCD/track1.wav myCD/track10.wav myCD/track11.wav myCD/track2.wav myCD/track3.wav myCD/track4.wav myCD/track5.wav myCD/track6.wav myCD/track7.wav myCD/track8.wav myCD/track9.wav

+ 57 - 0
vrac/rename.sh

@@ -0,0 +1,57 @@
+#!/bin/sh
+
+usage() {
+	echo 'Usage: ${0} -p prefix [-d directory] [-t extension] [-u]'
+	echo "	-p	prefix to be removed"
+	echo "	-d	destination folder"
+	echo "		default current directory"
+	echo "	-t	files extension"
+	echo "		default to ogg"
+	echo "	-u	encode filename in UTF-8"
+	echo '---------------------'
+}
+
+processing()
+{
+	echo processing "${@}"
+	newfile=`echo "$@" | sed "s/${prefix}//g"`
+	[ -n ${iconv} ] && newfile=`echo ${newfile} | iconv -cs -t UTF-8`
+	echo "	: copying <$newfile> into <${dest}>"
+	cp "${@}" "${dest}/${newfile}"
+}
+
+while getopts "p:d:t:u" option 
+do
+	case ${option} in
+		p)
+			prefix="${OPTARG}"
+			;;
+		d)
+			dest="${OPTARG}"
+			;;
+		t)
+			ext="${OPTARG}"
+			;;
+		u) iconv="y"
+			;;
+		*)
+			usage
+			exit 1
+			;;
+
+	esac
+done
+
+dest=${dest:-.}
+ext=${ext:-ogg}
+[ -z "${dest}" ] && usage && exit 1
+[ -z "${prefix}" ] && usage && exit 1
+
+echo 
+echo "Copy and rename ${ext} files, removing <${prefix}> prefixes, into <${dest}>."
+[ -n "${iconv}" ] && echo '* Filename UTF-8 encoding is on.'
+echo 
+mkdir -p "${dest}" || (echo "unable to create ${dest}" && exit 1)
+
+find . -maxdepth 1 -type f -name "*.${ext}" -print | while IFS= read file; do processing "${file}" ; done
+

+ 10 - 0
vrac/ripping.sh

@@ -0,0 +1,10 @@
+#!/bin/sh
+# mkdir -p ~/tmp/cd
+# cd ~/tmp/cd
+# cdparanoia -B -d /dev/d0
+for i in `ls *.wav`; do
+  lame -m s "$i" -o "$(echo $i | awk '{print substr($0,6,2)}' -).mp3"
+#  rm -f "$i"
+done
+echo files are in  $PWD
+exit 0

+ 2 - 0
vrac/unpinrox.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+rox --pinboard=

+ 10 - 0
vrac/utf8.sh

@@ -0,0 +1,10 @@
+#!/bin/sh
+export MM_CHARSET=UTF-8
+export LANG=fr_FR.UTF-8
+export LC_ALL=fr_FR.UTF-8
+export LC_COLLATE=fr_FR.UTF-8
+export LC_CTYPE=fr_FR.UTF-8
+export LC_MESSAGES=fr_FR.UTF-8
+export LC_MONETARY=fr_FR.UTF-8
+export LC_NUMERIC=fr_FR.UTF-8
+export LC_TIME=fr_FR.UTF-8

+ 63 - 0
vrac/vmstat.pl

@@ -0,0 +1,63 @@
+#!/usr/local/bin/perl
+#
+# requires textproc/p5-XML-LibXML
+#
+use warnings;
+use strict;
+
+use feature 'say';
+use XML::LibXML;
+
+my ($offset) = @ARGV;
+
+if (not defined $offset) {
+	$offset = 10;
+}
+
+my $filename = 'vmstat.xml';
+
+
+my %dict;
+
+
+
+while (1) {
+	say scalar localtime();
+	say "------------------------";
+	system("/usr/bin/vmstat -z --libxo xml >$filename"); 
+	my $doc = XML::LibXML->load_xml(location => $filename); 
+	my $c = 0;
+	foreach my $id ($doc->findnodes('//zone')) {
+		my $name=$id->findvalue('name');
+		my $used=$id->findvalue('used');
+
+		my $val = int($used);
+
+		if ($name eq "vm pgcache") {
+			$name = $name . "_$c";
+			$c++;
+		}
+		
+		if (exists $dict{$name}) {
+			my $v0=$dict{$name} + $offset;
+
+			if ($v0 <= $val) {
+format DIFF_V0V1 =
+	@<<<<<<<<<<<<<<<<<<<<<< @######## => @########
+	$name,$dict{$name},$val
+.
+				$~ = "DIFF_V0V1";
+				write;
+				$dict{$name} = $val;
+			}
+		} else {
+			$dict{$name} = $val;
+		}
+	}
+
+	say '';
+
+	sleep(5);
+}
+
+

+ 48 - 0
vrac/vmstatm.pl

@@ -0,0 +1,48 @@
+#!/usr/local/bin/perl
+#
+# requires textproc/p5-XML-LibXML
+#
+use warnings;
+use strict;
+use feature 'say';
+
+use XML::LibXML;
+
+my $filename = 'vmstatm.xml';
+my %dict;
+
+my ($offset) = @ARGV;
+
+if (not defined $offset) {
+	$offset = 10;
+}
+
+while (1) {
+	say scalar localtime();
+	say "------------------------";
+	system("/usr/bin/vmstat -m --libxo xml >$filename"); 
+	my $doc = XML::LibXML->load_xml(location => $filename); 
+	foreach my $id ( $doc->findnodes('//memory')) {
+		my $name=$id->findvalue('type');
+		my $used=$id->findvalue('memory-use');
+		if (exists $dict{$name}) {
+			my $v0=$dict{$name} + $offset;
+
+			if ($v0 < $used) {
+format DIFF_V0V1 =
+	@<<<<<<<<<<<<<<<<<<<<<< @######## => @########
+	$name,$dict{$name},$used
+.
+				$~ = "DIFF_V0V1";
+				write;
+				$dict{$name}=$used;
+			}
+		} else {
+			$dict{$name}=$used;
+		}
+	}
+
+	say '';
+	sleep(5);
+}
+

+ 17 - 0
vrac/withinajail.sh

@@ -0,0 +1,17 @@
+#!/bin/sh
+
+within_a_jail()
+{
+    return $(sysctl -n security.jail.jailed)
+}
+if  within_a_jail;  then
+		echo You r in a jail
+		C_BOLD_S="\033[1m";	C_BOLD_E="\033[0m"
+		C_CYAN_S="\e[1;36m";	C_CYAN_E="\e[1;36m\e[0m"
+		C_GREEN_S="\e[1;32m";	C_GREEN_E="\e[1;32m\e[0m"
+		C_YELLOW_S="\e[1;33m";	C_YELLOW_E="\e[1;33m\e[0m"
+		C_RED_S="\e[1;31m";	C_RED_E="\e[1;31m\e[0m"
+		C_MAGENTA_S="\e[1;35m";	C_MAGENTA_E="\e[1;35m\e[0m"
+else
+	echo ok. Not jailed.
+fi