You are not logged in.

#1 2004-11-17 19:28:09

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

nano syntax for PKGBUILDs

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.  Most people don't know you can do syntax highlighting in nano, so here's one for PKGBUILD syntax to get your feet wet.

Put this in /etc/nanorc or ~/.nanorc

syntax "pkgbuild" "^PKGBUILD$"
color green "<(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|backup|makedepends|depends|source|md5sums|groups|confilcts|provides|replaces)>"
color brightgreen "build()" "{" "}"
color red "<(cp|mv|cd|mkdir|return)>"
color cyan "<(configure|make|install)>"
color blue "#.*"
color brightwhite "<(DESTDIR|PREFIX|prefix)>"

Now, it's not perfect, for instance, the term "install" appears all over the place... install=package.install, make install, install -m755.... so there's just one color for it.... the colors are pseudo random (I just picked them off the top of my head)...

Offline

#2 2004-11-19 02:06:07

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: nano syntax for PKGBUILDs

BTW. I filed a bug report about nano.
http://bugs.archlinux.org/index.php?do=details&id=1804

It looks for nanorc in /usr/etc not in /etc. Adding --sysconfdir=/etc to configure and recompiling fixes this of course.

I tried to extend your coloring settings. It's not as easy as it looks :-) Not quite how I wanted it to but here it is my /etc/nanorc

set autoindent
set const
set historylog
set nowrap
set smooth
set speller "aspell -c"
set tabsize 4
set backup
set regexp

syntax "pkgbuild" "^.*PKGBUILD$"
color green start="^" end="$"
color cyan "^.*(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces).*=.*$"
color brightcyan "<(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces)>"
color cyan ".install"
color brightwhite "=" "'" "(" ")" """ "#.*$" "," "{" "}"
color brightcyan "($|${|$()(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces|startdir)(|}|))"
color brightred "build()"
color brightred "<(configure|make)>"
color red "<(DESTDIR|PREFIX|prefix|sysconfdir|datadir|libdir|includedir|mandir)>"

I'll try to improve it if I find some time this weekend.
Maybe someone else also has any ideas how cat this be improved and simplified?

Offline

#3 2005-11-27 15:41:52

matsche
Member
From: .at
Registered: 2004-04-27
Posts: 120

Re: nano syntax for PKGBUILDs

i just want to add my nanorc

set autoindent
set const
set historylog
set nowrap
set smooth
set speller "aspell -c"
set regexp 
set fill 72
set multibuffer
set nohelp
set suspend

syntax "pkgbuild" "^.*PKGBUILD$"
color green start="^" end="$"
color cyan "^.*(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces).*=.*$" 
color brightcyan "<(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces)>" 
color cyan ".install" 
color brightwhite "=" "'" "(" ")" """ "#.*$" "," "{" "}"
color brightcyan "($|${|$()(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces|startdir)(|}|))" 
color brightred "build()"
color brightred "<(configure|make)>"
color red "<(DESTDIR|PREFIX|prefix|sysconfdir|datadir|libdir|includedir|mandir)>"

syntax "c-file" ".(c|h)$"
color red "<[A-Z_]{2,}>"
color green "<(float|char|int|void|static|const|struct)>" 
color brightyellow "<(if|while|do|else|case|switch)>"
color brightcyan "^#( )*(define|include|ifn?def|endif|elif|else|if)"

syntax "php" ".php[2345s~]?$"
color brightblue "(.*)("
color blue "$[a-zA-Z_0-9$]*|[=!<>]"
color green "(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|@|while)s"
color green "[.,{}();]"
color red "('.*')|(".*")"
color brightyellow "(#.*|//.*)$"
color brightyellow start="/*" end="*/"
color brightblue "(<?(php)?|?>)"
color white start="?>" end="<?(php)?" 

syntax "HTML" ".html$"
color blue start="<" end=">"
color red "&[^; ]*;"

syntax "patch" ".(patch|diff)$"
color brightgreen "^+.*"
color green "^+++.*"
color brightblue "^ .*"
color brightred "^-.*"
color red "^---.*"
color brightyellow "^@@.*"
color magenta "^diff.*"

