View previous topic :: View next topic |
Author |
Message |
slarti` Retired Dev
Joined: 20 Sep 2003 Posts: 376 Location: UK
|
Posted: Sat Jun 19, 2004 11:59 pm Post subject: ZSH users (lovers?) thread |
|
|
ZSH is a fantastic shell, both for programming and day-to-day use. Much like a small business with a great product but not enough capital to market it, ZSH doesn't really have the same amount of users as bash, simple because everyone is constantly shouting out how good bash is.
Some of the things ZSH can do:
- Tab completion, but more advanced than bash. It ships with completion for Portage, including emerge. Some other examples - say you type killall<tab>, it will come up with a list of process names to kill. If you type modprobe <tab>, it will come up with a list of available module names for your current kernel. If you type ls -<tab>, it ill come up with a list of options for ls. There are literally hundreds (maybe more?) commands with tab completion in zsh.
- Lots of builtin functions. ZSH has built in functions such as preexec() and chpwd(). If you're wondering why the hell that's of any use, I'll give you an example. I wrote a function for my zshrc that renames the terminal title or the screen window title depending on what was last run. After that is finished, it sets the title to user@host:/workdir. Have a look.
- Mail checking. Although bash has a little-known environment variable to control this, it can only handle Unix-style spool mbox's. If you compile ZSH with the maildir USE flag, it can handle maildirs/MHs too.
- Right sided prompt. Using the RPROMPT environment variable, you can have a prompt on the right hand side too.
- MIME. Use the mailcap/mime.types files, ZSH knows what to load when you enter a path leading to a file of such and such MIME type. If I set up everything ending in ogg to be run by ogg123, every time a enter a path to an ogg file, it will play it.
- Maturity. ZSH has been going since 1990, and is still actively developed.
Here are some screenshots of it in action:
http://edgeoftheinterweb.org.uk/docs/zsh/unzip.png
http://edgeoftheinterweb.org.uk/docs/zsh/option.png
http://edgeoftheinterweb.org.uk/docs/zsh/mailbox.png
ZSH is not difficult to learn. In fact, in nearly all basic cases, it is syntactically the same as bash. Although ZSH is more closely related to KSH, you can barely notice the difference with bash until you start moving on to more advanced scripting, at which point ZSH's refined syntax really comes into its own. For tcsh and csh weirdos, there are options to make the shell immitate these.
I know that at least three Gentoo developers use ZSH - spider, rac and usata. I'm sure there are more.
Spider put up his zshrc around which most of mine is based on, however, I have added many things to mine. That lives here. Mine is up here. It might be slightly out of date and missing the MIME stuff I just found out about as I can't get weex to compile on amd64 and I'm too tired/drunk to upload by hand.
More reading:
http://zsh.sunsite.dk/Intro/intro_toc.html - An introduction to ZSH.
http://www.acm.uiuc.edu/workshops/zsh/toc.html - The ZSH workshop.
http://www.zsh.org/ - The ZSH homepage. _________________ Gentoo/AMD64, shell-tools, net-mail, vim, recruiters
IRC: slarti @ irc.freenode.net
Devspace |
|
Back to top |
|
|
rawoul n00b
Joined: 27 Dec 2003 Posts: 65
|
Posted: Sun Jun 20, 2004 1:00 am Post subject: |
|
|
Three things i love in zsh :
- The incredible completion system. Colors on files like when u do a ls, the menu system when u press 2 times tab (move the cursor with arrows), and the mime type cheking.
- The advanced globbing. For example u can use **/* to generate all filenames going recursively in directories. If u want only the directories, just do **/*(/), etc... for example u want to set permissions in all subdirectories :
do a chmod 755 **/*(/); chmod 644 **/*(.).
You could do that with a find . -type d -print0 | xargs -0 chmod 755 but it's less practical.
- The zmv builtin. It is an advanced mv. If u want to save all you files in another directory you just have to do zmv -W *.bak backup/*.
See a screenshot of my zsh here, and my config is here. |
|
Back to top |
|
|
nighty Apprentice
Joined: 10 Aug 2003 Posts: 217 Location: right behind you.
|
Posted: Sun Jun 20, 2004 7:37 am Post subject: |
|
|
thanks for the thread, i was really interested in zsh.
whats the best way to learn it besides basic use..is there a good tutorial out there? |
|
Back to top |
|
|
slarti` Retired Dev
Joined: 20 Sep 2003 Posts: 376 Location: UK
|
Posted: Sun Jun 20, 2004 7:56 am Post subject: |
|
|
The man pages are well written but rather long (they are divided into several, but the total number of lines is around 45,000). They are more useful if you know what you're looking for. You might want to try here, here and this is very useful too. _________________ Gentoo/AMD64, shell-tools, net-mail, vim, recruiters
IRC: slarti @ irc.freenode.net
Devspace |
|
Back to top |
|
|
placeholder Advocate
Joined: 07 Feb 2004 Posts: 2500
|
Posted: Sun Jun 20, 2004 8:58 am Post subject: |
|
|
Well I'm emerging it right now and then I'm going to set it as the shell for my normal account. Is there anything else I have to do to use it?
EDIT: Well I'm using it as my shell and it seems really nice and faster than bash even. How do I change what it says though? What I mean is that it says:
Fygor%
Instead of my name and stuff. Can I just copy my ~/.bashrc as my ~/.zshrc file? |
|
Back to top |
|
|
slarti` Retired Dev
Joined: 20 Sep 2003 Posts: 376 Location: UK
|
Posted: Sun Jun 20, 2004 11:04 am Post subject: |
|
|
Nope, I'm afraid you have to make your own. If you would like to see some of the things I mentioned download you can try[ur=]http://edgeoftheinterweb.org.uk/files/dot.zshrc]mine[/url]. _________________ Gentoo/AMD64, shell-tools, net-mail, vim, recruiters
IRC: slarti @ irc.freenode.net
Devspace
Last edited by slarti` on Sun Jun 20, 2004 12:44 pm; edited 2 times in total |
|
Back to top |
|
|
placeholder Advocate
Joined: 07 Feb 2004 Posts: 2500
|
Posted: Sun Jun 20, 2004 11:15 am Post subject: |
|
|
I switched back to bash for a bit but I'm going to go back to zsh and try that out. |
|
Back to top |
|
|
nighty Apprentice
Joined: 10 Aug 2003 Posts: 217 Location: right behind you.
|
Posted: Sun Jun 20, 2004 11:26 am Post subject: |
|
|
Quote: | I switched back to bash for a bit but I'm going to go back to zsh and try that out. |
a meta stable shell state |
|
Back to top |
|
|
Abraxas l33t
Joined: 25 May 2003 Posts: 814
|
Posted: Sun Jun 20, 2004 1:52 pm Post subject: |
|
|
I switched to zsh a few months ago and I'm not looking back. _________________ Time makes more converts than reason. - Thomas Paine
Travel is fatal to prejudice, bigotry, and narrow-mindedness, and many of our people need it sorely on these accounts. - Mark Twain |
|
Back to top |
|
|
Konsti l33t
Joined: 10 Dec 2002 Posts: 691
|
Posted: Sun Jun 20, 2004 4:50 pm Post subject: |
|
|
Pwnz3r wrote: | I switched back to bash for a bit but I'm going to go back to zsh and try that out. |
me 2, me 2 Well, actually I switched back to bash but now I am finally in love with zsh and use and compile it even for my embedded systems
Konsti |
|
Back to top |
|
|
minhtang Tux's lil' helper
Joined: 17 Oct 2003 Posts: 76
|
Posted: Mon Jun 21, 2004 4:50 am Post subject: |
|
|
zsh completion feature is totally awesome, heck completing hostname, username with ssh m<tab>@7<tab>. Not to mention programmable completion. And what's with the ** wildcards ? find used to be one of the CLI utlility that I used quite often. Now with zsh **, find is on vacation. Heck, I am still reading the manual for zsh once in a while to see what I am missing, and it seems like I still miss quite alot. _________________ Three minutes of thought would suffice to find this out. But then, thought is irksome, and three minutes is a rather long time.
-- A.E. Houseman |
|
Back to top |
|
|
placeholder Advocate
Joined: 07 Feb 2004 Posts: 2500
|
Posted: Mon Jun 21, 2004 5:08 am Post subject: |
|
|
If this switch follows my switch to Fluxbox then give me a couple of days. lol |
|
Back to top |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Mon Jun 21, 2004 2:43 pm Post subject: |
|
|
You mentioned the emerge/modprobe tab completion was built in, however I can't get it to work.
I merged zsh, and then ran zsh. When I did my PS1 was all messed up, but I guess that its just not compatible with zsh. However when I do modprobe <tab>, all it does is list the dir in my folder. It also does the same thing for emerge. Is there an option that needs to be turned on, or am I not running it properly? |
|
Back to top |
|
|
minhtang Tux's lil' helper
Joined: 17 Oct 2003 Posts: 76
|
Posted: Mon Jun 21, 2004 2:52 pm Post subject: |
|
|
Well, you need to autoload -U compinit, and then call compinit. Look at spider's .zshrc at http://dev.gentoo.org/~spider/zshrc for more info _________________ Three minutes of thought would suffice to find this out. But then, thought is irksome, and three minutes is a rather long time.
-- A.E. Houseman |
|
Back to top |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Mon Jun 21, 2004 3:04 pm Post subject: |
|
|
Thanks, sorry I missed those links in the original thread, somethimes when links are displayed like that I completly miss them.
I have been playing with zsh for a couple of minutes now, and I must say some of the features it has are amazing. |
|
Back to top |
|
|
nsahoo l33t
Joined: 17 Jul 2003 Posts: 618
|
Posted: Mon Jun 21, 2004 4:20 pm Post subject: |
|
|
I had tried it a few years back. I looked at csh and it's variants and sh and all it's variants. I figured csh is not my cup of tea. And in bourne shell category, zsh was the ruler, but, before you get urself too invested into a shell and all it's features, i thought, i gotta consider if i am going to have in all the *nix system I am going to touch, because more often than not, shell will be my window to the machine. Clearly sh will be there, but it's too primitive. So, I decided on bash and haven't looked back ever since.
P.S. and yes, ksh is a good one if any system doesn't have bash. I was using it for some time. it's no way related to kde, if you are wondering |
|
Back to top |
|
|
t0rtois3 n00b
Joined: 20 Feb 2004 Posts: 17
|
Posted: Mon Jun 21, 2004 8:58 pm Post subject: |
|
|
To get apm battery working as a rather froody thing on the prompt:
Code: | function precmd {
PR_APM_RESULT=`cat /proc/apm`
PR_APM='${PR_APM_RESULT[(w)7]%
}
Prompt=$'${(e)PR_APM%}% '
|
i whipped this up myself, its a bit of a hack but it works. |
|
Back to top |
|
|
sabo n00b
Joined: 20 Nov 2003 Posts: 5
|
Posted: Tue Jun 22, 2004 1:21 am Post subject: |
|
|
One of the things you can do (not sure if it works in your cases, I forget (but 90% sure it'll fix it) ) is type to preview all possible preset fonts. then to chage the prompt Code: | prompt <prompt-name> <prompt-colors> |
for instance, mine is Code: | prompt elite2 blue red |
and it looks like :
(ryan@demosthenes)(230/pts)(09:11pm:06/21/04)-
(%:~)-
I love zsh. I haven't gotten into the scripting stuff much, but I love the completions. One problem I have is whenever I hit delete, home, end, or anything in that area it capitalizes the letters and screws up the command. |
|
Back to top |
|
|
minhtang Tux's lil' helper
Joined: 17 Oct 2003 Posts: 76
|
Posted: Tue Jun 22, 2004 3:33 am Post subject: |
|
|
You might want to read the manual page for zle, if that's the case. I really don't use the home and end keys much anyway, since I am used to C-e and C-a anyway. _________________ Three minutes of thought would suffice to find this out. But then, thought is irksome, and three minutes is a rather long time.
-- A.E. Houseman |
|
Back to top |
|
|
allucid Veteran
Joined: 02 Nov 2002 Posts: 1314 Location: atlanta
|
Posted: Tue Jun 22, 2004 11:10 am Post subject: |
|
|
does zsh support emacs-style keybindings like bash does? (C-a, C-k, C-e, C-y, etc) |
|
Back to top |
|
|
minhtang Tux's lil' helper
Joined: 17 Oct 2003 Posts: 76
|
Posted: Tue Jun 22, 2004 2:43 pm Post subject: |
|
|
Yup, bindkeys -e is the way to go _________________ Three minutes of thought would suffice to find this out. But then, thought is irksome, and three minutes is a rather long time.
-- A.E. Houseman |
|
Back to top |
|
|
apeitheo Apprentice
Joined: 09 Jan 2004 Posts: 222
|
Posted: Tue Jun 22, 2004 4:18 pm Post subject: |
|
|
Hmm, maybe I'll give this a spin, although I'm kinda reluctant to switch away from the wide-used bash. |
|
Back to top |
|
|
apeitheo Apprentice
Joined: 09 Jan 2004 Posts: 222
|
Posted: Tue Jun 22, 2004 6:53 pm Post subject: |
|
|
Wow, I just tried it, and I love it, especially the completion feature. It doesn't look like I'm going back |
|
Back to top |
|
|
t0rtois3 n00b
Joined: 20 Feb 2004 Posts: 17
|
Posted: Tue Jun 22, 2004 7:57 pm Post subject: |
|
|
on bash pg up and pg dn did this history completion thing, zsh just types a ~ instead is there a way to get the completion ting working? |
|
Back to top |
|
|
NME Apprentice
Joined: 18 Nov 2003 Posts: 168 Location: The Netherlands
|
Posted: Wed Jun 23, 2004 4:28 pm Post subject: |
|
|
im definately trying this thing out, why the heck not?
good startpost, made me want to know what the buzz was immediately! _________________ f# that. |
|
Back to top |
|
|
|