You are not logged in.

#1 2016-01-01 20:47:40

John
Member
Registered: 2015-12-20
Posts: 13

cool terminal script fetch

was browsing the web and come across this script
pretty cool you can add images to your terminal

https://github.com/dylanaraps/fetch.sh

Offline

#2 2016-01-02 11:02:42

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: cool terminal script fetch

Nice find (it needs w3m-img for images btw).

Offline

#3 2016-01-02 11:25:33

Snap
Member
Registered: 2015-10-02
Posts: 465

Re: cool terminal script fetch

Great one! Thanks for the link.

The custom image code part is interesting on its own. Darn cool.

Offline

#4 2016-01-02 11:32:02

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: cool terminal script fetch

Thanks John, never seen one with an image display before cool

Offline

#5 2016-01-02 13:21:27

John
Member
Registered: 2015-12-20
Posts: 13

Re: cool terminal script fetch

yeah never seen one with image support so had to share guys not just another fetch script its a great one to sexy up screenshots and well just look cool

Offline

#6 2016-01-02 15:19:08

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: cool terminal script fetch

Is this your script John?

I have a diff here for OpenBSD packages support:
https://github.com/Head-on-a-Stick/fetc … e60b9c6da2

I'll add some more when I can (I'm not good with scripting so don't expect too much big_smile )

EDIT: Added `uptime` support but it generates a trailing comma that I will have to remove somehow.
https://github.com/Head-on-a-Stick/fetc … af3a77290d

I'm not very good at this but it's fun big_smile

Last edited by Head_on_a_Stick (2016-01-02 15:44:50)

Offline

#7 2016-01-02 15:59:52

John
Member
Registered: 2015-12-20
Posts: 13

Re: cool terminal script fetch

@Head_on_a_Stick not my script just found it while browsing around

Offline

#8 2016-01-02 17:53:33

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: cool terminal script fetch

@ Hoas:
This is one possible way of removing the time-stamp prefix and the trailing "," for the OPENBSD case:

uptime=( $(uptime|awk -F, '{ print $1 }') )
unset uptime[0]
uptime="${uptime[@]}"

Edit: this is a bash solution.

Last edited by xaos52 (2016-01-02 17:59:47)

Offline

#9 2016-01-02 18:10:10

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: cool terminal script fetch

^ Thank you very much xaos52!
smile

Unfortunately, uptime(1) is a bit more limited than the GNU/Linux equivalent hmm

The standard output format is:

$ uptime
 6:08PM  up  1:23, 1 user, load averages: 1.14, 1.13, 1.22

At the risk of embarrassing myself [1], this is the best I can do with your example:

$ uptime|awk -F, '{ print $1 }'|awk '{print $3}' 
1:24

I think there may be a more elegant way of doing that -- give me a bit...

[1] Too late!  :8

Offline

#10 2016-01-02 18:41:28

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: cool terminal script fetch

Simpler solution:

uptime=$(uptime|awk -F, '{ print $1 }')
uptime="${uptime# * }"

or, if you don't want the 'up'  prefix neither:

uptime=$(uptime|awk -F, '{ print $1 }')
uptime="${uptime# * up }"

These might not work if the leading space is not there when the minutes are double digits.
In that case you might have to delete the leading space first in a separate command:

uptime=$(uptime|awk -F, '{ print $1 }')
uptime=${uptime# }
uptime="${uptime#* up }"

Last edited by xaos52 (2016-01-02 19:21:40)

Offline

#11 2016-01-02 18:53:26

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: cool terminal script fetch

^ Ha, thank you!

Uptime:  up  2:08

smile

Offline

#12 2016-01-02 18:58:49

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: cool terminal script fetch

xaos52 wrote:
uptime=$(uptime|awk -F, '{ print $1 }')
uptime="${uptime# * up }"

That's the one!

Uptime:  2:13

Thank you so much smile

Offline

#13 2016-01-02 19:04:26

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: cool terminal script fetch

This might not work if the leading space is not there when the minutes are double digits.
In that case you might have to delete the leading space first in a separate command:

uptime=$(uptime|awk -F, '{ print $1 }')
uptime=${uptime# }
uptime="${uptime#* up }"

Should work in all cases.

Last edited by xaos52 (2016-01-02 19:20:17)

Offline

#14 2016-01-03 12:57:22

dylan
New Member
Registered: 2016-01-03
Posts: 3

Re: cool terminal script fetch

Hi there, author of the script here!

I finished rewriting the script from scratch today, see:

https://github.com/dylanaraps/fetch.sh/releases

I'm going to bed now but open an issue on github and I'll work on openbsd support tomorrow morning.

Thanks for using my script!

Edit: I've quickly added the base for OpenBSD support. Thanks the uptime lines xaos52! I've also created an issue on github where you can report issues with the script on OpenBSD to help me get it working.

Now I'm going to bed.

Edit2: The script also works with mksh and sh, all you have to do is change the shebang at the top!

Last edited by dylan (2016-01-03 21:55:24)

Offline

#15 2016-01-03 14:36:55

John
Member
Registered: 2015-12-20
Posts: 13

Re: cool terminal script fetch

welcome dylan really like your script had to share here

Offline

#16 2016-01-03 21:55:40

dylan
New Member
Registered: 2016-01-03
Posts: 3

Re: cool terminal script fetch

John wrote:

welcome dylan really like your script had to share here

Thanks!

Offline

#17 2016-01-04 14:43:37

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: cool terminal script fetch

@dylan,
Debian-based distro's need packages 'w3m' and 'w3m-img' installed to display images
xaos52

Offline

#18 2016-01-04 23:26:39

dylan
New Member
Registered: 2016-01-03
Posts: 3

Re: cool terminal script fetch

xaos52 wrote:

@dylan,
Debian-based distro's need packages 'w3m' and 'w3m-img' installed to display images
xaos52

I only needed to install w3m so I thought they were bundled together. I've added a note to the readme about it.

Thanks.

Offline

Board footer

Powered by FluxBB