|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
1) How can I receive colors in prompt under zsh ?
2) I have turn on coloring in ls. When i run: ls * | grep john -> bash keep colors of directoris etc... -> zsh lose colors 3) How i sholud use regex in zsh: ps -aux | grep [w]eechat generatin error (only under zsh) why ? Greetings from Poland John |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2007-03-7, 08:32(-08), Johny:
> 1) How can I receive colors in prompt under zsh ? > 2) I have turn on coloring in ls. > When i run: > ls * | grep john > -> bash keep colors of directoris etc... > -> zsh lose colors Neither bash nor zsh have an influence on how ls displays its output. What matters is what options you pass to ls. You probably have an alias defined for ls. In the bash case (maybe in ~/.bashrc), you probably have alias ls='ls --color=always' while with zsh (in ~/.zshrc?): alias ls='ls --color=auto' I would advice against using ls --color=always, because to display in color, ls output extra characters, so when piping to another command, those extra characters may cause trouble. for instance ls --color=always | grep blah | xargs rm would not work because xargs would think you want to remove a file called <Esc>[32mblahblah<Esc>[m when actually you want to remove blahblah. (<Esc>[32m is only of use to a terminal to change the current foreground text color, it is not to grep nor to xargs that treat it as any other character sequence). > > 3) How i sholud use regex in zsh: > ps -aux | grep [w]eechat > generatin error (only under zsh) why ? This is incorrect syntax in both bash and zsh. zsh s you a bit more in telling you that there is an error. [w]eechat is asking the shell to expand the globbing *pattern* into a list of matching files in the current directory. You want to make sure that globbing is not performed by the shell by quoting the "[" character that is a character special to the shell (both to bash and zsh). ps aux | grep '[w]eechat' On some systems: ps -fC weechat -- Stéphane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Johny <Jan.Koprowski@gmail.com>:
> 1) How can I receive colors in prompt under zsh ? Take a look at: man zshcontrib | less -p "OTHER FUNCTIONS" After autoloading and running the 'colors' function, you are able to access foreground and background colors via the associative arrays described in the part of the manual I pointed you to above. Make sure to put '%{%}' around your colors, so zsh's character counting does not get confused. Example: PS1="%{${fg[red]}%}%~%{${reset_color}%}%% " > 2) I have turn on coloring in ls. [...] > 3) How i sholud use regex in zsh: [...] Stéphane answered these already. Regards, Frank -- There are no threads in alt.binaries.pictures.erotica, so there's no gain in using a threaded news reader. -- unknown source |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 7 Mar, 18:16, Stephane CHAZELAS <this.addr...@is.invalid> wrote:
> 2007-03-7, 08:32(-08), Johny: > > > 1) How can I receive colors in prompt under zsh ? > > 2) I have turn on coloring in ls. > > When i run: > > ls * | grep john > > -> bash keep colors of directoris etc... > > -> zsh lose colors > > Neither bash nor zsh have an influence on how ls displays its > output. > > What matters is what options you pass to ls. You probably have > an alias defined for ls. > > In the bash case (maybe in ~/.bashrc), you probably have > > alias ls='ls --color=always' > > while with zsh (in ~/.zshrc?): > > alias ls='ls --color=auto' > > I would advice against using ls --color=always, because to > display in color, ls output extra characters, so when piping to > another command, those extra characters may cause trouble. > > for instance > > ls --color=always | grep blah | xargs rm > > would not work because xargs would think you want to remove a > file called <Esc>[32mblahblah<Esc>[m when actually you want to > remove blahblah. (<Esc>[32m is only of use to a terminal to > change the current foreground text color, it is not to grep nor > to xargs that treat it as any other character sequence). > Thank you for this grate simple examples. (This is very nice )> > > 3) How i sholud use regex in zsh: > > ps -aux | grep [w]eechat > > generatin error (only under zsh) why ? > > This is incorrect syntax in both bash and zsh. zsh s you a > bit more in telling you that there is an error. > > [w]eechat is asking the shell to expand the globbing *pattern* > into a list of matching files in the current directory. You want > to make sure that globbing is not performed by the shell by > quoting the "[" character that is a character special to the > shell (both to bash and zsh). > > ps aux | grep '[w]eechat' > > On some systems: > > ps -fC weechat ps -fC weechat works great I found this example here: [http://www.oreilly.com/catalog/esa3/] and it works (in bash on my computer). Example (i have alias weechat='env TERM=xterm weechat-curses'): Weechat is runing: 1) ps -fC weechat UID PID PPID C STIME TTY TIME CMD 2) ps -aux | grep weechat dziubdziub 3248 0.5 1.1 71472 7172 pts/2 S+ 08:00 0:00 weechat-curses dziubdziub 3258 0.0 0.1 2092 748 pts/1 R+ 08:02 0:00 grep weechat 3) ps -aux | grep [w]eechat johny 3248 0.3 1.1 71472 7172 pts/2 S+ 08:00 0:00 weechat-curses (and error before Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html) sometimes instead of error i get (here for ps -aux | grep [e]kg2): johny 3294 41.0 0.8 78996 5260 pts/2 S+ 08:05 0:00 ekg2 johny 3295 0.0 0.3 9748 2280 pts/2 S+ 08:05 0:00 ekg2 I belive that is wrong syntax in bash/zsh today but what i should to do to get this same effect in zsh today ? > -- > Stéphane On 7 Mar, 18:50, Frank Terbeck <f...@bewatermyfriend.org> wrote: > Johny <Jan.Koprow...@gmail.com>: > > > 1) How can I receive colors in prompt under zsh ? > > Take a look at: man zshcontrib | less -p "OTHER FUNCTIONS" > After autoloading and running the 'colors' function, you are able to > access foreground and background colors via the associative arrays > described in the part of the manual I pointed you to above. > > Make sure to put '%{%}' around your colors, so zsh's character > counting does not get confused. > > Example: > PS1="%{${fg[red]}%}%~%{${reset_color}%}%% " > Thank you Thanks you I have prompt like rainbow:PS1="%{${fg_bold[red]}%}%n%{${fg_bold[green]}%}@%{${fg_bold[blue]}%}%m% {${fg_bold[yellow]}%}:%~%#%{${reset_color}%}" |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 7 Mar 2007 23:08:40 -0800, Johny
<Jan.Koprowski@gmail.com> wrote: > > sometimes instead of error i get (here for ps -aux | grep [e]kg2): > johny 3294 41.0 0.8 78996 5260 pts/2 S+ 08:05 0:00 ekg2 > johny 3295 0.0 0.3 9748 2280 pts/2 S+ 08:05 0:00 ekg2 > > I belive that is wrong syntax in bash/zsh today but what i should to > do to get this same effect in zsh today ? ps aux | grep "[e]kg2" -- If you don't do it, you'll never know what would have happened if you had done it. |
|
![]() |
| Outils de la discussion | |
|
|