syntax "Java source" ".java$"
color green "<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)>"
color red "<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)>"
color cyan "<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)>"
color red ""[^"]*""
color yellow "<(true|false|null)>"
color blue "//.*"
color blue start="/*" end="*/"
color brightblue start="/**" end="*/"
color brightgreen,green " +$"

syntax "ml" ".*.([jrs]?html?|xml|sgml?)$"
color white "^.+$"
color green  start="<" end=">"
color cyan   "<[^> ]+"
color cyan   ">"
color yellow start="<!DOCTYPE" end="[/]?>"
color yellow start="<!--" end="-->"
color red    "&[^;]*;"

## syntax highlighting in xorg.conf
##
syntax "xorg" "xorg.conf$"
color brightwhite "(Section|EndSection|Sub[sS]ection|EndSub[sS]ection)"
# keywords
color yellow "[^A-Za-z0-9](Identifier|Screen|InputDevice|Option|RightOf|LeftOf|Driver|RgbPath|FontPath|ModulePath|Load|VendorName|ModelName|BoardName|BusID|Device|Monitor|DefaultDepth|View[pP]ort|Depth|Virtual|Modes|Mode|DefaultColorDepth|Modeline|+vsync|+hsync|HorizSync|VertRefresh)[^A-Za-z0-9]"
# numbers
color magenta "[0-9]"
# strings
color green ""(\.|[^"])*""
# comments
color white "#.*"

# Generic conf/rc/sh file syntax highlighting
#############################################
syntax "conf/rc/sh" "conf$|rc$|sh$"
color white ".+"
color green "^#.*"

# .nanorc syntax highlighting
#############################
syntax "nanorc" "[.]*nanorc$"
color white "^ *(set|unset).*$"
color cyan "^ *(set|unset) (autoindent|backup|const|cut|fill|keypad|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|regexp|smooth|speller|suspend|tabsize|tempfile|historylog|view)"
color brightwhite "^ *syntax [^ ]*"
color brightblue "^ *set>" "^ *unset>" "^ *syntax>"
color white "^ *color>.*"
color yellow "^ *color (bright)?(black|blue|cyan|green|magenta|red|white|yellow)>"
color magenta "^ *color>"
color green "^#.*$"

this works for nano 1.2.5!!


THX!!
cu matsche

Offline

#4 2005-11-28 04:52:23

shadowhand
Member
From: MN, USA
Registered: 2004-02-19
Posts: 1,142
Website

Re: nano syntax for PKGBUILDs

Thanks all! This a wonderful thread to find (I <3 nano!).


·¬»· i am shadowhand, powered by webfaction

Offline

#5 2005-11-28 19:14:22

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: nano syntax for PKGBUILDs

kick arse! i never knew nano could do all this!

Offline

#6 2006-11-13 16:36:54

matsche
Member
From: .at
Registered: 2004-04-27
Posts: 120

Re: nano syntax for PKGBUILDs

set multibuffer

this doesn't work anylonger in nano2!

I'm still looking for syntax highlighting in nano!


THX!!
cu matsche

Offline

#7 2006-11-13 17:20:26

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: nano syntax for PKGBUILDs

phrakture wrote:

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.  Most people don't know you can do syntax highlighting in nano, so here's one for PKGBUILD syntax to get your feet wet.

Thanks for nanorc, phrakture!
BTW, have you tried mc-colorer from AUR? wink


to live is to die

Offline

#8 2006-11-13 18:02:51

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,121

Re: nano syntax for PKGBUILDs

Thanks a lot for bringing this thread back to life! I really didn't know about the highlighting features of nano....


Dammit, haven't been here in a while. Still rocking Arch. smile

Offline

#9 2007-05-31 02:26:23

judfilm
Member
Registered: 2004-02-12
Posts: 229

Re: nano syntax for PKGBUILDs

Does anyone know how the Installer does its nano colours?

Offline

#10 2007-06-02 16:32:57

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: nano syntax for PKGBUILDs

phrakture wrote:

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.

No way man, why? It only takes a sec to load up vim and power away... *stares menacingly at arrow keys*

Offline

#11 2007-06-04 18:33:12

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: nano syntax for PKGBUILDs

KomodoDave wrote:
phrakture wrote:

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.

No way man, why? It only takes a sec to load up vim and power away... *stares menacingly at arrow keys*

Old thread is oooollld.

Offline

#12 2007-06-04 18:58:22

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: nano syntax for PKGBUILDs

phrakture wrote:
KomodoDave wrote:
phrakture wrote:

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.

No way man, why? It only takes a sec to load up vim and power away... *stares menacingly at arrow keys*

Old thread is oooollld.

Haha, don't dodge the question! =P

Edit: Wait, does that mean you no longer resort to such foolish tactics? wink

- Dave

Last edited by KomodoDave (2007-06-04 18:58:58)

Offline

#13 2007-06-04 20:18:01

stonecrest
Member
From: Boulder
Registered: 2005-01-22
Posts: 1,190

Re: nano syntax for PKGBUILDs

KomodoDave wrote:

Edit: Wait, does that mean you no longer resort to such foolish tactics? wink

- Dave

He's a bigger nano user than ever before.


I am a gated community.

Offline

#14 2007-06-04 21:08:19

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: nano syntax for PKGBUILDs

stonecrest wrote:
KomodoDave wrote:

Edit: Wait, does that mean you no longer resort to such foolish tactics? wink

- Dave

He's a bigger nano user than ever before.

No way! *scoff, chortle*

- Dave

Offline

#15 2007-06-04 21:59:41

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: nano syntax for PKGBUILDs

stonecrest wrote:
KomodoDave wrote:

Edit: Wait, does that mean you no longer resort to such foolish tactics? wink

- Dave

He's a bigger nano user than ever before.

I actually run notepad in wine for quick tasks.

Offline

#16 2007-06-07 08:02:17

judfilm
Member
Registered: 2004-02-12
Posts: 229

Re: nano syntax for PKGBUILDs

Geeting an error with the PKGBUILD syntax (as listed above):

$nano /etc/nanorc

Error in /etc/nanorc on line 54: Bad regex "(": Unmatched ( or \(

Error in /etc/nanorc on line 54: Bad regex "{": Invalid preceding regular expression

Error in /etc/nanorc on line 55: Bad regex "($|${|$()(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces|startdir)(|}|))": Invalid preceding regular expression

Press Enter to continue starting nano.

Any ideas? Thanks.

Offline

#17 2008-10-27 13:15:23

Wikimig
Developer
From: France
Registered: 2004-12-10
Posts: 77
Website

Re: nano syntax for PKGBUILDs

Escape parenthesis and brackets :

## Here is an example for PKGBUILD
##
syntax "pkgbuild" "^.*PKGBUILD$"
color green start="^" end="$"
color cyan "^.*(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces).*=.*$"
color brightcyan "<(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces)>"
color cyan ".install"
color brightwhite "=" "'" "\(" "\)" """ "#.*$" "," "\{" "\}"
#color brightcyan "($|${|$()(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces|startdir)(|}|))"
color brightcyan "($|$\{|$\(\)(pkgname|pkgver|pkgrel|pkgdesc|force|url|license|install|source|md5sums|groups|backup|depends|makedepends|conflicts|provides|replaces|startdir)\(|\}|\))"
color brightred "build()"
color brightred "<(configure|make)>"
color red "<(DESTDIR|PREFIX|prefix|sysconfdir|datadir|libdir|includedir|mandir)>"

Answering a bit late but it could help others smile

Offline

#18 2008-10-27 23:10:09

ChoK
Member
From: France
Registered: 2008-10-01
Posts: 340

Re: nano syntax for PKGBUILDs

Just one year and 3 months
but thank you making me rediscovering the nano experience


Ah, good taste! What a dreadful thing! Taste is the enemy of creativeness.
Picasso
Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away.
Saint Exupéry

Offline

#19 2008-10-28 15:34:33

Wikimig
Developer
From: France
Registered: 2004-12-10
Posts: 77
Website

Re: nano syntax for PKGBUILDs

ChoK wrote:

Just one year and 3 months

lol

I faced the issue yesterday and found the thread while looking for *.nanorc files

Offline

#20 2009-06-03 17:36:36

matsche
Member
From: .at
Registered: 2004-04-27
Posts: 120

Re: nano syntax for PKGBUILDs

hi,
this syntax file PKGBUILD is not working in my nano 2.0.9. The sreen remains black! Any changes needed?

Last edited by matsche (2009-06-03 17:37:00)


THX!!
cu matsche

Offline

#21 2009-06-03 17:42:55

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

Re: nano syntax for PKGBUILDs

1) old
2) no idea. sorry
3) nano? and you found it weird i use joe! tongue


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

Offline

#22 2009-06-07 14:53:12

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: nano syntax for PKGBUILDs

matsche wrote:

hi,
this syntax file PKGBUILD is not working in my nano 2.0.9. The sreen remains black! Any changes needed?

If it used to work and now it doesn't, check what other packages have been updated in the meantime.  Either way, check your /usr/share/nano/pkgbuild.nanorc and /etc/nanorc files.  Maybe those got changed unintentionally.

Offline

#23 2009-06-07 15:36:52

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: nano syntax for PKGBUILDs

phrakture wrote:
KomodoDave wrote:
phrakture wrote:

Hey guys, for simple tasks, I tend to use nano, as it's real lightweight.

No way man, why? It only takes a sec to load up vim and power away... *stares menacingly at arrow keys*

Old thread is oooollld.

and

Dieter@be wrote:

1) old
2) no idea. sorry
3) nano? and you found it weird i use joe! tongue

Here comes the lock! Leave those zombies alone!


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#24 2009-06-07 15:57:47

hokasch
Member
Registered: 2007-09-23
Posts: 1,461

Re: nano syntax for PKGBUILDs

you forgot to push the button

Offline

#25 2009-06-08 06:00:23

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: nano syntax for PKGBUILDs

I did... Fixed wink


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

Board footer

Powered by FluxBB