Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Gentoo Chat
  • Search

ZSH users (lovers?) thread

Opinions, ideas and thoughts about Gentoo. Anything and everything about Gentoo except support questions.
Post Reply
  • Print view
Advanced search
301 posts
  • Page 1 of 13
    • Jump to page:
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 13
  • Next
Author
Message
slarti`
Retired Dev
Retired Dev
User avatar
Posts: 376
Joined: Sat Sep 20, 2003 3:04 pm
Location: UK
Contact:
Contact slarti`
Website

ZSH users (lovers?) thread

  • Quote

Post by slarti` » Sat Jun 19, 2004 11:59 pm

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
Top
rawoul
n00b
n00b
User avatar
Posts: 65
Joined: Sat Dec 27, 2003 8:07 pm

  • Quote

Post by rawoul » Sun Jun 20, 2004 1:00 am

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.
Top
nighty
Apprentice
Apprentice
User avatar
Posts: 217
Joined: Sun Aug 10, 2003 7:19 am
Location: right behind you.

  • Quote

Post by nighty » Sun Jun 20, 2004 7:37 am

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?
Top
slarti`
Retired Dev
Retired Dev
User avatar
Posts: 376
Joined: Sat Sep 20, 2003 3:04 pm
Location: UK
Contact:
Contact slarti`
Website

  • Quote

Post by slarti` » Sun Jun 20, 2004 7:56 am

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
Top
placeholder
Advocate
Advocate
Posts: 2500
Joined: Sat Feb 07, 2004 12:15 am

  • Quote

Post by placeholder » Sun Jun 20, 2004 8:58 am

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?
Top
slarti`
Retired Dev
Retired Dev
User avatar
Posts: 376
Joined: Sat Sep 20, 2003 3:04 pm
Location: UK
Contact:
Contact slarti`
Website

  • Quote

Post by slarti` » Sun Jun 20, 2004 11:04 am

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].
Last edited by slarti` on Sun Jun 20, 2004 12:44 pm, edited 2 times in total.
Gentoo/AMD64, shell-tools, net-mail, vim, recruiters
IRC: slarti @ irc.freenode.net
Devspace
Top
placeholder
Advocate
Advocate
Posts: 2500
Joined: Sat Feb 07, 2004 12:15 am

  • Quote

Post by placeholder » Sun Jun 20, 2004 11:15 am

I switched back to bash for a bit but I'm going to go back to zsh and try that out. 8)
Top
nighty
Apprentice
Apprentice
User avatar
Posts: 217
Joined: Sun Aug 10, 2003 7:19 am
Location: right behind you.

  • Quote

Post by nighty » Sun Jun 20, 2004 11:26 am

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 :)
Top
Abraxas
l33t
l33t
User avatar
Posts: 814
Joined: Sun May 25, 2003 1:00 pm

  • Quote

Post by Abraxas » Sun Jun 20, 2004 1:52 pm

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
Top
Konsti
l33t
l33t
User avatar
Posts: 691
Joined: Tue Dec 10, 2002 12:42 pm
Contact:
Contact Konsti
Website

  • Quote

Post by Konsti » Sun Jun 20, 2004 4:50 pm

Pwnz3r wrote:I switched back to bash for a bit but I'm going to go back to zsh and try that out. 8)
me 2, me 2 :D 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
Top
minhtang
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 76
Joined: Fri Oct 17, 2003 7:38 am

  • Quote

Post by minhtang » Mon Jun 21, 2004 4:50 am

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
Top
placeholder
Advocate
Advocate
Posts: 2500
Joined: Sat Feb 07, 2004 12:15 am

  • Quote

Post by placeholder » Mon Jun 21, 2004 5:08 am

If this switch follows my switch to Fluxbox then give me a couple of days. lol
Top
jpc82
Guru
Guru
Posts: 326
Joined: Sun Mar 09, 2003 4:31 pm

  • Quote

Post by jpc82 » Mon Jun 21, 2004 2:43 pm

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?
Top
minhtang
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 76
Joined: Fri Oct 17, 2003 7:38 am

  • Quote

Post by minhtang » Mon Jun 21, 2004 2:52 pm

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
Top
jpc82
Guru
Guru
Posts: 326
Joined: Sun Mar 09, 2003 4:31 pm

  • Quote

Post by jpc82 » Mon Jun 21, 2004 3:04 pm

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.
Top
nsahoo
l33t
l33t
User avatar
Posts: 618
Joined: Thu Jul 17, 2003 10:57 pm
Contact:
Contact nsahoo
Website

  • Quote

Post by nsahoo » Mon Jun 21, 2004 4:20 pm

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
Top
t0rtois3
n00b
n00b
Posts: 17
Joined: Fri Feb 20, 2004 2:30 pm

  • Quote

Post by t0rtois3 » Mon Jun 21, 2004 8:58 pm

To get apm battery working as a rather froody thing on the prompt:

Code: Select all

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.
Top
sabo
n00b
n00b
Posts: 5
Joined: Thu Nov 20, 2003 11:40 am

  • Quote

Post by sabo » Tue Jun 22, 2004 1:21 am

One of the things you can do (not sure if it works in your cases, I forget :D(but 90% sure it'll fix it) ) is type

Code: Select all

 prompt -p |less
to preview all possible preset fonts. then to chage the prompt

Code: Select all

prompt <prompt-name> <prompt-colors>
for instance, mine is

Code: Select all

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.
Top
minhtang
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 76
Joined: Fri Oct 17, 2003 7:38 am

  • Quote

Post by minhtang » Tue Jun 22, 2004 3:33 am

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
Top
allucid
Veteran
Veteran
Posts: 1314
Joined: Sat Nov 02, 2002 6:27 pm
Location: atlanta

  • Quote

Post by allucid » Tue Jun 22, 2004 11:10 am

does zsh support emacs-style keybindings like bash does? (C-a, C-k, C-e, C-y, etc)
Top
minhtang
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 76
Joined: Fri Oct 17, 2003 7:38 am

  • Quote

Post by minhtang » Tue Jun 22, 2004 2:43 pm

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
Top
apeitheo
Apprentice
Apprentice
Posts: 222
Joined: Fri Jan 09, 2004 3:47 am

  • Quote

Post by apeitheo » Tue Jun 22, 2004 4:18 pm

Hmm, maybe I'll give this a spin, although I'm kinda reluctant to switch away from the wide-used bash.
Top
apeitheo
Apprentice
Apprentice
Posts: 222
Joined: Fri Jan 09, 2004 3:47 am

  • Quote

Post by apeitheo » Tue Jun 22, 2004 6:53 pm

Wow, I just tried it, and I love it, especially the completion feature. It doesn't look like I'm going back :D
Top
t0rtois3
n00b
n00b
Posts: 17
Joined: Fri Feb 20, 2004 2:30 pm

  • Quote

Post by t0rtois3 » Tue Jun 22, 2004 7:57 pm

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?
Top
NME
Apprentice
Apprentice
User avatar
Posts: 168
Joined: Tue Nov 18, 2003 7:24 pm
Location: The Netherlands

  • Quote

Post by NME » Wed Jun 23, 2004 4:28 pm

im definately trying this thing out, why the heck not?
good startpost, made me want to know what the buzz was immediately!
f# that.
Top
Post Reply
  • Print view

301 posts
  • Page 1 of 13
    • Jump to page:
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 13
  • Next

Return to “Gentoo Chat”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic