10 ms·
Use Zsh
- MatthewPhillips 14y agoThis article really feels like bikeshedding to me. I'm always going to use whatever shell comes default with the OS I'm on (which almost always means Bash), simply because changing the shell is an unnecessary block of time that could instead be used writing software. I need a really good reason to switch, something the equivalent of pipes, and if the #1 reason you can give is "Powerful context based tab completion", I'm confident in dismissing zsh as a cosmetic improvement on bash that I don't need to waste my time on.
- rimantas 14y agoHow much software can you write in three seconds?
- untog 14y agoHow many computers do you use? Having to switch between zsh and bash mentally when you from your dev box to a server can be jarring. For some people it's worth it, for others it isn't.
- grogs 14y agojust stick an exec zsh at the end of your bashrc, wrapper in an if statement if it's not available on all machines on your environment. do people have the same attitude to screen/tmux or vim/emacs (vs nano)?
- amboar 14y agoI don't think untog was talking about the overhead of executing zsh upon starting a new session so much as the mental overhead of the mode change from zsh specific features to those of another shell.
- darkstalker 14y agozsh's tab completion is definitely not cosmetic. It can do very useful things like completing scp destination paths over remote hosts.
- r00fus 14y agoThis is the same logic that keeps me from jailbreaking my iPhone - it's possible and fairly straightforward, but eventually some condition (likely an important iOS point release) causes the situation to revert. f.lux for iOS is tempting me to re-visit this, as it's crucial to me getting a few more Z's at night.
- aerique 14y agoMeanwhile I've been enjoying a jailbroken iPhone for over three years now. How many important iOS updates have there been anyway? All I can recall were the SMS exploit and the PDF exploit for which there was a fix available on Cydia sooner than Apple provided an iOS update.
- nessus42 14y agoPersonally, I spend so much time in the shell that it's definitely worth spending some effort to increase my ability to use it productively. I switched from tcsh to bash about a year ago after decades of using tcsh. Switching to bash was a mistake; I probably should have switched to zsh instead. Bash is broken as an interactive shell in more ways than I can enumerate; it is a constant source of annoyance and frustration. I have no great love for tcsh, but it is far better as an interactive shell, despite the fact that it truly sucks for programming. Re what comes with the OS: I haven't logged into a Unix/Linux box in a decade that hasn't had zsh on it.
- grandalf 14y agojust installed zsh but now my rvm is broken, any quick tips? tried adding the following to .zshrc but it doesn't appear to have fixed the issue: if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
- sstephenson 14y agoHere's another perspective: http://sstephenson.us/posts/on-configuration http://sstephenson.us/posts/on-configuration
- Apreche 14y agoI independently wrote pretty much the same post. http://www.apreche.net/dont-change-the-computer-change-yourself/ http://www.apreche.net/dont-change-the-computer-change-yours...
- darkstalker 14y agoProbably you used Linux at the time it wasn't very mature. I'm running Gentoo now and never had to reinstall to fix things. With modern computers compiling is very fast, most software compiles in less than a minute. I spend more time solving binary compatibility problems with CentOS (at work) than compiling stuff via portage. I recently bought a new video card (nvidia), plugged it and then booted linux. It just worked out of the box. Then I proceeded to boot windows, it started on a low resolution video mode because the current driver failed. So had to download and install latest drivers manually. The whole procedure took like 3 or 4 restarts.
- shazow 14y agoThat's the huge advantage of distros without discrete upgrade paths. I have the same Gentoo install on my desktop since I built it in 2008. Meanwhile I tried Ubuntu on my laptop for a couple of years and every time a new version came out, I tried to upgrade only to find my system borked, hours wasted, and ultimately my giving up and doing a fresh reinstall. And yes, so many more things work "out of the box" today than ever before (as long as it isn't ATI/AMD :P). The Linux ecosystem has grown and improved incredibly over the last few years. I wouldn't dare argue whether it's better than OSX or Windows, but I can comfortably say that it has advanced a much further distance in the last few years.
- achille2 14y agoI can't provide source right now, but Microsoft pretty much said the same thing when they updated handwriting recognition for Windows Tablet PC Edition. In the past they'd go through a procedure where they would learn how you write. But later on, they decided it was most effective for you to learn to write in a way that the handwriting recognition software would understand.
- adambratt 14y agoBeen meaning to start using it for a while. You convinced me to download it and see what all the fuss was over. Couldn't be happier!
- daivd 14y agoGreat!
- ludwigvan 14y ago> In Bash, we often use PgUp to search through the command history. In Zsh you just write part of the command and press Up. This will let you cycle through all command lines that contain what you have written, not just those that begins with it. If you don’t write anything Up works as usual, by cycling through all commands. This is not true, you can do that in Bash too (via .inputrc) http://blog.theliuy.com/2011/inputrc-keyboard-mapping-config-file/ http://blog.theliuy.com/2011/inputrc-keyboard-mapping-config... Edit: Maybe I misunderstood though, does pressing Up really let you search all command lines that contain what you have written, not just those that begins with it? It doesn't seem to do that on my zsh.
- daivd 14y agoYeah, I thought as much. I just mentioned it to help a new user, because the standard in Bash seems to be PgUp and beginning-of-line search, while in Zsh it is Up and full search.
- bryanlarsen 14y agoIn bash, I press ctrl-r and then enter part of the command. additional ctrl-r's cycle.
- bostonvaulter2 14y agoZsh does that as well with the same exact shortcut
- jlgreco 14y agoIt depends on which completion type you want to use. Zsh can do either.
- mathieuh 14y agoAny one else using Fish?
- nagisa 14y agoMe. Just came to tell, that it's even better than zsh, but ultimately it's a matter of preference.
- slurgfest 14y agoWhat are your top reasons to use fish over zsh? (Bearing in mind, of course, that it's ultimately a matter of preference...)
- shadowfiend 14y agoSyntax. I much prefer the fish syntax, even though the fact that it's different from bash can occasionally cause headaches. When I'm mucking with my shell, I'd rather not be remembering [[ -z ]], because I don't do it often. Basically most shells are designed around power, which is fine. Fish is designed around ease-of-use, which I consider to be a better idea since there's already a ton of power in the UNIX tools that are on the system. That's not to say fish isn't powerful, mind you. Just that you detect a different emphasis when using it. Consider setting colors in a prompt, for example. zsh and bash use PS1=$'\e[0;31m$ \e[0m'. Ouch. More recent versions of zsh do let you do PS1="%{$fg[red]%}%n" type stuff, I'll confess. For fish, setting up a colored prompt or whatever: function fish_prompt -d "Write out the prompt" printf '%s%s@%s%s' (set_color brown) (whoami) (hostname|cut -d . -f 1) (set_color normal) # Color writeable dirs green, read-only dirs red printf ' %s%s' (set_color green) (prompt_pwd) # Print git branch if test -d ".git" printf ' %s%s/%s' (set_color normal) (set_color blue) (parse_git_branch) end printf '%s> ' (set_color normal) end It's stuff you already know how to do. It's not an environment variable, it's a function. Commands you use normally. Invoking other regular fish functions/commands. Etc etc. It just feels cleaner (to me).
- slurgfest 14y ago
- fusiongyro 14y agoI used to use zsh but switched back to bash a couple years ago simply because the benefit wasn't worth the trouble. When I first changed back I went to some difficulty to get my PS1 to have color in it. That slowly faded away and now I have a visceral, negative reaction to prompts with that much colorful whizzy fu. Maybe in a few more years I'll trim out the username/hostname/path and become content with just a %.
- slurgfest 14y agoIt faded away because it was too difficult to get the prompt working?
- fusiongyro 14y agoWhen you have access to a lot of machines run by different organizations but not administration privileges on most of them, it's a hassle.
- benvd 14y agoSo put your zsh config in a git repo, clone it wherever you need it and symlink to the repo?
- fusiongyro 14y agoUh huh. Now I have to install git on all those computers as well as make sure there's a recent-enough copy of zsh. Much less work that way. Or I can just use the bash that's already there.
- oinksoft 14y agoYour concern about git however is unrelated to shell choice. I customize bash quite a bit (my own completions, etc.) and maintain dotfiles in a git repository. I have a post-receive hook that tars up my dotfiles and puts them at a public location on my http server that only I know about so that I can easily get them when I'm on a machine without git. I'm not going to do that for every machine, but if I'm stuck debugging something on some odd machine, at the very last I want my vim settings around.
- brcrth 14y agoNo, really. Use what you like/know. I hate posts about "you should use X because I like it".
- JoeAltmaier 14y agometa: I hate posts about "you should hate this post because I don't like it" :)
- notJim 14y agoHow do you ever learn anything or improve your workflow if you never try new things?
- Alan01252 14y agoJust started using Zsh. I never really had any qualms with bash, and so had the mantra if it's not broke don't fix it. Then I worked with a couple of junior developers and noticed them doing some cool looking things on the terminal. Suffice to say I've now switched to Zsh and can't see myself going back to bash any time soon. Thanks junior devs :)
- redsymbol 14y agoI've been using zsh for over ten years. Since one of my best friends (now a computational physicist) convinced me to try it in college. Over time I've temporarily switched to others just to make sure I wasn't being stuck in a rut, but I always have come back to zsh. It's a joy to use as a day to day command line interface. For writing shell scripts, i.e. actual software implemented in shell, I actually prefer bash. In large part because it's more portable, in the sense that any given machine is likely to have bash already installed.
- dbbolton 14y agoIf you really want your scripts to be portable, you should probably write them in POSIX sh. There might be a high probability that any given machine with a Unix-like operating system will have bash installed, but it is essentially guaranteed that it will have sh. However, if a person really wants to run your scripts, he can probably install the interpreter for which they were written. So choosing bash as some sort of middle-ground isn't really justifiable.
- lurker14 14y agoAs someone who used zsh for a while but got tired of setting it up everywhere I go and losing the "local community" bash stuff, I humbly request: someone please post a rebuttal showing how to do all this in bash with appropriate .bashrc/functions and utility programs like fasd.
- lloeki 14y agoIn spirit, here's mine [0], where I maintain a configuration that works in a similar way for both bash and zsh and does not try to make one identical the other[1]. It respects login vs interactive, and is reasonably fast on start (i have a few ideas to make it faster). It's designed to be lean, DRY, simple and modular. You can use it as is, overwriting you own dotfiles with setup.sh, or you can pick-source each file/feature you want individually (some need a couple vars set, grep for DOTFILES_). It leverages available software but tries not to break when it's not available. It works under both Linux and OSX. It includes an implementation of something like vcs_info for bash, leading to a much more configurable PS1 than git's provided bash prompt support. Its prompt tries to use colors semantically, and keeps things logical and non-cluttered. If this reads like this is the best thing since slice bread, that's because it is! ... for me. But I'm sure you could find a useful thing or two in there. [0] https://github.com/lloeki/dotfiles https://github.com/lloeki/dotfiles [1] I went all the way to hack support of right prompting and reverse-% cleanup on non-newlined output in bash. It works well... most of the time, but when it breaks it's ugly so I just disabled it.
- zecho 14y agoNot much of a rebuttal, but certainly a counter to oh-my-zsh: https://github.com/revans/bash-it https://github.com/revans/bash-it (which includes fasd).
- ta12121 14y agoI've never read about zsh on HN before. I swear it officer.
- eblume 14y agoI tried using oh-my-zsh, but all of a sudden bringing up a new terminal (on OS X) went from taking ~1 second to ~5 seconds. Totally killed my interest in zsh. I'm sure there's a way to make it all work nicely, but bash has been doing just fine for me, I don't feel the need to figure out an entirely new configuration system for a tool that ultimately has little new utility in my workflow.
- jff 14y agoI'm thiiiiiis close to going back to rc, because when there's any kind of load on my system it can take multiple seconds for a new xterm to open with bash. rc starts in no time, and I already use it when I have to write a quick one-off script.
- oe 14y agoSame thing on a year old MBP. I installed the basic Oh My Zsh package and a new terminal sometimes takes 5-10 seconds to initialize. Are there some tricks that would make it faster? I mainly use the Git-plugin.
- osdf 14y agoThere is a cleaner 'version' (==fork) of oh-my-zsh that fixed the long startup time for me: https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto. With nice, fast setup (overwrites your .zshrc file!) and lots of documentation.
- crazydiamond 14y agoThanks, I have the same slow startup issue with oh-my-zsh. But the link does not talk about how to migrate from oh-my-zsh to prezto. Which files should I copy over, or compare and update once I install prezto ?
- jlgreco 14y agoHonestly I do not understand the purpose of oh-my-zsh. I've been using zsh without it for years, if I want something for it I just take 5 minutes on google to figure it out. No sense in having a lot of stuff turned on by default that I don't know how to use. I feel the same way about Vim, but for some reason more people in the Vim community seem to agree with me.
- ithcy2 14y agoEverything in the "Context based tab completion" paragraph is already done by bash_completion. * It knows which commands git takes? Yes. * which hosts are in my hosts file for ssh? Yes. * which users my system have when I write chmod? Yes. * available packages to apt-get? Yes. Plus everything in /etc/bash_completion, plus the hundreds of additional commands in /etc/bash_completion.d, plus many, many online resources for creating your own...
- bjourne 14y agoOne important difference between how that completion works and zsh's is that zsh cycles between the available completions if you repeatedly type tab. E.g. if you have the files [less01.png, less02.png, less03.png] and type "eog less<tab>" in bash will show you the files. Press tab again and it will list the files again. In zsh, the second tab press would fill in "less01.png", then "less02.png" and so on. It's a matter of preference which completion strategy is the best, yes. :) But for me I've found that zsh's way to do it saves me many more keystrokes than bash's way.
- Evbn 14y agoThat is an inputrc configuration not a shell feature. http://stackoverflow.com/questions/7179642/how-can-i-make-bash-tab-completion-behave-like-vim-tab-completion http://stackoverflow.com/questions/7179642/how-can-i-make-ba... Yay Unix. Input collection is a pluggabls component.
- buster 14y agoBeen trying zsh for a while, ran fish for 1 or 2 years. Am back to bash because to many scripts rely on bash and wont't work on zsh or fish. Thing is, it's note that hard to get the mentioned features in bash. Good tab completion, good git enabled color prompt, ssh completion, host completion, command completion and (my favorite) "start typing, press up, cycle through command history with the given input" aka reverse search. I really really liked fish. But incompatibility with bash was just too annoying after a while.
- jlgreco 14y agoI use zsh and write all my ~/bin/ scripts in bash.. what problems did you encounter? I don't see how issues could possibly even occur.
- buster 14y agoYou write YOUR scripts in bash, it's not about my scripts though ;) Also, it's annoying to constantly switch between zsh and bash when you are working on other servers over 50% of your time.
- jlgreco 14y agoI was wondering what you mean by "many scripts rely on bash". If you write a script in bash it will work from zsh just fine. I guess I don't really run into the same adoption difficulty other people seem to, since at work we use zsh instead of bash.
- zerop 14y agoNot sure if this is good ask. But windows needs a tool like this. Why not have a port for windows as well.
- ithcy2 14y agolike cygwin zsh? Or are you talking about oh-my-zsh?
- zobzu 14y agoSo I heard "use zsh its so cool" since about 12 years, every 3 month. Here's the new post, just in time. Don't get me wrong, I use zsh. I also use bash. I end up using more bash than zsh though. The reason are the same as 12 years ago. If zsh was the most popular shell right now the same people would be praising bash. - they're equally fast for what we need them to do - they've similar features - bash is everywhere - bash is the standard for all scripts - zsh has extra complexity Oh yeah and stop using pg-up in bash, use ctrl-r. And if different is cool, I don't know, use fish.
- deleted 14y ago[deleted]
- reyan 14y agoI use prezto (https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto -- initially a fork of oh-my-zsh).
- dlisboa 14y agoSame here. oh-my-zsh was too slow for me and took away one of the advantages of zsh (that of being faster to load than bash). Also, a great number of oh-my-zsh config options are, to me, incredibly annoying (the long completion menu is the worst shell interface ever invented). I'm in the process of trimming down prezto to exactly what I need, since it also has too much fluff. It's a great resource, I'd recommend it to anyone wanting a slimmer and easier to grok zsh configuration.
- army 14y agoI use zsh for day-to-day use. It's mostly been good to me but sometimes I contemplate switching back to bash because of the performance: sometimes zsh simply hangs for seconds at a time. I'm sure one extension or another is at fault and I could fix the performance issues by reconfiguring things, but I really don't want to put the time into doing that.
- dbbolton 14y agoThere's one of these "why you should convert from X to Y" posts every week or so. I understand that a person can be somewhat excited about finding a better application to replace their old stand-by and might feel the need to evangelize. I don't see anything wrong with wanting to introduce others to new software with a helpful attitude. However, it seems like all of the bash-to-zsh posts boil down to better autocompletion and oh-my-zsh. I haven't really seen anything fresh in quite some time. This is something that I do not understand. Does the author think he is saying something that hasn't been said, or is the hope that if we keep saying the same thing over and over that we can get more people to try zsh? I really can't say. Also, I recommend not using oh-my-zsh if you are a beginner. Rather, I recommend that you start with a blank slate and read the documentation. This is the only way to get the exact configuration you want. If you don't really care about your shell that much, then why are you switching in the first place? Alternatively, you might try using the "recommended" config offered on first run (I can confirm that the default config on Debian is a good start and will work for most people). Then go through that config while reading the Zsh User Guide[1] and tweak it to your liking. It is my opinion that oh-my-zsh ultimately stops people from reading documentation and offers an incentive (ease of use) for using code that may not be understood (when it probably should be). However, a lot of people seem to like it. Perhaps I am missing something. My intent is not to discourage this author specifically, but rather to call into question the underlying motivation and behind and utility of all posts of this type. 1 - http://zsh.sourceforge.net/Guide/ http://zsh.sourceforge.net/Guide/
- daivd 14y agoThe underlying motivation is to write it specifically for a few people, whose current way of working I know, and who have asked me for some information on zsh. If it were not for them, I would not have written it, since I don't add anything new, just summarize in a different way. Having written it, though, I thought I might share it. For most people, like me, the timing has to be right to try something new. You have to have the time and the motivation and everything else. By sharing it, I hope to hit some people with the right timing (and based on some comments, upvotes, etc, I know I did). I must have seen 20 Haskell advocacy posts before I actually tried writing something in it. Same with you for some new technologies?
- 14y ago
- tharris0101 14y agoI used zsh for years. Loved it. I just don't do as much command line stuff anymore so vanilla bash works fine for me. I do miss the history stuff mentioned at the end of the article, though.
- djcb 14y agoI've been using zsh for a decade or so, and I like it quite a lot. For basic things, it works enough like bash to hardly notice it; but slowly I've learned all the special tricks. Now, I would recommend against using /oh-my-zsh/ and the like wholesale; just add useful things to your zsh setup step-by-step, where you actually understand each step. Otherwise you're just importing a blob of magic that can interact with other things in weird ways. /oh-my-zsh/ contains a lot of gems, but take them one by one.
- y4m4 14y agowhat a joke!
- scrsh 14y agoIt's not portable. And I have to invest time to learn all the codes. In the times it takes to learn zsh, I could write the same functionality into small sh scripts which I can run on any machine. Put them in a folder, add it to my PATH and I'm in business. I can tar up this folder and upload it to some internet-connected machine so I can download it to any other machine with an internet connection. zsh is wonderful. It is the ultimate "interactive" shell. But it's not portable. Moreover, the less "interactive" I need to be on the command line the better. If I have short, portable scripts to do certain things, and I can run them on any machine with /bin/sh (no need to install anything; sh is the universal interpreter), that's a nice thing to have. zsh won't give me that.
- nakkiel 14y agoI'm not going to elaborate much because I feel I'll waste my and I have a plane to catch but I have yet to see a compelling argument to make me believe zsh is in any way superior to bash. All posts on the subject show that theirs authors have been using a shell they don't know and have replaced it by another shell plus configuration files made up by someone more clever. All posts are also bullet lists of features bash can actually be configured to do. Someone wake up.
- X6MW3aQrZU5VKkz 14y agoThat's exactly how I feel about this as well. I can actually confirm that my bash config does each of these things other than some of the globbing features (* * for instance does work though). edit: should be two asterix characters with no whitespace in between, but if I do this they're not displayed. Any advice on how to get that working?
- lr--rw-rwx 14y agoMy concern with Zsh is that is just not that much better than Bash and that's the (valid) reason, why it's not getting widespread adoption. It's like with Plan9 and Linux or new systems languages which try to make a better C. The technology _is_ better than the existing one, but not that much better that it's that relevant. I think one of the main problems of current shells is that they try to be a CLI and an interpreter for a programming language (e.g. Bash script) at the same time, but the user uses mostly just one of these features for certain periods of time. At one point he wants to control the computer in a very efficient matter (system usage), so short keystroke sequences are convenient. At other times one wants to do more complex stuff which involves programming (development). However current Shells are at any point in time prepared for both and that's the reason why both tasks are sometimes cumbersome.