You are not logged in.

#1 2012-09-10 10:34:01

sillyousu
Member
Registered: 2012-08-09
Posts: 1

shell script may slow down terminal opening

script

Here is a piece of script on wiki,

alias archnews="echo -e \"$(echo $(curl --silent http://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | sed -e 's/&lt;\/a&gt;/@/g' | sed -e 's/<title>/\\n\\n\\n\\t:: \\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/&lt;p&gt;/\n/g' | sed -e 's/&lt;a href\=\"\([^\"]*\)\"&gt;\([^@]*\)@/\\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/&lt;li&gt;/\n \\e[01;34m*\\e[00;37m /g' | sed -e 's/<[^>]*>/ /g' | sed -e 's/&lt;.*&gt;//g')\n\n\""

I found it would slow down the terminal from opening under slow network connection (or without network).

It take  about 1 second to open a new terminal with it in .bashrc.

Forgive my English.

Last edited by sillyousu (2012-09-10 14:23:40)

Offline

#2 2012-09-10 10:57:27

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: shell script may slow down terminal opening

Take this command as an example:
$ alias thetime="echo $(date)"
$ thetime
Mon Sep 10 12:54:38 CEST 2012
$ sleep 10
$ thetime
Mon Sep 10 12:54:38 CEST 2012

The $() command in double quotes is launched once at shell start up. If news comes while the shell stays open, this alias won't actually fetch the news.

Offline

Board footer

Powered by FluxBB