Jump to content

Changing default Armbian shell to ZSH


Igor

Set default shell to ZSH?  

23 members have voted

  1. 1. Read below and vote! Do you support shell change except in minimal images?

    • Yes! That is a wonderful idea!
      6
    • My feelings are mixed. Is this really needed?
      12
    • No, I am not happy about.
      5

This poll is closed to new votes

  • Please sign in or register to vote in this poll.
  • Poll closed on 01/31/21 at 08:15 PM

Recommended Posts

zshtmux.jpg

 

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

 

Link to comment
Share on other sites

  • Igor changed the title to Should we switch default Armbian shell to ZSH?
  • Igor changed the title to Changing default Armbian shell to ZSH

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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} "

 

zsh_color_prompt.jpg.0640ae2abba45592414badf6b5b5cbab.jpg

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

1 hour ago, Technicavolous said:

but I'm a real armbian-config fanatic and would vote to keep it there.


It looks like sufficient support for defaulting ZSH is not going to happen :P But it will remain as a second choice ... lets repeat this question year later.


Speaking on armbian-config ... @tparys started to help on enhancements, I do what I can ... still more helping hand is needed. It's a long term job. Any idea how to get more movement there? Yes, its a wonderful tool, but require constant love. Like other parts of the project.

Link to comment
Share on other sites

What would be best at this stage? Assemble some resources to start changing whole app structure, put things together in a better way. Main problem is that script was made in ad-hoc matter and it stayed that way for years. It was never designed to meet the needs. We are just adding things.

 

Armbian config is utility to setup things quicker and an interface with OS low/mid level functions in some more human way. Its not expected that person that wants to help around understands all those functions since the problem is mainly in poor overall design, mixture of different styles, several functions are obsolete, should be done different ... its a code which was built in a period of 10+ years. I would say we need few people to scan it and together we create a design for refactoring, cut work into chunks and start working on it. On a new version. Then we switch.

Link to comment
Share on other sites

6 hours ago, Igor said:

scan it and together we create a design for refactoring, cut work into chunks and start working on it

Let's do it :P

 

P.S.: Not a big fan of ZSH so far. I installed it on my Ubuntu PC, and it all just looked like an unconfigured BASH, needing plenty of work to make it useful. I guess the Armbian version comes pre-configured, I'll give it a chance in some near future.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines