From: Nicolas Boisselier Date: Tue, 28 Jul 2015 23:06:58 +0000 (+0100) Subject: change profile paths X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=7e68ca61fc7aff1318a21e25659f177ba2eb5995;p=nb.git change profile paths --- diff --git a/bin/nb-update b/bin/nb-update index 93b668c8..9576ec3c 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -37,12 +37,16 @@ for repo in \ cd "$repo" || continue [ -z "$user" ] && user=`ls -dl "$repo" |awk '{print $3}'` + cmd="git pull" echo ">git pull $repo (user=$user)" if [ "$USER" == "$user" ]; then timeout 30 git pull - else + elif [ "$USER" == "root" ]; then timeout 30 su $user -c "GIT_SSH=$TMP cd \"$repo\" && git pull" + else + echo "Ignore $repo: current user=$USER repo user=$user" + continue fi ret=$? diff --git a/etc/bashrc b/etc/bashrc deleted file mode 100644 index 718fc1fe..00000000 --- a/etc/bashrc +++ /dev/null @@ -1,105 +0,0 @@ -################################################################################# -# -# ENVS -# -################################################################################# -case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac -[ -e "$path/bashrc.function" ] && . "$path/bashrc.function" -NB_ROOT=$(realpath ${path}/..) -unset path - -# -# BASE -# -[ -z "$HOME" ] && HOME=`realpath ~/` -[ -z "$HOSTNAME" ] && HOSTNAME=`hostname` -[ -z "$UID" ] && UID=`id -u` -[ -z "$USER" ] && USER=`whoami` -[ -z "$OSTYPE" ] && OSTYPE=`uname|tr [:upper:] [:lower:]` - -# -# PATHS -# -env_add_path &>/dev/null && PATH=`env_add_path "$PATH" \ - /bin \ - /sbin \ - /usr/sbin \ - /usr/sbin \ - /opt/local/bin \ - /opt/local/sbin \ - /usr/local/bin \ - /usr/local/sbin \ - $NB_ROOT/bin \ - $NB_ROOT/sbin \ - $HOME/bin \ - $HOME/sbin \ - /usr/share/awstats/tools \ - /home/bin \ - /home/www/wp/bin \ -` -export PATH - -# -# OTHERS -# - -export IGNOREEOF=0 -export LESS="-iMR" -export EDITOR=vim -case "$OSTYPE" in darwin*) export DARWIN=1;; esac - -# -# Color -# -color_prompt='' -case "$TERM" in - xterm-color) color_prompt=yes;; - *screen*) color_prompt=yes;; - linux) color_prompt=yes;; -esac - -# -# PS1 -# -h='\h' -color='' -#case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in -case "`hostname -f`" in - pi*) color=31 ;; - # ovh - yellow - *.ovh.net|*.kimsufi.com|*.ip-*.eu) color=33 ;; - # mac - magenta - Nicolas-Boisselier-MacBook*) h="macbook"; color=35 ;; - MacMini*) color=35 ;; - *.semantico.net|dev*|cst*|csp*|isp*) color=32 ;; - *) color=36 ;; -esac - -char='$'; [ $UID = "0" ] && char='#' -if [ "$color_prompt" = yes -a -n "$color" ]; then - PS1="\[\033[01;${color}m\]\u@$h:\[\033[00m\]\W${char} " -else - PS1="\u@\h:\W${char} " -fi -unset h color char - -# -# ls -# -ls_opt='' -ll_opt='' -if [ -n "$DARWIN" ]; then - [ "$color_prompt" = yes ] && ls_opt="$ls_opt -G" -else - [ "$color_prompt" = yes ] && ls_opt="$ls_opt --color=auto" - ll_opt="$ll_opt --time-style=long-iso" -fi - -[ "$ls_opt" = "" ] || alias ls="ls${ls_opt}" -alias ll="ls -alh${ll_opt}" -unset ls_opt ll_opt - -# -# bye -# -unset color_prompt diff --git a/etc/bashrc.function b/etc/bashrc.function deleted file mode 100644 index 2ec01783..00000000 --- a/etc/bashrc.function +++ /dev/null @@ -1,205 +0,0 @@ -################################################################################# -# -# FUNCTIONS - SH -# -################################################################################# -if ! which timeout 1>/dev/null; then -timeout() { - perl -e 'BEGIN{$|=1}; alarm(shift @ARGV); exec join(" ",@ARGV)' -- $@ -} -fi - -shell_help() { - # - # Print help message and return true if args contains -?-h(elp)? - # - local msg="$1"; shift - - case "$@" in - *-h*|*-help*|*--help*) - case $OSTYPE in - darwin*) printf "$msg\n" ;; - *) echo -e "$msg" ;; - esac - return 0 - ;; - *) return 1 ;; - esac - -} - -shell_help_noarg() { - # - # Print help message and return true if args contains -?-h(elp)? or is empty - # - local msg="$1"; shift - - local args=""; args="$@" # zsh compatible - [ -z "$args" ] && args="--help" - - sem_help "$msg" "$args" -} - -shell_functions() { - set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"' -} - -shell_slogin() { - declare ssh_opt; case "$1" in -*) ssh_opt="$1"; shift ;; esac - declare server; server="$1"; shift - declare tmp; tmp="/tmp/$FUNCNAME.$USER" - ( - alias - type $(shell_functions) | grep -v 'is a function$' - cat $NB_ROOT/etc/bashrc - echo "[ -r /etc/profile ] && . /etc/profile" - ) | ssh "$server" "cat > $tmp || rm -vf $tmp" || return - - declare args - if [ -z "$@" ]; then - [ -z "$ssh_opt" ] && ssh_opt='-t' - ssh $ssh_opt "$server" "bash --rcfile $tmp && rm -f $tmp" - else - ssh $ssh_opt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@" - fi -} - -ips() { - ifconfig | perl -ne '/^\s*inet (?:addr:)?([\d\.]+)/ and $1 ne "127.0.0.1" and print "$1\n"' -} - -env_add_path() { - # Add paths to a variables - # Usage PATH=`env_add_path "$PATH" "/blbabla"` - declare env_value; env_value=$1; shift - - for p in $@; do - [ -e "$p" ] || continue - case "${env_value}" in - *:$p|*:$p:*|$p:*|$p) continue;; - esac - [ -z "$env_value" ] || env_value=":${env_value}" - env_value="${p}${env_value}" - done - - [ -z "$env_value" ] || echo "$env_value" -} - -realpath() { - perl -MFile::Spec -MCwd -e 'print File::Spec->rel2abs( Cwd::abs_path($ARGV[0]) )."\n"' $1 -} - -ascii() { - perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }' -} - -psmem() { - declare ps; ps=`ps ax -O rss 2>/dev/null` - echo "$ps"| awk "\ -BEGIN { count = 0; sum= 0; } -/^ *[0-9]+/ && /$1/ { count ++; sum += \$2 } -END { - print \"Number of processes =\",count; - if (count < 1) { count = 1 } - print \"Memory usage per process =\",sum/1024/count, \"MB\"; - print \"Total memory usage =\", sum/1024, \"MB\"; -} -" - return -} - -unzipurl() { - declare url file - url=$1 - file=`echo "$url"|awk -F/ '/\.zip$/ { print $NF }'` - [ -z "$file" ] && file="$FUNCNAME.zip" - wget "$url" -O "$file" && unzip "$file" - rm "$file" -} - -bytes2h() { - declare in args - - if [ "$1" = "-regex" ]; then - args="regex=$2" - shift - shift - fi - in="cat" - [ -z "$@" ] || in="echo $@" - - $in | perl -pe 'BEGIN{ - use NB::Functions qw/&oct2h/; - $exp = "([\\d\\.]+)"; - if (@ARGV and $ARGV[0] =~ /regex=(\S+)/) { - shift @ARGV; - $exp = $1; - } -}; -s/$exp/oct2h($1*1024)/ge; -' $args -} - -yaml2perl() { - perl -MYAML -MData::Dumper -e 'print Dumper YAML::Load(join("",<>))' $@ -} - -################################################################################# -# -# CHECK SHELL -# -################################################################################# -# NB 08.07.15 case "$BASH" in -# NB 08.07.15 */bash) ;; -# NB 08.07.15 *) -# NB 08.07.15 case "$SHELL" in -# NB 08.07.15 */bash) ;; -# NB 08.07.15 */zsh) ;; -# NB 08.07.15 *) return 0 ;; -# NB 08.07.15 esac -# NB 08.07.15 ;; -# NB 08.07.15 esac - -################################################################################# -# -# FUNCTIONS - BASH -# -################################################################################# -hl() { - cat | grep --color=auto -E "(^|($@))" -} - -ls_tree() { - tree -tDphug -} - -find_sort_mtime() { - ( - if [ -n "$DARWIN" ]; then - find $@ -type f -exec stat -f '%m'$'\t''%N' {} \; - else - find $@ -type f -printf "%T@\t%p\n" | sed 's/^\([0-9]\+\)\.0\+/\1/' - fi - ) | sort -k1 -n | cut -f 2 | head -} - -replace_tag_content() { - declare tag; tag="$1"; shift - declare content; content="$@" - perl -ne 'BEGIN { -$tag = shift(@ARGV)." - replace_tag_content"; -$t1 = "# >>> $tag"; -$t2 = "# <<< $tag"; -$content = shift @ARGV; -$content = "$t1\n$content\n$t2\n" -} - -if (/^$t1$/ .. /^$t2$/) { - print "$content" and $content="" if /^$t1$/; -} else { - print "$_"; -} - -END { print "$content" if $content; } -' "$tag" "$content" -} diff --git a/etc/profile b/etc/profile index b84c3060..6964d3ca 100644 --- a/etc/profile +++ b/etc/profile @@ -1,10 +1,14 @@ -case "$BASH_SOURCE" in */*) path_profile="${BASH_SOURCE%/*}";; *) path_profile='.' ;; esac -[ -r "${path_profile}/bashrc" ] && . "${path_profile}/bashrc" -[ -r "${path_profile}/aliases" ] && . "${path_profile}/aliases" +# +# ROOT PATH +# +case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac +[ -e "$path/profile.d/functions" ] && . "$path/profile.d/functions" +NB_ROOT=$(realpath ${path}/..) +unset path -for i in $NB_ROOT/etc/profile.d/*.sh; do +for i in ${NB_ROOT}/etc/profile.d/envs ${NB_ROOT}/etc/profile.d/aliases $NB_ROOT/etc/profile.d/*.sh; do [ -r "$i" ] && . "$i" done -unset i path_profile +unset i tmp true diff --git a/etc/profile.d/0default.sh b/etc/profile.d/0default.sh deleted file mode 100644 index 5a9fe88e..00000000 --- a/etc/profile.d/0default.sh +++ /dev/null @@ -1,52 +0,0 @@ -radio_play() { -#1 | FranceInter | http://www.tv-radio.com/station/france_inter_mp3/france_inter_mp3-128k.m3u -#3 | FranceInfo | http://players.creacast.com/creacast/france_info/playlist.m3u -#4 | FranceCulture | http://www.tv-radio.com/station/france_culture_mp3/france_culture_mp3-128k.m3u - local radios="\ -1 | FranceInter | http://audio.scdn.arkena.com/11008/franceinter-midfi128.mp3 -2 | Indie | http://107.155.126.42:17160/listen.pls -3 | FranceInfo | http://audio.scdn.arkena.com/11006/franceinfo-midfi128.mp3 -4 | FranceCulture | http://audio.scdn.arkena.com/11010/franceculture-midfi128.mp3 -5 | BBC 1 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p -6 | BBC 2 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p -7 | BBC 3 | http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls -8 | BBC 4 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p -9 | BBC 5 live | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5live_mf_p -10 | BBC 6 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p - -Choose one > \ -" - if [ -z "$@" ]; then - read -p "$radios" - else - REPLY="$@" - fi - - test -z "$REPLY" 2>/dev/null && return - echo "$radios" | awk -F '|' '$1 == '$REPLY' {print $3; exit}' | sed 's/^ //' | xargs mplayer 2>/dev/null -} - -_getexp_pcregrep="" -getexp() { - [ -z "$*" -o "$1" == "-h" -o "$1" == "--help" ] && echo "Usage: $FUNCNAME [capture number|default 0] PERL_REGEXP FILES..." && return - declare exp num - num=0; case "$1" in [0-9]*) num=$1; shift ;; esac - exp=$1; shift - - if [ -z "$_getexp_pcregrep" ]; then - _getexp_pcregrep=0 - which pcregrep > /dev/null && _getexp_pcregrep=1 - fi - - if [ $_getexp_pcregrep = 1 ]; then - pcregrep -o${num} "$exp" $@ - else - perl -ne 'BEGIN{$e=shift @ARGV; $n=shift(@ARGV) or 0; $e="($e)" and $n=1 if $n==0} (@_=m{$e}) and ($n<=scalar(@_)) and print ($n==0 ? $_[0] : $_[$n-1].chr(10))' "$exp" "$num" $@ - fi - return -} - -hl(){ - #cat | grep --color=always -E "(^|($@))" - perl -MTerm::ANSIColor -pe 's/('$@')/color("red").$1.color("reset")/ge' -} diff --git a/etc/profile.d/default.sh b/etc/profile.d/default.sh new file mode 100644 index 00000000..e69de29b diff --git a/etc/profile.d/envs b/etc/profile.d/envs new file mode 100644 index 00000000..a38dd6e8 --- /dev/null +++ b/etc/profile.d/envs @@ -0,0 +1,108 @@ +################################################################################# +# +# ENVS +# +################################################################################# +# NB 28.07.15 case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac +# NB 28.07.15 # +# NB 28.07.15 # ROOT PATH +# NB 28.07.15 # +# NB 28.07.15 [ -e "$path/bashrc.function" ] && . "$path/bashrc.function" +# NB 28.07.15 NB_ROOT=$(realpath ${path}/..) +# NB 28.07.15 unset path + +# +# BASE +# +[ -z "$HOME" ] && HOME=`realpath ~/` +[ -z "$HOSTNAME" ] && HOSTNAME=`hostname` +[ -z "$UID" ] && UID=`id -u` +[ -z "$USER" ] && USER=`whoami` +[ -z "$OSTYPE" ] && OSTYPE=`uname|tr [:upper:] [:lower:]` + +# +# PATHS +# +env_add_path &>/dev/null && PATH=`env_add_path "$PATH" \ + /bin \ + /sbin \ + /usr/sbin \ + /usr/sbin \ + /opt/local/bin \ + /opt/local/sbin \ + /usr/local/bin \ + /usr/local/sbin \ + $NB_ROOT/bin \ + $NB_ROOT/sbin \ + $HOME/bin \ + $HOME/sbin \ + /usr/share/awstats/tools \ + /home/bin \ + /home/www/wp/bin \ +` +export PATH + +# +# OTHERS +# + +export IGNOREEOF=0 +export LESS="-iMR" +export EDITOR=vim +case "$OSTYPE" in darwin*) export DARWIN=1;; esac + +# +# Color +# +color_prompt='' +case "$TERM" in + xterm-color) color_prompt=yes;; + *screen*) color_prompt=yes;; + linux) color_prompt=yes;; +esac + +# +# PS1 +# +h='\h' +color='' +#case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in +case "`hostname -f`" in + pi*) color=31 ;; + # ovh - yellow + *.ovh.net|*.kimsufi.com|*.ip-*.eu) color=33 ;; + # mac - magenta + Nicolas-Boisselier-MacBook*) h="macbook"; color=35 ;; + MacMini*) color=35 ;; + *.semantico.net|dev*|cst*|csp*|isp*) color=32 ;; + *) color=36 ;; +esac + +char='$'; [ $UID = "0" ] && char='#' +if [ "$color_prompt" = yes -a -n "$color" ]; then + PS1="\[\033[01;${color}m\]\u@$h:\[\033[00m\]\W${char} " +else + PS1="\u@\h:\W${char} " +fi +unset h color char + +# +# ls +# +ls_opt='' +ll_opt='' +if [ -n "$DARWIN" ]; then + [ "$color_prompt" = yes ] && ls_opt="$ls_opt -G" +else + [ "$color_prompt" = yes ] && ls_opt="$ls_opt --color=auto" + ll_opt="$ll_opt --time-style=long-iso" +fi + +[ "$ls_opt" = "" ] || alias ls="ls${ls_opt}" +alias ll="ls -alh${ll_opt}" +unset ls_opt ll_opt + +# +# bye +# +unset color_prompt diff --git a/etc/profile.d/functions b/etc/profile.d/functions new file mode 100644 index 00000000..51a74d1a --- /dev/null +++ b/etc/profile.d/functions @@ -0,0 +1,252 @@ +################################################################################# +# +# FUNCTIONS - SH +# +################################################################################# +if ! which timeout 1>/dev/null; then +timeout() { + perl -e 'BEGIN{$|=1}; alarm(shift @ARGV); exec join(" ",@ARGV)' -- $@ +} +fi + +shell_help() { + # + # Print help message and return true if args contains -?-h(elp)? + # + local msg="$1"; shift + + case "$@" in + *-h*|*-help*|*--help*) + case $OSTYPE in + darwin*) printf "$msg\n" ;; + *) echo -e "$msg" ;; + esac + return 0 + ;; + *) return 1 ;; + esac + +} + +shell_help_noarg() { + # + # Print help message and return true if args contains -?-h(elp)? or is empty + # + local msg="$1"; shift + + local args=""; args="$@" # zsh compatible + [ -z "$args" ] && args="--help" + + sem_help "$msg" "$args" +} + +shell_functions() { + set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"' +} + +shell_slogin() { + declare ssh_opt; case "$1" in -*) ssh_opt="$1"; shift ;; esac + declare server; server="$1"; shift + declare tmp; tmp="/tmp/$FUNCNAME.$USER" + ( + alias + type $(shell_functions) | grep -v 'is a function$' + cat $NB_ROOT/etc/bashrc + echo "[ -r /etc/profile ] && . /etc/profile" + ) | ssh "$server" "cat > $tmp || rm -vf $tmp" || return + + declare args + if [ -z "$@" ]; then + [ -z "$ssh_opt" ] && ssh_opt='-t' + ssh $ssh_opt "$server" "bash --rcfile $tmp && rm -f $tmp" + else + ssh $ssh_opt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@" + fi +} + +ips() { + ifconfig | perl -ne '/^\s*inet (?:addr:)?([\d\.]+)/ and $1 ne "127.0.0.1" and print "$1\n"' +} + +env_add_path() { + # Add paths to a variables + # Usage PATH=`env_add_path "$PATH" "/blbabla"` + declare env_value; env_value=$1; shift + + for p in $@; do + [ -e "$p" ] || continue + case "${env_value}" in + *:$p|*:$p:*|$p:*|$p) continue;; + esac + [ -z "$env_value" ] || env_value=":${env_value}" + env_value="${p}${env_value}" + done + + [ -z "$env_value" ] || echo "$env_value" +} + +realpath() { + perl -MFile::Spec -MCwd -e 'print File::Spec->rel2abs( Cwd::abs_path($ARGV[0]) )."\n"' $1 +} + +ascii() { + perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }' +} + +psmem() { + declare ps; ps=`ps ax -O rss 2>/dev/null` + echo "$ps"| awk "\ +BEGIN { count = 0; sum= 0; } +/^ *[0-9]+/ && /$1/ { count ++; sum += \$2 } +END { + print \"Number of processes =\",count; + if (count < 1) { count = 1 } + print \"Memory usage per process =\",sum/1024/count, \"MB\"; + print \"Total memory usage =\", sum/1024, \"MB\"; +} +" + return +} + +unzipurl() { + declare url file + url=$1 + file=`echo "$url"|awk -F/ '/\.zip$/ { print $NF }'` + [ -z "$file" ] && file="$FUNCNAME.zip" + wget "$url" -O "$file" && unzip "$file" + rm "$file" +} + +bytes2h() { + declare in args + + if [ "$1" = "-regex" ]; then + args="regex=$2" + shift + shift + fi + in="cat" + [ -z "$@" ] || in="echo $@" + + $in | perl -pe 'BEGIN{ + use NB::Functions qw/&oct2h/; + $exp = "([\\d\\.]+)"; + if (@ARGV and $ARGV[0] =~ /regex=(\S+)/) { + shift @ARGV; + $exp = $1; + } +}; +s/$exp/oct2h($1*1024)/ge; +' $args +} + +yaml2perl() { + perl -MYAML -MData::Dumper -e 'print Dumper YAML::Load(join("",<>))' $@ +} + +################################################################################# +# +# CHECK SHELL +# +################################################################################# +# NB 08.07.15 case "$BASH" in +# NB 08.07.15 */bash) ;; +# NB 08.07.15 *) +# NB 08.07.15 case "$SHELL" in +# NB 08.07.15 */bash) ;; +# NB 08.07.15 */zsh) ;; +# NB 08.07.15 *) return 0 ;; +# NB 08.07.15 esac +# NB 08.07.15 ;; +# NB 08.07.15 esac + +################################################################################# +# +# FUNCTIONS - BASH +# +################################################################################# +hl(){ + #cat | grep --color=always -E "(^|($@))" + perl -MTerm::ANSIColor -pe 's/('$@')/color("red").$1.color("reset")/ge' +} + +ls_tree() { + tree -tDphug +} + +find_sort_mtime() { + ( + if [ -n "$DARWIN" ]; then + find $@ -type f -exec stat -f '%m'$'\t''%N' {} \; + else + find $@ -type f -printf "%T@\t%p\n" | sed 's/^\([0-9]\+\)\.0\+/\1/' + fi + ) | sort -k1 -n | cut -f 2 | head +} + +replace_tag_content() { + declare tag; tag="$1"; shift + declare content; content="$@" + perl -ne 'BEGIN { +$tag = shift(@ARGV)." - replace_tag_content"; +$t1 = "# >>> $tag"; +$t2 = "# <<< $tag"; +$content = shift @ARGV; +$content = "$t1\n$content\n$t2\n" +} + +if (/^$t1$/ .. /^$t2$/) { + print "$content" and $content="" if /^$t1$/; +} else { + print "$_"; +} + +END { print "$content" if $content; } +' "$tag" "$content" +} + +_getexp_pcregrep="" +getexp() { + [ -z "$*" -o "$1" == "-h" -o "$1" == "--help" ] && echo "Usage: $FUNCNAME [capture number|default 0] PERL_REGEXP FILES..." && return + declare exp num + num=0; case "$1" in [0-9]*) num=$1; shift ;; esac + exp=$1; shift + + if [ -z "$_getexp_pcregrep" ]; then + _getexp_pcregrep=0 + which pcregrep > /dev/null && _getexp_pcregrep=1 + fi + + if [ $_getexp_pcregrep = 1 ]; then + pcregrep -o${num} "$exp" $@ + else + perl -ne 'BEGIN{$e=shift @ARGV; $n=shift(@ARGV) or 0; $e="($e)" and $n=1 if $n==0} (@_=m{$e}) and ($n<=scalar(@_)) and print ($n==0 ? $_[0] : $_[$n-1].chr(10))' "$exp" "$num" $@ + fi + return +} + +radio_play() { +perl -e ' +@_=grep{$_} split("\n"," +FranceInter | http://audio.scdn.arkena.com/11008/franceinter-midfi128.mp3 +Indie | http://107.155.126.42:17160/listen.pls +FranceInfo | http://audio.scdn.arkena.com/11006/franceinfo-midfi128.mp3 +FranceCulture | http://audio.scdn.arkena.com/11010/franceculture-midfi128.mp3 +BBC 1 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p +BBC 2 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p +BBC 3 | http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls +BBC 4 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p +BBC 5 live | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5live_mf_p +BBC 6 | http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p +"); +if (@ARGV) { $play=shift @ARGV; } else { + $i=1; + map{printf("%2d | %s\n",$i++,$_)} @_; + print "\nChoose one > "; + chomp($play=<>); +} +$play eq "" && exit; @_ = $_[$play-1] =~ /^(.*?)\s*\|\s*(.*?)$/ or exit; +print "[ $play - ".$_[0]." ]\n\n"; +exec "mplayer",$_[1]; +' "$@" +}