You are not logged in.

#1 2009-12-07 20:51:05

cytzol
Member
Registered: 2007-06-27
Posts: 10

cope: a command-line program colouriser

cope is a wrapper around various command-line programs that takes their output and adds colours - a sort of ornamental cope, if you will.

It's written in Perl, and requires version >= 5.10, so installation may be a bit complicated if you have to track down the dependencies. It installs several scripts in a directory, each one calling the program it's named after, only highlighting its output using regexes. Then you add this directory to your $PATH, and everything should (hopefully!) be seamless.

Currently it's in release candidate status - I've been using it personally for a few weeks and nothing catastrophic has happened so far, so there's little point me keeping it private.

Screenshots:
df.png
netstat.png

Main site: http://stuff.cytzol.org/cope/
GitHub: http://github.com/cytzol/cope

Offline

#2 2009-12-07 21:34:00

denton
Member
Registered: 2009-12-05
Posts: 13

Re: cope: a command-line program colouriser

Judging by the screen shots, I like it.

Although I do have a small suggestion; show a small section in the site on how it's configured. I haven't downloaded yet, so you may as well explain the setup in comments or a man page, etc., but the configuration excerpt would tell me more about its features and how does it accomplish doing what it does before downloading it.

Offline

#3 2009-12-07 21:36:55

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: cope: a command-line program colouriser

isn't coloring output of commands also what zsh does?


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#4 2009-12-07 22:22:05

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: cope: a command-line program colouriser

I like the look of it a lot too, I'm going to download it and try it once I get the chance. Nice work smile Does it have a wrapper for pacman or do I still need to get around to installing pacman-color?

Dieter@be wrote:

isn't coloring output of commands also what zsh does?

If it does, I would sure like to know. Just another reason to like zsh.

Edit: Just looked in the scripts directory, no pacman. And, is that a wrapper for ls? Can't ls do it's own colors?

Last edited by jac (2009-12-07 22:24:42)

Offline

#5 2009-12-07 22:28:44

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: cope: a command-line program colouriser

the only other way to do this is to install cwrapper, Daisuke_Aramaki often shows colorized commands in most of his screenshot posts, and i believe this is how he does it.

calling existing binaries then colorizing their output is a much better approach IMO.  i'm not sure how cwrapper does it, but i do know it's version of cmake wouldn't work for me so maybe something else is going on.

i assume all the standard redirects will hold with your method (i.e. you keep stdout and stderr intact post-coloring)?

i don't think zsh has anything like this built-in but i could be wrong.

Offline

#6 2009-12-07 22:49:09

cytzol
Member
Registered: 2007-06-27
Posts: 10

Re: cope: a command-line program colouriser

jac wrote:

I like the look of it a lot too, I'm going to download it and try it once I get the chance. Nice work smile Does it have a wrapper for pacman or do I still need to get around to installing pacman-color? And, is that a wrapper for ls? Can't ls do it's own colors?

Thanks! There's no script for pacman because pacman-color does the job already, so I just used that. Same with diff and colordiff.

cope provides extra colours when you use long output (ls -l); it doesn't touch dircolors's tweaking as it does this, so you can happily use them both.

Dieter@be wrote:

isn't coloring output of commands also what zsh does?

I don't know! I've been using zsh for a while now, and haven't found anything in the way of highlighting. (Not to say that it can't do it, zsh sure can do a lot)

denton wrote:

Judging by the screen shots, I like it. Although I do have a small suggestion; show a small section in the site on how it's configured.

Thanks. Good point; I'll add something to the site. There does exist documentation in the form of POD throughout the source files, but you need to download and install cope before you get to see it - the App::Cope documentation in particular shows how it can be configured. GitHub-coloured code doesn't exactly make pleasant reading, though.

Offline

#7 2009-12-07 23:00:31

cytzol
Member
Registered: 2007-06-27
Posts: 10

Re: cope: a command-line program colouriser

brisbin33 wrote:

the only other way to do this is to install cwrapper, Daisuke_Aramaki often shows colorized commands in most of his screenshot posts, and i believe this is how he does it.

calling existing binaries then colorizing their output is a much better approach IMO.  i'm not sure how cwrapper does it, but i do know it's version of cmake wouldn't work for me so maybe something else is going on.

i assume all the standard redirects will hold with your method (i.e. you keep stdout and stderr intact post-coloring)?

cwrapper uses the same approach that cope does - you run programs that run actual programs of the same name. I've never used cmake, so I have no idea what could go wrong, sadly...

If you're redirecting stdout, it doesn't highlight it at all, as 1) this interferes badly with pipes, and 2) you might not end up seeing the final output anyway.

Offline

#8 2009-12-08 05:18:39

