| View previous topic :: View next topic |
| Author |
Message |
Satoshi Apprentice


Joined: 06 Nov 2006 Posts: 179 Location: Brazil
|
Posted: Sun Oct 24, 2010 4:27 am Post subject: |
|
|
Just switched and it's been working great!
Really like all of zsh's functions.
| Gogiel wrote: | My PROMPT is
| Code: | | PROMPT=$'%{\e[0;32m%}%B[%b%{\e[0m%}%n%{\e[0;32m%}@%{\e[0m%}%(4c,./%1~,%~)%{\e[0;32m%}%B]%b% %(?,%{\e[0;32m%}:%)%{\e[0m%},%{\e[0;31m%}:(%{\e[0m%}) %# ' |
Last part is tricky. When previous program exit with error there's red ' ' in prompt. Otherwise there's green ' '. |
How can I change that to make the % or # turn green or red, instead of the smiling face? |
|
| Back to top |
|
 |
ppurka Advocate

Joined: 26 Dec 2004 Posts: 2782
|
Posted: Sun Oct 24, 2010 5:44 am Post subject: |
|
|
| Satoshi wrote: | Just switched and it's been working great!
Really like all of zsh's functions.
| Gogiel wrote: | My PROMPT is
| Code: | | PROMPT=$'%{\e[0;32m%}%B[%b%{\e[0m%}%n%{\e[0;32m%}@%{\e[0m%}%(4c,./%1~,%~)%{\e[0;32m%}%B]%b% %(?,%{\e[0;32m%}:%)%{\e[0m%},%{\e[0;31m%}:(%{\e[0m%}) %# ' |
Last part is tricky. When previous program exit with error there's red ' ' in prompt. Otherwise there's green ' '. |
How can I change that to make the % or # turn green or red, instead of the smiling face? | Remove the % or # from the end, and insert it in place of the smilies. _________________ emerge --quiet redefined | E17 vids: I, II |
|
| Back to top |
|
 |
ppurka Advocate

Joined: 26 Dec 2004 Posts: 2782
|
Posted: Sun Oct 24, 2010 5:50 am Post subject: |
|
|
| mv wrote: | | ppurka wrote: | | 1. Use the following to automatically rehash. Then you don't need to alias emerge. |
This will not work if you do not use autocompletion for the new command (i.e. if you "just" type it). Moreover, if the autocompletion finds another (existing) command it will also not rehash and thus not show the new alternative. I guess these are most of the cases when you installed something new. Moreover, IMHO it is a bit too overdone to rehash that often. If you have really such a fast machine that you do not really care about rehashing time, you can also rehash in the precmd hook (i.e. every time before the prompt is displayed). | I never thought that rehashing took a lot of time. I never noticed any lag on my core2duo laptop which usually runs at 800MHz.
But maybe you are right, simply putting rehash in precmd would be more efficient I believe. Only thing is that it would work on the terminal I am working on, and then it won't work (until I press enter) on some other terminal that remained open while the new program was being installed. _________________ emerge --quiet redefined | E17 vids: I, II |
|
| Back to top |
|
 |
Krog Apprentice


Joined: 26 Jun 2007 Posts: 251 Location: Roma, Italy
|
Posted: Sun Oct 24, 2010 6:48 am Post subject: |
|
|
for now i still use bash for root and zsh only for my normal user...
so if I emerge (root of course) and then i type "exit" i have to rehash?
So the other shells?
What happens exactly if i don't? |
|
| Back to top |
|
 |
mv Advocate


Joined: 20 Apr 2005 Posts: 2589
|
Posted: Sun Oct 24, 2010 5:37 pm Post subject: |
|
|
| Krog wrote: | for now i still use bash for root and zsh only for my normal user...
so if I emerge (root of course) and then i type "exit" i have to rehash? |
Yes, but this is not related with the question of whether the shells are different. You would have the same issue if both are zsh or both are bash.
| Quote: | | What happens exactly if i don't? |
If you installed a new command, the running shell will not find this new command in the path. |
|
| Back to top |
|
 |
Krog Apprentice


Joined: 26 Jun 2007 Posts: 251 Location: Roma, Italy
|
Posted: Sun Oct 24, 2010 7:02 pm Post subject: |
|
|
sorry if i don't understand:
if i install... for example, mplayer
and i don't rehash
i can't do "mplayer foo.avi"? |
|
| Back to top |
|
 |
mv Advocate


Joined: 20 Apr 2005 Posts: 2589
|
Posted: Sun Oct 24, 2010 7:19 pm Post subject: |
|
|
| Krog wrote: | sorry if i don't understand:
if i install... for example, mplayer
and i don't rehash
i can't do "mplayer foo.avi"? |
Yes, if mplayer was never installed before (more precisely, if there was no mplayer executable in $PATH before you emerged mplayer): If you type just "mplayer ..." (and not "/usr/bin/mplayer ...") the shell just looks up where "mplayer" was in PATH at the last rehash (typically at startup) - if there was no such binary before, it will not find that command. |
|
| Back to top |
|
 |
