Tag Info

Hot answers tagged

31

zsh is for vulcans. ;-) Seriously: bash 4.0 has some features previously only found in zsh, like ** globbing: % ls /usr/src/**/Makefile is equivalent to: % find /usr/src -name "Makefile" but obviously more powerful. In my experience bash's programmable completion performs a bit better than zsh's, at least for some cases (completing debian packages ...


18

Two reasons come to mind: First -- it is available practically everywhere. I have several Linux systems (CentOS 4.x in this case) which do not have zsh installed. Similarly I have to touch ancient systems like Solaris 2.6 and up, HP-UX 10 and up, and similarly creaky versions of AIX. Therefore I pretty much have to use bash on these computers, which I do ...


14

I would like to point out that bash is not installed by default on FreeBSD, OpenBSD, or NetBSD, and it is also not installed by default on Solaris 10 (OpenSolaris has it as the default), last time I used an AIX, and or HP-UX servers it was not installed by default either. Also, on OpenSolaris /bin/sh is NOT bash. It is ksh. The biggest issues I have as a ...


14

After you've used CTRL-U you can use CTRL-Y to paste back what you've erased. It works after erasing a word or a number of words with CTRL-W too. Note this way you don't really need to copy anything to the clipboard or select it with the mouse - CTRL-U actually yanks the line to a separate clipboard, so to speak.


13

For existing users: chsh USER -s SHELL chsh root -s /usr/local/bin/bash For future users: Edit "/etc/pw.conf" defaultshell keywords When use adduser(), choose necessary shell


11

Although I am a bash user, I find one of zsh's features pretty cool: RPS1. Remember: PS1: the left aligned prompt RPS1: the right aligned prompt Sample: When using something like PS1=’%B(%h) %m%#%b ‘ RPS1=’(%20<…<%~)' You get your prompt on the left and the current directory pushed onto the right. It even disappears when the current line is ...


9

Bash generally comes with every system, zsh doesn't. I love zsh, but because of this, I use zsh for interactive use, but Bash for all my scripting. I find this keeps everything simpler, as even when I shopt whatever the bash compatible (setopt SH_WORD_SPLIT ?), I still run into subtle differences.


9

Zsh has spelling correction. If you're a letter (or more) off, it will figure out what you meant. It also has more robust tab completion, which I like. Zsh has an interactive config utility to get it set how you like. Some speed tests say zsh is faster, but I haven't noticed any difference.


8

In cases where command -- -file does not work - since not every program uses the same option parsing routines, command ./-file works everywhere.


7

Run which ls to see what exactly is ran why you type ls. ls may be configured as an alias with options not available on your system.


7

Depending on the OS, ls doesn't always have the functionalities. There are two different versions of ls : One from the BSD world (for example Mac OS X version) : The --color=auto doesn't work, use -G instead. One from the Free Software Foundation (Linux for example) : You can use the --color=auto and the -G option does not list group. By the way, ...


7

Very close: cp P10802{75..83}.JPG ~/Images


6

I've been using zsh for about 18 years now, and I must say I don't like the accepted solution. Here's why: You need to figure out the source of the problem - determine why 'tda' is being offered as a correction option. What you have done is completely disabled spelling correction globally. This denies you some very nice functionality while trying to get rid ...


5

It isn't your shell that determines whether output of ls is colorized. You must run ls --color=auto (either as an alias, or explicitly) in order to get colorised ls output. I suspect that your bash configuration included that alisa by default, but zsh doesn't for some reason. Seems odd that Ubuntu would have crippled their zsh installation in such a ...


5

pushd is like cd, but it also pushes your current directory onto a stack. You might be in /some/deep/directory and then need to poke around in /var/www for a while: crb@server /some/deep/directory $ pushd /var/www/ /var/www /some/deep/directory crb@server /var/www $ [do some stuff] crb@server /var/www $ popd /some/deep/directory crb@server ...


5

zsh is not fully bash compatible. There are a variety of differences. Newer zsh is more compatible with bash (=~ supported, exec now has the extra flag options, etc) but full compatibility is not a goal, not even under "emulate". For instance, bash substring is ${foo:offset:len} but in zsh it's $foo[start,end] and that's just one simple example. zsh is a ...


5

As a one-off for the last command: echo !! | pbcopy will put exactly the last command into the clipboard.


5

To iterate over a range in bash: for x in {0..10}; do echo $x; done Applying the same in your case: for x in {272..283}; do cp P1080$x.JPG ~/Images; done


4

My advice: if you are going for absolute portability, write using Bourne shell rules, don't even bother with Korn shell extensions. As mentioned, that are some older "big boxes" around that don't have GNU shells on them at all. Bash already does "too much". I have a friend at work who prefers zsh, but I don't know what exactly it does. Anyway, either ...


4

I don't know of any bash features that zsh does not support. The design goal of zsh seems to include supporting any features that bash adds. I still use bash instead of zsh. I rarely come across compelling features that zsh supports that bash does not. Occasional problems with zsh over the years, or it not existing on certain sysetms, have made it not worth ...


4

Try: unsetopt EXTENDED_HISTORY The numbers are the number of seconds since the Unix epoch of when the command began and the duration in seconds that the command ran. Edit: I forgot to mention that you should use the fc command to interact with history instead of parsing the history file. There are at least a couple of reasons for this. One is that the ...


4

Place -- just before file name. In Unix it indicates the end of options for command. To be more concrete, use: vim -- -file.


4

I'm not sure if you're still tracking this question, but I'd like to help. It's been awhile since I've dove into the guts of zsh's completion system, so this will be a good excuse. For now, we'll use this answer as an ongoing tool for me to provide useful tidbits to help you (and I) troubleshoot the problem. As you can tell, zsh's completion system is very ...


3

Here's the relevant part from my .zshrc. It hasn't changed since 2002, so I might write it differently today, but it still works to complete host names from ~/.ssh/config and ~/.ssh/known_hosts (if HashKnownHosts is off — it didn't exist in those days). h=() if [[ -r ~/.ssh/config ]]; then h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host ...


3

When you run bash with the -c option, bash runs in non-interactive mode. Apparently, the bind builtin doesn't generate output when bash is in non-interactive mode. You can force bash to interactive mode by giving the -i option. The following works for me: bash -i -c 'bind -p'


3

setopt noautomenu setopt nomenucomplete You need both of them. If you hit tab enough times, you'll get the list of completions but it will never add any characters to what you've typed so far.


3

By the way, you have been told here many times that bash is found practically everywhere, so use it to write portable scripts, which is false. Nonsense. If you know that every system you care about has BASH then it's a perfectly reasonable statement. BASH has many useful features that can't be reasonably emulated in POSIX sh. Frivolous use of ...


3

try % unsetopt correct I have the spelling correction off by default. If it works, add it to your .zshrc file.


3

Works fine for me in zsh with the assignment changed from: array={geometry, analysis, topology, graph theory, calculus} to array=(geometry, analysis, topology, graph theory, calculus) But zsh has tons of options that change its behavior. Maybe the output 'setopt' might help.


3

This project has a number of completions for Mac-specific commands (neither of the two you mentioned, but it does have others like defaults, hdiutil, launchctl, mdls, open, and others), as well as a lot of other command-line functions and utilities: http://code.google.com/p/zsh-templates-osx/ There's a lot of Mac development and system utilities that don't ...



Only top voted, non community-wiki answers of a minimum length are eligible