ent
Member
Registered: 2008-12-15
Posts: 53

Re: cope: a command-line program colouriser

this is very cool, I just saw it on reddit. how would one go about making a pkgbuild for this?

Offline

#9 2009-12-08 05:37:19

sati
Member
Registered: 2008-03-12
Posts: 22

Re: cope: a command-line program colouriser

I briefly installed this to test it,,it had worked fine for most commands but it appeared to break things,,notably compilation with make, especially under AUR/yaourt,,maybe I did something wrong?

Offline

#10 2009-12-08 06:59:43

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: cope: a command-line program colouriser

ent wrote:

this is very cool, I just saw it on reddit. how would one go about making a pkgbuild for this?

Install abs and use the PKGBUILD-perl.proto template. Or just have a look at some official perl PKGBUILDs.

Offline

#11 2009-12-08 07:56:21

zowki
Member
From: Trapped in The Matrix
Registered: 2008-11-27
Posts: 582
Website

Re: cope: a command-line program colouriser

Can you post your $PS1? I like your fancy 2 line prompt.


How's my programming? Call 1-800-DEV-NULL

Offline

#12 2009-12-08 08:53:13

denton
Member
Registered: 2009-12-05
Posts: 13

Re: cope: a command-line program colouriser

PKGBUILD

# Contributor: denton <e9203.00 gmail com>
pkgname=cope-git
pkgver=20091208
pkgrel=1
pkgdesc='A colourful wrapper for terminal programs'
arch=(any)
url=http://stuff.cytzol.org/cope/
license=('GPL' 'PerlArtistic')
depends=("perl>=5.10")
makedepends=(git)
provides=(cope)
conflicts=(cope)
install=$pkgname.install

_gitroot=git://github.com/cytzol/cope.git
_gitname=cope

build() {
  cd $srcdir

  # Git
  msg 'Connecting to Git server...'

  if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin || return 1
    msg 'The local files are updated.'
  else
    git clone $_gitroot || return 1
  fi

  msg 'Git checkout done or server timeout.'
  msg 'Starting make...'

  rm -rf $srcdir/$_gitname-build
  git clone $srcdir/$_gitname $srcdir/$_gitname-build || return 1
  cd $srcdir/$_gitname-build

  # Build
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
  make || return 1
  make install DESTDIR=$pkgdir || return 1

  # Remove perllocal.pod and .packlist
  find $pkgdir -name perllocal.pod -delete
  find $pkgdir -name .packlist -delete
}

cope-git.install

post_install() {
  echo 'Prepend /usr/share/perl5/vendor_perl/auto/share/dist/Cope/ to $PATH'
}

post_upgrade() {
  post_install
}

First time making a perl package. It puts files that shouldn't be in */site:

/usr/bin/perlbin/site/envpath
/usr/lib/perl5/site_perl/5.10.1/IO/Pty.pm
/usr/lib/perl5/site_perl/5.10.1/IO/Tty.pm
/usr/lib/perl5/site_perl/5.10.1/IO/Tty/
/usr/lib/perl5/site_perl/5.10.1/IO/Tty/Constant.pm
/usr/lib/perl5/site_perl/5.10.1/List/MoreUtils.pm
/usr/lib/perl5/site_perl/5.10.1/Params/Util.pm
/usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.bs
/usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.so
/usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.bs
/usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.so
/usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.bs
/usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.so
/usr/share/perl5/site_perl/5.10.1/Class/Inspector.pm
/usr/share/perl5/site_perl/5.10.1/Class/Inspector/
/usr/share/perl5/site_perl/5.10.1/Class/Inspector/Functions.pm
/usr/share/perl5/site_perl/5.10.1/Env/Path.pm
/usr/share/perl5/site_perl/5.10.1/IO/Stty.pm
/usr/share/perl5/site_perl/5.10.1/IO/stty.pl
/usr/share/perl5/site_perl/5.10.1/Regexp/Common.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/CC.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/SEN.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1035.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1738.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1808.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2384.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2396.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2806.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/fax.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/file.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/ftp.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/gopher.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/http.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/news.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/pop.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/prospero.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tel.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/telnet.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tv.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/wais.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/_support.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/balanced.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/comment.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/delimited.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/lingua.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/list.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/net.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/number.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/profanity.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/whitespace.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/zip.pm

And as shown by the previous list, I haven't fetched these binaries (are they in the repos?):

Env::Path
File::ShareDir
IO::Handle
IO::Pty
IO::Stty
List::MoreUtils
Regexp::Common
Term::ANSIColor

Everything works, except cope_path.pl.

Last edited by denton (2009-12-08 09:14:37)

Offline

#13 2009-12-08 09:08:42

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: cope: a command-line program colouriser