Krog Apprentice


Joined: 26 Jun 2007 Posts: 251 Location: Roma, Italy
|
Posted: Mon Oct 25, 2010 5:19 am Post subject: |
|
|
| mv wrote: | | Krog wrote: | sorry if i don't understand:
if i install... for example, mplayer
and i don't rehash
i can't do "mplayer foo.avi"? |
Yes, if mplayer was never installed before (more precisely, if there was no mplayer executable in $PATH before you emerged mplayer): If you type just "mplayer ..." (and not "/usr/bin/mplayer ...") the shell just looks up where "mplayer" was in PATH at the last rehash (typically at startup) - if there was no such binary before, it will not find that command. |
this is really a very annoying issue....
and i still have problems under kde with "home" and "end" buttons of my keyboard under kde. With:
| Code: | typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
bindkey "${key[Home]}" beginning-of-line
bindkey "${key[End]}" end-of-line |
outside X they work, but under kde still not! |
|
| Back to top |
|
 |
Krog Apprentice


Joined: 26 Jun 2007 Posts: 251 Location: Roma, Italy
|
Posted: Sat Nov 13, 2010 6:11 am Post subject: |
|
|
still the same problem....  |
|
| Back to top |
|
 |
Krog Apprentice


Joined: 26 Jun 2007 Posts: 251 Location: Roma, Italy
|
Posted: Sat Nov 13, 2010 6:29 am Post subject: |
|
|
| Krog wrote: | still the same problem....  |
found a nice way to solve it:
just typing cat and then pushing the button, it shows exactly the code of the button
on my system:
| Code: | krog@krogpc ~ % cat
^[[H^C
|
for home, and
| Code: | krog@krogpc ~ % cat
^[[F |
for end
so adding:
| Code: | key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
bindkey "${key[Home]}" beginning-of-line
bindkey "${key[End]}" end-of-line
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
|
makes home and end buttons working on konsole AND tty |
|
| Back to top |
|
 |
Satoshi Apprentice


Joined: 06 Nov 2006 Posts: 179 Location: Brazil
|
Posted: Sat Nov 13, 2010 11:18 pm Post subject: |
|
|
| Anyone know if there's a way to make the history persistent, as in bash (across reboots, etc)? |
|
| Back to top |
|
 |
BitJam Advocate

Joined: 12 Aug 2003 Posts: 2248 Location: Silver City, NM
|
Posted: Sun Nov 14, 2010 12:28 am Post subject: |
|
|
Here is what I use. I don't think it is all needed and you probably don't want all of it. For example, the extended_history option adds a timestamp to each line which you may not want. I think the first three lines will do what you want.
| Code: | export HISTSIZE=100000
export HISTFILE="${HOME}/.zhistory/zhistory"
export SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt extended_history
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
setopt HIST_REDUCE_BLANKS |
Currently my ~/.zshistory directory contains 355 files which hold 15K lines of history. |
|
| Back to top |
|
 |
Satoshi Apprentice


Joined: 06 Nov 2006 Posts: 179 Location: Brazil
|
Posted: Sun Nov 14, 2010 4:54 am Post subject: |
|
|
| BitJam wrote: | Here is what I use. I don't think it is all needed and you probably don't want all of it. For example, the extended_history option adds a timestamp to each line which you may not want. I think the first three lines will do what you want.
| Code: | export HISTSIZE=100000
export HISTFILE="${HOME}/.zhistory/zhistory"
export SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt extended_history
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
setopt HIST_REDUCE_BLANKS |
Currently my ~/.zshistory directory contains 355 files which hold 15K lines of history. |
Perfect! |
|
| Back to top |
|
 |
Alex Libman n00b


Joined: 26 May 2010 Posts: 39 Location: Leaving New Hampshire
|
Posted: Mon Nov 22, 2010 2:33 am Post subject: |
|
|
I'm a big fan of zsh, and it will probably be the only base shell (i.e. /bin/sh and /bin/ksh replacement) in my modernized pure-copyFREE redistribution of OpenBSD.
I can understand GNU/Linux being married to bash, but Apple and Haiku OS really goofed when they chose bash over zsh - GNU is not UNIX, and UNIX is not GNU. Korn is missing some very useful features, and (t)csh has syntax issues, so I think all non-GNU projects should use zsh by default.
I'd also like to see more software packages provide zsh auto-completion support, which is particularly convenient for package management commands, any commands where you specify modes (ex. ffmpeg), etc. |
|
| Back to top |
|
 |
Satoshi Apprentice


Joined: 06 Nov 2006 Posts: 179 Location: Brazil
|
Posted: Mon Nov 22, 2010 4:23 am Post subject: |
|
|
| Alex Libman wrote: | I'm a big fan of zsh, and it will probably be the only base shell (i.e. /bin/sh and /bin/ksh replacement) in my modernized pure-copyFREE redistribution of OpenBSD.
I can understand GNU/Linux being married to bash, but Apple and Haiku OS really goofed when they chose bash over zsh - GNU is not UNIX, and UNIX is not GNU. Korn is missing some very useful features, and (t)csh has syntax issues, so I think all non-GNU projects should use zsh by default.
I'd also like to see more software packages provide zsh auto-completion support, which is particularly convenient for package management commands, any commands where you specify modes (ex. ffmpeg), etc. |
Have you seen fish? It also appears to be very good. |
|
| Back to top |
|
 |
Alex Libman n00b


Joined: 26 May 2010 Posts: 39 Location: Leaving New Hampshire
|
Posted: Mon Nov 22, 2010 5:05 am Post subject: |
|
|
Um, I've just troll-ranted about copyFREE license issues. Fish is licensed as very market-unfriendly GPL.
Plus fish is just simply a bad idea right off the bat: yet another shell that breaks POSIX/etc traditions, but isn't as flexible as ipython and other scripting language shells. I believe in a dichotomy between tradition and objective innovation, and for the latter what we really need is JavaScript (aka TheScript) everywhere, including the UNIX command shell. |
|
| Back to top |
|
 |
avx Veteran


Joined: 21 Jun 2004 Posts: 1831
|
Posted: Fri Jun 03, 2011 12:35 pm Post subject: |
|
|
Found this yesterday, imho pretty nifty. FISH like 'live' syntax coloring for ZSH:
https://github.com/nicoulaj/zsh-syntax-highlighting _________________ Want to thank me for something? Send me a nice postcard(ask per pm for my address), thank you! |
|
| Back to top |
|
 |
mv Advocate


Joined: 20 Apr 2005 Posts: 2589
|
Posted: Fri Jun 03, 2011 7:00 pm Post subject: |
|
|
| avx wrote: | | Found this yesterday, imho pretty nifty. FISH like 'live' syntax coloring for ZSH |
A live ebuild for this is in the mv overlay (available over layman). |
|
| Back to top |
|
 |
avx Veteran


Joined: 21 Jun 2004 Posts: 1831
|
Posted: Fri Jun 03, 2011 8:51 pm Post subject: |
|
|
| mv wrote: | | avx wrote: | | Found this yesterday, imho pretty nifty. FISH like 'live' syntax coloring for ZSH |
A live ebuild for this is in the mv overlay (available over layman). | Danke  _________________ Want to thank me for something? Send me a nice postcard(ask per pm for my address), thank you! |
|
| Back to top |
|
 |
NotQuiteSane Guru


Joined: 30 Jan 2005 Posts: 444 Location: Klamath Falls, Jefferson, USA, North America, Midgarth
|
Posted: Tue Jul 26, 2011 5:25 am Post subject: |
|
|
| Gogiel wrote: | My PROMPT is
| Code: | | PROMPT=$'%{\e[0;32m%}%B[%b%{\e[0m%}%n%{\e[0;32m%}@%{\e[0m%}%(4c,./%1~,%~)%{\e[0;32m%}%B]%b% %(?,%{\e[0;32m%}:%)%{\e[0m%},%{\e[0;31m%}:(%{\e[0m%}) %# ' |
Last part is tricky. When previous program exit with error there's red ' ' in prompt. Otherwise there's green ' '. |
Very nice. I used a good chunk of your code to make my prompt:
| Code: | # NQS's prompt, based off of
# http://forums.gentoo.org/viewtopic-p-3690849.html?sid=753a61864e669836fc5121f9800360e3#3690849
# and
# http://dotfiles.org/~mental/.zshrc (gave me the idea)
# Also http://www.understudy.net/custom.html#table1 for varibles
PS1=$'%{\e[1;34m%}%~ on terminal %l, %BCommand #%!%b\
%B[%b%n@%m%{\e[0m%}%B]%b %(?,%{\e[0;32m%} OK ,%{\e[0;31m%} FAIL )%# %{\e[0m%}'
RPS1=$'%{\e[1;34m%}20%D-%*%{\e[0m%}' |
Screenshot
.zshrc
NQS _________________ These opinions are mine, mine I say! Piss off and get your own.
As I see it -- An irregular blog, Improved with new location
To delete French language packs from system use 'sudo rm -fr /' |
|
| Back to top |
|
 |
nicoulaj n00b

Joined: 28 Aug 2011 Posts: 1
|
Posted: Sun Aug 28, 2011 12:32 pm Post subject: |
|
|
| I have moved the zsh-syntax-highlighting script and other projects here: http://github.com/zsh-users |
|
| Back to top |
|
 |
|