Igor 2099 Posted December 19, 2020 Share Posted December 19, 2020 What is ZSH, and Why Should You Use It Instead of Bash? ZSH, also called the Z shell, is an extended version of the BASH, with plenty of new features, and support for plugins and themes. Since it’s based on the same shell as Bash, ZSH has many of the same features, and switching over is a breeze. So Why Use It? ZSH has too many features to list here, some just minor improvements to Bash, but here are some of the major ones: Automatic cd: Just type the name of the directory Recursive path expansion: For example “/u/lo/b” expands to “/usr/local/bin” Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you Plugin and theme support: ZSH includes many different plugin frameworks Plugin and theme support is probably the coolest feature of ZSH and is what we’ll focus on here. Can be shipped with Armbian by default Pros: Zsh is Bash-compatible. Existing Bash scripts will work in Zsh, largely unmodified. Everything you already know already applies. You don't have to unlearn anything. Zsh has a powerful extension mechanism. It allows zsh to include as builtins features like sockets, line-editing, regular expression engines, and lots of other things. (Take a look at man zshmodules for more examples) Command completion is absurdly powerful, and can be extended quite far. Scripts already do a lot in the zsh-completions collection, but a zsh module can go much further to do what shells like Fish do. You can easily switch back to Bash in armbian-config Cons: It's bigger than Bash but we tweaked it to run smoothly also on older boards. It will spoil you rotten. Its features are so much more powerful than Bash, you'll never be happy with Bash ever again. What is Oh-My-ZSH? Oh-My-Zsh is the most popular plugin framework for ZSH, and it comes with many built-in plugins and themes as well. Oh-My-Zsh has loads of plugins built right in and does its job well. Plugins that we plan to ship by default: evalcache git git-extras debian tmux screen history extract colorize web-search docker Quote Armbian ZSH comes in a bundle with oh-my-zsh and tmux. How to test it on existing builds? Support for ZSH was already merged into the build system which means its present in self build or nightly images. Currently you still need to choose ZSH or BASH at 1st login. You can test new features on existing Armbian: Spoiler apt update apt -y install armbian-zsh awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534 || $3 == 0) print $1}' /etc/passwd | xargs -L1 chsh -s $(grep /zsh$ /etc/shells | tail -1) This will change all normal users including root on the system from BASH to ZSH. To see effect, logout and login. First login will be slow, others will be normal speed. Going back from ZSH to BASH: Spoiler awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534 || $3 == 0) print $1}' /etc/passwd | xargs -L1 chsh -s $(grep /bash$ /etc/shells | tail -1) Also available via armbian-config. References: [1] https://ohmyz.sh/ [2] Bash VS ZSH [3] Why zsh is Cooler than Your Shell [4] Getting started with Tmux 0 Quote Link to post Share on other sites
Werner 320 Posted December 28, 2020 Share Posted December 28, 2020 IMHO I would not ship zsh by default. Simply because one of Armbians goals is to provide a mostly unmodified experience known from a fresh vanilla Debian/Ubuntu installation on other platforms. Providing as pre-configured and easy to install enhancement is perfectly fine. 0 Quote Link to post Share on other sites
Igor 2099 Posted December 28, 2020 Author Share Posted December 28, 2020 According to my small internal mini research, ideas were mixed - there were few thoughts: - if BASH stays on minimal, no problem - don't ask, just change it - debian sucks. it even can't remember what i typed (arch and macos users) If you don't want change - you can use BASH logic. Its backward compatibility ... but I am ZSH user. I am biased and will use it anyway ... Let's see. 0 Quote Link to post Share on other sites
guidol 266 Posted December 28, 2020 Share Posted December 28, 2020 On 12/20/2020 at 12:21 AM, Igor said: Cons: It's bigger than Bash but we tweaked it to run smoothly also on older boards. @Igorin means of MegaByte - how much is zsh bigger? I dont think another shell does use more CPU-power? or only while typing in the command? from the 60-pages presentation: zsh-syntax-highlighting (page 56) HMM: as bash-replacement my colored (ansi-escape-sequences) prompt doenst work in ~/.zshrc How have I to convert that? The PS1 prompt gives me the sequences but doenst interpret them export THEIP="$(/sbin/ifconfig | grep "inet " | grep -v 127.0.0. | awk '{print $2}')" # \u = User # @ = @ # \h = Host # \w = working directory # \$ = # for root (uid=0) or $ for user BRed='\[\033[31;1m\]' BGreen='\[\033[32;1m\]' BYellow='\[\033[33;1m\]' BCyan='\[\033[36;1m\]' BWhite='\[\033[37;1m\]' Reset='\[\033[0m\]' UserPromptPS1='\$' export PS1="${BCyan}\u${BWhite}@${BYellow}\h${BWhite}${BGreen}${THEIP}${BWhite})${BRed}:${BCyan}\w${BRed}${UserPromptPS1}${Reset} " [EDIT] colors seems to be "easy" - here some examples: PROMPT='%F{240}%n%F{red}@%F{green}%m:%F{141}%d$ %F{reset}' PS1="%{%F{red}%}%n%{%f%}@%{%F{blue}%}%m %{%F{yellow}%}%~ %{$%f%}%% " from https://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text so my prompt could look like # zsh # %n = User # @ = @ # %m = Host # %~ = working directory # %# = # for root (uid=0) or $ for user BRed='%F{red}' BGreen='%F{green}' BYellow='%F{yellow}' BCyan='%F{cyan}' BWhite='%F{white}' Reset='%F{reset}' UserPromptPS1='%#' export PS1="${BCyan}%n${BWhite}@${BYellow}%m${BWhite}${BGreen}${THEIP}${BWhite})${BRed}:${BCyan}%~${BRed}${UserPromptPS1}${Reset} " 0 Quote Link to post Share on other sites
Igor 2099 Posted December 28, 2020 Author Share Posted December 28, 2020 3 minutes ago, guidol said: I dont think another shell does use more CPU-power? or only while typing in the command? It is certainly more hungry but it runs nicely also on older boards. I didn't compare memory footprint yet. The question here is - setting it by default. It can easily be disabled - the same way as it can be enabled. And its not planned to be enabled on minimal images. We can also go further and make it per board function and disable for Nanopi Duo, Opi Zero, Neo where memory could be as low as 256Mb. We have to explore this together. 0 Quote Link to post Share on other sites
sfx2000 99 Posted December 29, 2020 Share Posted December 29, 2020 I'd suggest putting this in armbian-config to enable (along with the options for tmux, etc) and leave bash as default... Also look at byobu - this is an ubuntu sanctioned environment, and pretty handy - it's my go-to for working on the shell... https://www.byobu.org/ 0 Quote Link to post Share on other sites
Werner 320 Posted December 29, 2020 Share Posted December 29, 2020 4 hours ago, sfx2000 said: I'd suggest putting this in armbian-config to enable (along with the options for tmux, etc) and leave bash as default... Also look at byobu - this is an ubuntu sanctioned environment, and pretty handy - it's my go-to for working on the shell... https://www.byobu.org/ This isn't an entire shell or? More a screen competitor? 0 Quote Link to post Share on other sites
guidol 266 Posted December 29, 2020 Share Posted December 29, 2020 @Igor zsh itself doesnt seem to affect a "very low" memory-sbc (only zsh-common installled) - and OK its not armbian but pure debian 0 Quote Link to post Share on other sites
sfx2000 99 Posted December 30, 2020 Share Posted December 30, 2020 19 hours ago, Werner said: This isn't an entire shell or? More a screen competitor? Screen/Tmux - pretty nifty, and it's in the repo's so one can play with it, and define as the default shell if one prefers... 0 Quote Link to post Share on other sites
Pander 1 Posted January 6 Share Posted January 6 Please allow armbian-config to switch to zsh but don't name it the default as to stay as close to Debian/Ubuntu as possible by default. 0 Quote Link to post Share on other sites
loredin 0 Posted Tuesday at 09:09 PM Share Posted Tuesday at 09:09 PM Hi not sure how to vote but as an eternal noob I wont go for it , I have tried it a bit and although I was fine with some features other things were a bit confusing me (like the need to use extra "" for some basic functions, cant remember what that was). I switched back to bash and was much more comfortable with it. 0 Quote Link to post Share on other sites
Igor 2099 Posted Tuesday at 10:35 PM Author Share Posted Tuesday at 10:35 PM ... it looks like Bash will remain as default and those who wants ZSH, they could choose it at 1st login or later via armbian-config. No worries. 0 Quote Link to post Share on other sites
arox 32 Posted Wednesday at 10:37 AM Share Posted Wednesday at 10:37 AM Well ... Shell users can use "chsh" command. I'm not interested in "themes" or "plugins" or badly contrasted "colorization" but "socket" and "re" integration is a good idea, (thanks to Igor to point that). Nevertheless, I have been a "vi" user for more than 30 years because it is (almost) already present in any **unix** implementation, access method or system maintenance situation. I just use "geany <myfile>" on the command line if I want to do serious editing. So "it will spoil you rotten" is not an empty threat. Linux or Unix need to be layered not re-invented. Ken Thompson et Dennis Ritchie, developed Unix as a simplified version of Multics. Here is the success of the concept : keep it simple and go on above rock-solid foundations. I need to give zsh a try in order to make my opinion : should I waste 10 seconds more time to configure or unconfigure yet another "modern" linux implementation every time I install a machine ? And does it matter for "command line" haters ? 0 Quote Link to post Share on other sites
Igor 2099 Posted Wednesday at 12:27 PM Author Share Posted Wednesday at 12:27 PM 1 hour ago, arox said: Nevertheless, I have been a "vi" user for more than 30 years because it is (almost) already present in any **unix** implementation Indeed. While I think VI exists mainly as a softlink to VIM. Which is anyway the same thing in its roots. Spoiler 1 hour ago, arox said: I need to give zsh a try in order to make my opinion : should I waste 10 seconds more time to configure or unconfigure yet another "modern" linux implementation every time I install a machine ? And does it matter for "command line" haters ? I am by no means an ZSH expert. Just switched to it some years back and I got spoiled. I think ZSH is also more convenient for lazy people I remember back in the 90" we were running chsh for experimental purposes, to discover other shells, if nothing else. But today I would also not do that anymore ... Also ZSH - on a level of my usage, when installing new system - doesn't represent more attention than dealing with BASH. On Armbian is now only by choosing 1 for BASH, 2 for ZSH at 1st login screen. Or by running armbian-config ... 0 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.