I've tested this for some time now, and I'm not sure that it's that useful... yet. Though I must say that it is nice! Especially since it's perl, been digging through the code and that was even nicer...

Offline

#14 2009-12-08 09:48:22

denton
Member
Registered: 2009-12-05
Posts: 13

Re: cope: a command-line program colouriser

Never mind, someone made a better package with all the modules: http://aur.archlinux.org/packages.php?ID=32514

Offline

#15 2009-12-09 18:52:35

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: cope: a command-line program colouriser

So, I have a question that I wish I knew how to figure out: I have ccache setup by just prepending the /usr/lib/ccache/bin directory to my path so those binaries get run first, how does having cope installed affect that? To be honest, I just setup ccache and left it to figure out how to use it and what not till later, so I don't know how to check if it's being run or not. I tried looking at the scripts cope installs, but I don't know enough perl to make heads or tails of them. So, do I need to have the cope path and the ccache path in a certain order to have it still work OK? Thanks

Offline

#16 2009-12-09 19:55:21

tvale
Member
From: Portugal
Registered: 2008-12-11
Posts: 175

Re: cope: a command-line program colouriser

Looking good!
So far only complain is that when a heavy ls -lh output is colored in the screen, the typing is slow.

Offline

#17 2010-01-13 16:46:21

MkFly
Member
From: Mars
Registered: 2009-12-10
Posts: 141

Re: cope: a command-line program colouriser

zowki wrote:

Can you post your $PS1? I like your fancy 2 line prompt.

This is a great starting point:
http://bbs.archlinux.org/viewtopic.php?id=84386

Last edited by MkFly (2010-01-13 17:00:57)

Offline

#18 2010-01-13 21:03:23

roy_hu
Member
Registered: 2009-10-29
Posts: 85

Re: cope: a command-line program colouriser

cytzol wrote:
jac wrote:

I like the look of it a lot too, I'm going to download it and try it once I get the chance. Nice work smile Does it have a wrapper for pacman or do I still need to get around to installing pacman-color? And, is that a wrapper for ls? Can't ls do it's own colors?

Thanks! There's no script for pacman because pacman-color does the job already, so I just used that. Same with diff and colordiff.

There's also colorgcc. Why're you creating wrappers for gcc and stuff?

Offline

#19 2010-01-27 15:05:30

gnomen
Member
Registered: 2009-01-04
Posts: 5

Re: cope: a command-line program colouriser

I am pretty noob. How to I add this directory to my path?

Last edited by gnomen (2010-01-27 23:52:31)

Offline

#20 2010-01-27 17:33:03

Awake
Member
Registered: 2010-01-21
Posts: 3

Re: cope: a command-line program colouriser

Open your .bashrc file with an editor and add this line

PATH=/usr/share/perl5/vendor_perl/auto/share/dist/Cope:$PATH

save and exit.

Last edited by Awake (2010-01-27 18:50:51)

Offline

#21 2010-01-27 23:54:09

gnomen
Member
Registered: 2009-01-04
Posts: 5

Re: cope: a command-line program colouriser

Thanks! This is great!

Offline

#22 2010-01-28 21:03:02

Berticus
Member
Registered: 2008-06-11
Posts: 731

Re: cope: a command-line program colouriser

Is there a way to customize the colors? Like have it read .dir_colors or something?

Offline

#23 2010-01-29 00:30:17

Renan Birck
Member
From: Brazil
Registered: 2007-11-11
Posts: 401
Website

Re: cope: a command-line program colouriser

This program is made of awesomeness. Thanks!

Offline

#24 2010-02-06 18:40:37

idosh
Member
Registered: 2008-11-07
Posts: 42

Re: cope: a command-line program colouriser

Sorry for the bump, but unfortunately it doesn't work for me.

I've installed cope via aur and and add "/usr/share/perl5/vendor_perl/auto/share/dist/Cope" to $PATH. I've confirmed that both the installation and the addition to the PATH went smoothly.

Any help?

Offline

#25 2010-02-06 18:45:15

prasetyams
Member
From: Jakarta
Registered: 2008-04-29
Posts: 74

Re: cope: a command-line program colouriser

idosh wrote:

Sorry for the bump, but unfortunately it doesn't work for me.

I've installed cope via aur and and add "/usr/share/perl5/vendor_perl/auto/share/dist/Cope" to $PATH. I've confirmed that both the installation and the addition to the PATH went smoothly.

Any help?

Make sure the path to cope is listed first, like so

PATH=/usr/share/perl5/vendor_perl/auto/share/dist/Cope:$PATH

Or, maybe you need to re-source the shell rc file.

Last edited by prasetyams (2010-02-06 18:46:25)


Where's my sig?

Offline

Board footer

Powered by FluxBB