iminplaya sends in an item from TechNewsWorld that begins, “Several incidents of iPod Nanos bursting into flames have created consumer jitters in gadget-happy Japan. Apple is downplaying the problem,…
iminplaya sends in an item from TechNewsWorld that begins, “Several incidents of iPod Nanos bursting into flames have created consumer jitters in gadget-happy Japan. Apple is downplaying the problem,…
root@utam-f9:/home/.env # cat bash_prompt
#!/bin/bash
#export PROMPT_COMMAND=’ history -a; PROMPT1A’
_PROMPT_FILL_OUT=”“
setprompt () {
typeset PROMPT_NO=1A
test x”$1” != x && PROMPT_NO=”${1}”
export PROMPT_COMMAND=” history -a; PROMPT${PROMPT_NO}; “
}
PROMPT1 () {
_PROMPT_FILL ” “
PS1line=”\[\e[4;41m\]${_PROMPT_FILL_OUT}\[\e[0m\]”
PS1error=’$( ret=$? ; test $ret -gt 0 && echo “\[\e[41;93m\] [$ret] \[\e[0m\]” )’
PS1user=”$( test `whoami` == root && echo \u )”
#PS1color=’\[\e[1;31m44m\]’ # color of working directory
PS1=”$PS1line\n$PS1error$PS1user@\h:\w \$\[\e[0m\]$PS1version “
tty | grep pts > /dev/null && PS1=”$PS1\[\e]0;\w - \u@\h\a\]”;
export PS1
}
PROMPT1A () {
_PROMPT_FILL ” “
if [[ “$USER” == root ]]
then
PS1line=”\[\e[4;31m\]${_PROMPT_FILL_OUT}\[\e[0m\]”
PS1error=’$( ret=$? ; test $ret -gt 0 && echo “\[\e[41;93m\] [$ret] \[\e[0m\]” )’
PS1user=”$USER”
#PS1color=’\[\e[1;31m44m\]’ # color of working directory
PS1=”$PS1line\n$PS1error$PS1user@\h:\w \$\[\e[0m\]$PS1version “
tty | grep pts > /dev/null && PS1=”$PS1\[\e]0;\w - \u@\h\a\]”;
export PS1
else
PS1line=”\[\e[4m\]${_PROMPT_FILL_OUT}\[\e[0m\]”
PS1error=’$( ret=$? ; test $ret -gt 0 && echo “\[\e[41;93m\] [$ret] \[\e[0m\]” )’
PS1user=”$USER”
#PS1color=’\[\e[1;31m44m\]’ # color of working directory
PS1=”$PS1line\n$PS1error$PS1user@\h:\w \$\[\e[0m\]$PS1version “
tty | grep pts > /dev/null && PS1=”$PS1\[\e]0;\w - \u@\h\a\]”;
export PS1
fi
}
PROMPT2 () {
PS1user=`whoami`
PS1host=`hostname -s`
PS1pwd=`pwd`
PS1error=’$( ret=$? ; test $ret -gt 0 && echo “\[\e[41;93m\] [$ret] \[\e[0m\]” )’
#PS1time=”\t”
if [[ “$PS1user” == root ]]
then
PS1line1=”${PS1user}@${PS1host}[${PS1pwd}]”
PS1line__fill_len=$( echo -ne “$PS1line1” | wc -c )
_PROMPT_FILL ” ” $PS1line__fill_len
PS1line1=”\[\e[0;41;93m\]${PS1user}@${PS1host}${_PROMPT_FILL_OUT}[$PS1pwd]\[\e[0m\]”
PSline2=”${PS1error}\[\e[0m\]\$ “
PS1=”${PS1line1}\n${PSline2}”
else
PS1line1=”${PS1user}@${PS1host}$PS1pwd”
PS1line__fill_len=$( echo -ne “$PS1line1” | wc -c )
_PROMPT_FILL ” ” $PS1line__fill_len
PS1line1=”\[\e[07m\]${PS1user}@${PS1host}${_PROMPT_FILL_OUT}$PS1pwd\[\e[0m\]”
PSline2=”${PS1error}\[\e[0m\]\$ “
PS1=”${PS1line1}\n${PSline2}”
fi
export PS1
}
PROMPT3 () {
PS1user=`whoami`
PS1host=`hostname -s`
PS1pwd=`pwd`
PS1error=’$( ret=$? ; test $ret -gt 0 && echo “\[\e[7;41;93m\] [ERR: $ret] \[\e[0m\]” )’
#PS1time=”\t”
if [[ “$PS1user” == root ]]
then
PS1line1=”${PS1user}@${PS1host}[${PS1pwd}]”
PS1line__fill_len=$( echo -ne “$PS1line1” | wc -c )
_PROMPT_FILL ” ” $PS1line__fill_len
PS1line1=”\[\e[0;41;93m\]${PS1user}@${PS1host}${_PROMPT_FILL_OUT}[$PS1pwd]\[\e[0m\]”
PSline2=”${PS1error}\[\e[0;41;93m\] \# \$ \[\e[0m\] “
PS1=”${PS1line1}\n${PSline2}”
else
PS1line1=”${PS1user}@${PS1host}[${PS1pwd}]”
PS1line__fill_len=$( echo -ne “$PS1line1” | wc -c )
_PROMPT_FILL ” ” $PS1line__fill_len
PS1line1=”\[\e[07m\]${PS1user}@${PS1host}${_PROMPT_FILL_OUT}[$PS1pwd]\[\e[0m\]”
PSline2=”${PS1error}\[\e[07m\] \# \$ \[\e[0m\] “
PS1=”${PS1line1}\n${PSline2}”
fi
export PS1
}
function _ssssssss {
TERMWIDTH=${COLUMNS}
# Calculate the width of the prompt:
PS1_hostname=$(hostname -s)
PS1_username=$(whoami)
let usersize=$(echo -n $usernam | wc -c | tr -d ” “)
newPWD=”${PWD}”
let pwdsize=$(echo -n ${newPWD} | wc -c | tr -d ” “)
# Add all the accessories below …
let promptsize=$(echo -n “—(${usernam}@${hostnam})—-(${PWD})—” \
| wc -c | tr -d ” “)
let fillsize=${TERMWIDTH}-${promptsize}
fill=”“
while [ “$fillsize” -gt “0” ]
do
fill=”${fill}-“
let fillsize=${fillsize}-1
done
if [ “$fillsize” -lt “0” ]
then
let cut=3-${fillsize}
newPWD=”…$(echo -n $PWD | sed -e “s/\(^.\{$cut\}\)\(.*\)/\2/”)”
fi
}
function _PROMPT_PS1 {
PS1_hostname=$(hostname -s)
PS1_username=$(whoami)
PS1_PWD=”${PWD}”
}
function _PROMPT_FILL {
typeset FILL_LMAX=”${COLUMNS}” FILL_CHAR=”_” FILL_OUT=”” COUNT=0 FILL_CROP=0 FILL_LEN_MAX=”” FILL_REPT=”“
test x”$1” != x && FILL_CHAR=”${1}”
test x”$2” != x && FILL_CROP=”${2}”
test x”$3” != x && FILL_LMAX=”${3}”
case “$FILL_LMAX” in
[0-9]*) :
;;
*) FILL_LMAX=${COLUMNS};;
esac
case “$FILL_CROP” in
[0-9]*) :
;;
*) FILL_CROP=0;;
esac
let FILL_LNEW=$FILL_LMAX-$FILL_CROP
FILL_CHARLEN=$( echo -ne “$FILL_CHAR” | wc -c)
if [[ ${FILL_CHARLEN} -ge ${FILL_LNEW} ]]
then
let FILL_REPT=1
else
let FILL_REPT=($FILL_LNEW/$FILL_CHARLEN)+($FILL_LNEW%$FILL_CHARLEN)
fi
FILL_OUT=”“
while test ${FILL_REPT} -gt $COUNT
do
let COUNT++
FILL_OUT=”${FILL_CHAR}${FILL_OUT}”
done
_PROMPT_FILL_OUT=`echo -ne “${FILL_OUT}” | cut -c 1-$FILL_LEN1`
#printf — “$FILL_OUT”
#printf — “\n==\n”
#printf — “$FILL_OUT_CUT”
}
function _bashish_prompt_fillx {
typeset BASHISH_ARGV=”” BASHISH_ARGC=”” n=0 STRCROP=”0” STR=” ” STRREPEAT=”” STRREST=”” COUNT=0
test x”$1” != x && STR=”${1}”
test x”$2” != x && STRCROP=”${2}”
case “$STRCROP” in
[0-9]*) :
;;
*) STRCROP=${#STRCROP};;
esac
test “$COLUMNS”||for COLUMNS in $(stty size)
do :
done
test ${STRCROP} -ge ${COLUMNS}&&exit 0
PRINTSTR=”“
let STRREPEAT=$COLUMNS-${STRCROP}
let STRRESTCROP=${STRREPEAT}%${#STR}
let STRREPEAT=${STRREPEAT}/${#STR}
case “$BASH” in
“”)
STRREST=$(printf “$STR”|cut -c1-$STRRESTCROP)
;;
*)
STRREST=${STR:0:$STRRESTCROP}
esac
while test ${STRREPEAT} -gt $COUNT
do
let COUNT++
PRINTSTR=”${STR}${PRINTSTR}”
done
printf — “${PRINTSTR}${STRREST}”
}
setprompt
root@utam-f9:/home/.env # cat env
#!/bin/bash
export PATH=”$PATH:/usr/local/bin:/usr/local/sbin:/data/bin:/usr/libexec/nx”
export HISTSIZE=10000
export HISTCONTROL=”ignoredups”
export HISTIGNORE=”&:ls:[bf]g:exit”
export PROMPT_COMMAND=’history -a’
export CDPATH=’.:..:../..:~:/data/.links:/data:/www/first:/www’
export PAGER=`which less` # for man pagese
export BROWSER=`which firefox` # for xdg-open
export EDITOR=`which vim` # for visudo, crontab -e, etc
export CVS_RSH=`which ssh` # for cvs!
export GREP_OPTIONS=’—color=auto’
shopt -s histappend
shopt -s no_empty_cmd_completion
shopt -s cdspell # fix dir-name typos in cd
shopt -s checkwinsize # handle xterm resizing
shopt -s cmdhist # save multi-line commands as one line
shopt -s dotglob # allow tab-completion of ‘.’ filenames
shopt -s extglob # bonus regex globbing!
shopt -s hostcomplete # tab-complete words containing @ as hostnames
shopt -s execfail # failed execs don’t exit shell
set -o notify # show status of terminated programs immediately
stty -ixon # disable Ctrl-S and Ctrl-Q, which suck!
# Override lame default apps with useful 3rd-party ones if they exist
#[ “” != “`which colordiff`” ] && alias diff=`which colordiff`
All my function below:
root@utam-f9:/home/.env # cat function
#!/bin/bash
# —————————————————————————————————-
today () {
echo -ne “Today’s date is: “
echo -ne ‘\e[1m’
date +”%A, %B %-d, %Y”
echo -ne ‘\e[m’
}
# —————————————————————————————————-
x () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo “’$1’ cannot be extracted via extract()” ;;
esac
else
echo “’$1’ is not a valid file”
fi
}
# —————————————————————————————————-
vi () {
echo $@
for i in “$@” ; do
if [ -f “$i” -a ! -w “$i” ] ; then precommand=”sudo ” ; break ; fi
done
if [ “x$DISPLAY” = “x” ] ; then
${precommand}vim “$@”
else
${precommand}gedit “$@” &
echo “$? is “
if [ “$?” != “0” ] ; then setz ; ${precommand}vim “$@” ;fi
fi
}
# —————————————————————————————————-
startwm () {
if [ -z “$1” ]
then
echo Usage: startwm path [screen]
return 1
fi
SCREEN_NUM=$2
[ -z “$SCREEN_NUM” ] && SCREEN_NUM=”1”
xinit $1 — :${SCREEN_NUM}
}
# —————————————————————————————————-
function rv_color () {
if [ $? -eq 0 ]
then
color=’\033[32m’ # GREEN
else
color=’\033[31m’ # RED
fi
echo -e $color
}
# —————————————————————————————————-
cpx () {
if [ -z “$1” -o -z “$2” ]
then
echo Usage: cpx src dest
return 1
fi
tar cpf - $1 | (cd $2 && tar xvpBf -)
return $?
}
# —————————————————————————————————-
# Zombie ps
zomb_ps () {
ps hr -Nos | awk ‘$1==”Z” {print $1}’
}
# —————————————————————————————————-
# trunc: truncate string $1 to length $2, prefixed with ‘…’
trunc () {
if [ -z “$1” -o -z “$2” ]
then
echo Usage: trunc string length
return 1
fi
if [ ${#1} -le $2 ]
then
echo $1
else
local offset=$(( ${#1} - $2 + 3 ))
echo “…${1:$offset:$2}”
fi
}
# —————————————————————————————————-
# xtitle: Set caption of terminal-emulator title bar to args
xtitle () {
echo -e “\033]0;$*\007”
}
# —————————————————————————————————-
# xtrun: Invoke xtitle on args, then execute args
xtrun () {
xtitle $*
$*
}
# —————————————————————————————————-
# xrun: run a window manager (or any X app) in a new XServer session.
xrun () {
if [ -z “$1” ]
then
echo Usage: xrun path [screen]
return 1
fi
SCREEN_NUM=$2
[ -z “$SCREEN_NUM” ] && SCREEN_NUM=”1”
xinit $1 — :${SCREEN_NUM}
}
# —————————————————————————————————-
# battery_life : Echo the percentage of battery life remaining
battery_life () {
life=$(acpi -b | cut -d , -f 2)
# NOTE: the trailing % is stripped
echo ${life%\%}
}
# —————————————————————————————————-
# battery_color: Change console font based on battery life
battery_color () {
num=$(battery_life)
if [ $num -gt 25 ]
then
# 26-100% remaining : GREEN
color=’\033[32m’
elif [ $num -gt 10 ]
then
# 11-25% remaining : YELLOW
color=’\033[1;33m’
else
# 0-10% remaining : RED
color=’\033[31m’
fi
echo -e “${color}”
}
# —————————————————————————————————-
# uprompt: Build and echo (NOT return!) a user prompt.
# This echoes “user@host:path”, where path is truncated to
# 1/3 of the screen size (using the trunc() function).
# The entire string is colored RED if UID is 0.
uprompt () {
local prompt=’\u@\h:`trunc $PWD $((COLUMNS/3))`’
if [ $UID -eq 0 ]
then
prompt=”${RED}${prompt}${NC}”
fi
echo $prompt
}
# —————————————————————————————————-
# fixtty : reset TTY after user cat’ed a binary file
fixtty () {
stty sane
reset
}
# —————————————————————————————————-
# quick backup files ;)
bak () {
typeset file=”“
if [ ! -n “$1” ]
then
echo “Usage: bak file1 file2 etc”
exit 1
fi
for file in $@;
do
now=$(date +%Y%m%d-%H%M%S)
cp $file $file.$now
done
return 0
}
# —————————————————————————————————-
# quick link files ;)
ln2 () {
set -x
typeset DIR1 DIR2
if [ ! -n “$2” ]
then
echo “Usage: ln2 dir1 dir2”
return 1
fi
if [ -d ${1} ]
then
DIR1=$(cd ${1} && echo `pwd`)
else
echo “${1} is not a directory”
return 1
fi
if [ -d ${2} ]
then
DIR2=”${2}”
PTH2=$(cd $DIR2 && echo `pwd`)
else
DIR2=”${2}”
mkdir -p $2 || (echo “${2} is not a directory & cant be created” && return 1)
fi
ls -1 $DIR1 | awk “{ system("set -x; ln -s $DIR1/" \$1 " $DIR2/" \$1)} “
set +x
return 0
}
all alias below:
#alias
alias wget=’wget —directory-prefix=/downloads/unsorted/direct/wget ‘
alias ll=’ls -ahlrtF’
alias l=’ls -lhF’
#alias la=’ls -rltha’
alias lt=’ls -lrtha’
alias du=”du -sh”
alias df=”df -h”
alias cd..=’cd ..’
alias ..=’cd ..’
alias …=’cd ../..’
alias gotemp=’cd ~/temp’
alias temp=’cd ~/temp’
alias pkill=’pkill -9’
alias phup=’pkill -1’
alias pff=’ps -ef f’
alias pfg=’ps -ef f | grep ‘
alias rudo=’sudo su - root’
alias rebash=’. ~/.bashrc’
#alias vialias=’vi ~/.env/alias’
alias setx=”export DISPLAY=192.168.2.100:0.0”
alias sety=”export DISPLAY=192.168.2.101:0.0”
alias setz=”export DISPLAY=””
alias vibashrc=’vi ~/.bashrc’
#[ root only
if [[ “$(/usr/bin/whoami)” = “root” ]]; then
dialog —title ‘ROOT!’ —textbox ~/_cowsay.txt 16 45
#cowsay -s Hey man, you are ROOT now! Careful!
echo “”
alias vialias=’vi /data/home/.env/alias’
alias vifuncton=’vi /data/home/.env/function’
alias vienv=’vi /data/home/.env/env’
alias viprompt=’vi /data/home/.env/bash_prompt’
fi
#]
alias whatismyip=’ curl -s www.whatismyip.com/automation/n09230945.asp; echo “”’
alias myip=’curl -s www.whatismyip.com/automation/n09230945.asp; echo “”’
# misc
alias netsl=’netstat -leeptu’ # listening sockets
alias netsc=’netstat -eeptu’ # connected sockets
alias memfree=’free -m’ # available memory
# directory shortcuts
alias golog=’cd /var/log’ # change to log dir
alias gowww=’cd /data/apps/www/’
Video easier on ur eyes than reading http://www.ted.com/index.php/talks/tony_robbins_asks_why_we_do_what_we_do.html
I fear that I will always be
A lonely number like root three
The three is all that’s good and right,
Why must my three keep out of sight
Beneath the vicious square root sign,
I wish instead I were a nine
For nine could thwart this evil trick,
with just some quick arithmetic
I know I’ll never see the sun, as 1.7321
Such is my reality, a sad irrationality
When hark! What is this I see,
Another square root of a three
As quietly co-waltzing by,
Together now we multiply
To form a number we prefer,
Rejoicing as an integer
We break free from our mortal bonds
With the wave of magic wands
Our square root signs become unglued
Your love for me has been renewed