You are not logged in.
Latest news from Arch Official website (but you can change the source: this script is simply a stupid - but coloured :-D - rss reader):
# The characters "ç, £, §" are used as metacharacters. They should not be encountered in a feed...
echo -e "$(echo $(curl --silent http://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \
sed -e 's/>/ç/g' |
sed -e 's/<\/aç/£/g' |
sed -e 's/href\=\"/§/g' |
sed -e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' |
sed -e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' |
sed -e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' |
sed -e 's/<pç/\n/g' |
sed -e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' |
sed -e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' |
sed -e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' |
sed -e 's/<[^>]*>/ /g' |
sed -e 's/<[^ç]*ç//g' |
sed -e 's/[磧]//g')\n\n"
Last edited by grufo (2012-08-09 23:17:43)
Offline
Or if you want a generic (but still coloured) function for your .bashrc file...:
feed() {
# The characters "ç, £, §" are used as metacharacters. They should not be encountered in a feed...
echo -e "$(echo $(curl --silent $1 | sed -e ':a;N;$!ba;s/\n/ /g') | \
sed -e 's/>/ç/g' |
sed -e 's/<\/aç/£/g' |
sed -e 's/href\=\"/§/g' |
sed -e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' |
sed -e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' |
sed -e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' |
sed -e 's/<pç/\n/g' |
sed -e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' |
sed -e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' |
sed -e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' |
sed -e 's/<[^>]*>/ /g' |
sed -e 's/<[^ç]*ç//g' |
sed -e 's/[磧]//g')\n\n"
}
Usage:
$ feed http://www.archlinux.org/feeds/news
Offline
# Change cd function to enable to go back
function cd() {
if [ $# -lt 1 ]; then
pushd ~ > /dev/null
else
pushd "$@" > /dev/null
fi
}
alias b='popd > /dev/null; pwd'
BTW : is "function" or "alias" use preferable ?
TODE : change dir forward :-p
Offline
Not directly a function, but related.... I found this on identica the other day:
https://github.com/josephwecker/bashrc_dispatch
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Or if you want a generic (but still coloured) function for your .bashrc file...:
feed() { # The characters "ç, £, §" are used as metacharacters. They should not be encountered in a feed... echo -e "$(echo $(curl --silent $1 | sed -e ':a;N;$!ba;s/\n/ /g') | \ sed -e 's/>/ç/g' | sed -e 's/<\/aç/£/g' | sed -e 's/href\=\"/§/g' | sed -e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' | sed -e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' | sed -e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' | sed -e 's/<pç/\n/g' | sed -e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' | sed -e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' | sed -e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' | sed -e 's/<[^>]*>/ /g' | sed -e 's/<[^ç]*ç//g' | sed -e 's/[磧]//g')\n\n" }
Usage:
$ feed http://www.archlinux.org/feeds/news
this is awsome
Offline
function cd() {
if [[ ! $PWD =~ ^$HOME ]];then
builtin cd $1
elif [[ $# -ne 0 ]];then
builtin cd $1
elif [[ -e .git || -e .hg || -e .project_root ]];then
builtin cd
else
while [[ "$PWD" != "$HOME" ]]
do
[[ -e .git || -e .hg || -e .project_root ]] && break
builtin cd ..
done
fi
}
but, it contains a bug, When a directory name includes blank or something wired unusual, this function will fail ;-(
Apple hater. Panda lover.
Offline
# Change cd function to enable to go back function cd() { if [ $# -lt 1 ]; then pushd ~ > /dev/null else pushd "$@" > /dev/null fi } alias b='popd > /dev/null; pwd'
BTW : is "function" or "alias" use preferable ?
TODE : change dir forward :-p
huh. `cd -` always takes you back to the previous directory.
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
BTW : is "function" or "alias" use preferable ?
Nothing wrong with aliases but from the Bash manual:
For almost every purpose, aliases are superseded by shell functions
I'd be surprised if they ever deprecated them.
Edit to add a function. Can't remember where I got it from, but it's not mine.
# nicely formatted mount
nmount() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2=$4="";1') | column -t ; }
Last edited by skanky (2012-08-15 14:26:30)
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
Latest news from Arch Official website (but you can change the source: this script is simply a stupid - but coloured :-D - rss reader):
# The characters "ç, £, §" are used as metacharacters. They should not be encountered in a feed... echo -e "$(echo $(curl --silent http://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \ sed -e 's/>/ç/g' | sed -e 's/<\/aç/£/g' | sed -e 's/href\=\"/§/g' | sed -e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' | sed -e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' | sed -e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' | sed -e 's/<pç/\n/g' | sed -e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' | sed -e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' | sed -e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' | sed -e 's/<[^>]*>/ /g' | sed -e 's/<[^ç]*ç//g' | sed -e 's/[磧]//g')\n\n"
Actually, if you want to ostensively optimize this a bit more, just take out all the piped sed invocations and just use the -e extension repeatedly, e.g.:
echo -e "$(echo $(curl --silent http://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \
sed -e 's/>/ç/g' \
-e 's/<\/aç/£/g' -e \
-e 's/href\=\"/§/g' -e \
-e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' \
-e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' \
-e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' \
-e 's/<pç/\n/g' \
-e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' \
-e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' \
-e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' \
-e 's/<[^>]*>/ /g' \
-e 's/<[^ç]*ç//g' \
-e 's/[磧]//g')\n\n"
As a general rule, the fewer pipes, the better the performance, although this script's bottle neck is most likely comes via the network. In general, sed is an expensive operation as well (as I've found out via hostsblock), so I try to use as much grep and coreutils utilities like tr, cut, etc. as possible.
Check out hostsblock for system-wide ad- and malware-blocking.
Offline
@gaenserich you probably missed this thread https://bbs.archlinux.org/viewtopic.php?id=146850
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
huh. `cd -` always takes you back to the previous directory.
I didn't know that. Thanks :-)
But I tested and it seems to work only once, you can go back to previously once then it loop back.
Nothing wrong with aliases but from the Bash manual:
Ok thanks. I will use alias when I can put every thing in one command line and in function for more complexe things
Offline