iTerm With ZSH

1.)What is the difference between bash and zsh?
Bash and Zsh are both shells for your terminals. Bash or the Bourne-Again SHell, is the default on most systems due to backward compatibility reasons with sh which was pretty much the only shell in its time. 

Before I begin elaborating on the differences, there should come the most important item, the direct quote from the ZSH Documentation:

2.5: Similarities with bash

The Bourne-Again Shell, bash, is another enhanced Bourne-like shell; the most obvious  difference from zsh is that it does not attempt to emulate the Korn shell. Since both  shells are under active development it is probably not sensible to be too specific  here. Broadly, bash has paid more attention to standards compliancy (i.e. POSIX) for  longer, and has so far avoided the more abstruse interactive features (programmable  completion, etc.) that zsh has.

Now that the documentation is out of the way, let me begin discussing the topic based on my own views. Bash and Zsh are bot undeniably powerful shells with even more powerful scripting support. The Zsh Script is *very* similar to Bash with only small differences. But the differences are large enough that migrating scripts is not trivially easy.

As mentioned in the FAQ, Bash attempts to stick more closely to POSIX and hence avoids certain features which otherwise should exist in a modern shell. It is that gap which Zsh attempts to fill. By not following POSIX, Zsh loses a bit on its portability, but gains a lot more in terms of features.

To notice a difference between Bash and Zsh simply try installiong both and starting them. Bash will immediately start and take you to a working prompt. Zsh on the other hand will take you through a 30 minute ordeal customizing your prompt so that it works precisely as you intend it to. A lot of the settings can also be applied to Bash, but having such a well written installer script makes it much easier to find those options and set them up in the very beginning.

The most notable of differences between the two shells is their support for autocompletion, or more specifically, programmable autocompletion. While newer versions of Bash now support programmable autocompletion through the bash-completion package, it simply isn't as powerful as it is in Zsh. Also, since it isn't an entirely native feature in bash, autocompletion of single commands is also much noticeably slower when compared to Zsh. The autocompletion in bash isn't keyboard navigable either. It simply lists the possibilities and leaves it upto the user to type the result manually. On Zsh, you can navigate the completion list and select the completion you'd like to use. 
Bash:

Zsh:

As you can see from the above images, Bash simply lists the completion results and moves to  a new prompt, while Zsh allows navigating the results through the keyboard. This is a very time saving feature.
2.)zsh:-mvn command not found.
While you will use other terminal with other shell (like bash) zsh.

You need to edit .zshrc file , that is you need to copy and paste all paths from .bash_profile to .zshrc.

Also source .bash to .zsh

For eg:-
In .bash_profile
# The next line enables shell command completion for gcloud.
if [ -f '/Users/abhishekthakur/Downloads/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/abhishekthakur/Downloads/google-cloud-sdk/completion.bash.inc'; fi

In .zshrc
# The next line enables shell command completion for gcloud.
if [ -f '/Users/abhishekthakur/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/abhishekthakur/Downloads/google-cloud-sdk/completion.zsh.inc'; fi

And now restart the system and check the commands, like mvn , gcloud etc.

Comments