Zsh with oh-my-zsh

I noticed that the Zsh package includes some customization wrt Manjaro.
I was wondering why it did’nt make use of Oh-My-Zsh?
Wouldn’t it be more appriciated by Zsh users to have Oh-My-Zsh installed system-wide along with Zsh and use it’s plugin system to tailor for Manjaro?

See also: Installing system-wide · Issue #9380 · ohmyzsh/ohmyzsh · GitHub where i posted on their repo with a related question in case it needs support on their side.

1 Like

My current first attempt is composed of:

sudo -i
mkdir /opt/oh-my-zsh
setfacl -m g:wheel:rwx,d:g:wheel:rwX /opt/oh-my-zsh
ZSH=/opt/oh-my-zsh ./install-oh-my-zsh.sh --unattended --keep-zshrc

With this change to the install script from their repo:

--- install.sh	2020-10-24 11:57:35.132039529 +0300
+++ install-oh-my-zsh.sh	2020-10-24 11:10:47.288704933 +0300
@@ -255,13 +255,13 @@
 		exit 1
 	fi
 
-	if [ -d "$ZSH" ]; then
-		cat <<-EOF
-			${YELLOW}You already have Oh My Zsh installed.${RESET}
-			You'll need to remove '$ZSH' if you want to reinstall.
-		EOF
-		exit 1
-	fi
+#	if [ -d "$ZSH" ]; then
+#		cat <<-EOF
+#			${YELLOW}You already have Oh My Zsh installed.${RESET}
+#			You'll need to remove '$ZSH' if you want to reinstall.
+#		EOF
+#		exit 1
+#	fi
 
 	setup_ohmyzsh
 	setup_zshrc

Which leaves only this functionality done afterwards to initialize the user’s ~/.zshrc to point to the installed location /opt/oh-my-zsh

So we need to do:

<As root>
cp -a /etc/skel/.zshrc /etc/skel/.zshrc.pre-oh-my-zsh
sed '/^export/ s|$HOME/.oh-my-zsh|/opt/oh-my-zsh|' /opt/oh-my-zsh/templates/zshrc.zsh-template > /etc/skel/.zshrc
sed -i '/^source/ i ZSH_DISABLE_COMPFIX="true"\ ' /etc/skel/.zshrc

That last line is to disable the warning about shared file permissions…

If we want to apply that config to our current user we can simply perform as current user:

cp /etc/skel/.zshrc* ~

Note:
If we want this all to be installed in some other location then simply change all occurrences of /opt/oh-my-zsh in the above steps with the wanted path.

1 Like

Hi!
You don’t need Oh-My-Zsh to use their plugins or themes, just download/install the plugins/themes you want and add them to .zshrc with source /path/to/the/plugins/themes and reload the zsh config with source .zshrc

The beauty of it is that they keep their ecosystem updated using their git repo.
Manually downloading and installing their themes and plugins will not allow that…

What I use is environmental variables set at ~/.config/environment.d/profile.conf

XDG_CONFIG_HOME="$HOME/.config"
ZDOTDIR="$XDG_CONFIG_HOME/zsh"
ZSH_CUSTOM="$ZDOTDIR/custom"

plus at .zshrc

# Path oh-my-zsh installation.
export ZSH=/usr/share/oh-my-zsh/

Just change the ZSH_CUSTOM to something User HOME like and everyones’s happy?


EDIT: the ZDOTDIR is for .zshrc config and stuff around zsh be located ant ~/.config/zsh rather than directly at ~/

That would still install Oh-My-Zsh in the users homedir and not system-wide right?
Ofcourse the use of ZSH_CUSTOM is a nice idea to allow per-user customization to point to a subdir in the users homedir… :+1:

No no, the installed Oh My Zsh package will not change anything for anyone ( If I remember correctly it did no set up any variables for me )

Any new user will be invoked by the zsh prompt to “Create new .zshrc at ~/.zshrc” or something like this.

That zshrc should be the vanilla zsh config, for the new user, he would need to set up the ZSH variable, can be done with export like I’ve written in the .zshrc above.

EDIT: manjaro-base-skel adds some file after useradd MyNewUser ? I am not sure how the base skel applies, if after installation only or everytime useradd happens. Please correct me if I am wrong.

Yea i know, that’s why i added these last steps:

Maybe i should make those changes in the /opt/oh-my-zsh/templates/zshrc.zsh-template file instead hmmm
(Nahh that would change the repo version which would interfere)

The default setup of Oh-My-Zsh seems to work so far, let’s see when i add/change the used plugins array to what i used to have :smiley:
(edit: it’s :white_check_mark: )

1 Like

I don’t know what are you trying to accomplish but I wish you good luck :smiley:

I’m trying to accomplish a system-wide install of Oh-My-Zsh which allows for a single central installation that get’s auto-updated , while still allowing customization per-user…

That’s a functionality of the useradd ecosystem:

   -k, --skel SKEL_DIR
       The skeleton directory, which contains files and directories to be copied in the user's home directory, when the home directory is created by useradd.

       This option is only valid if the -m (or --create-home) option is specified.

       If this option is not set, the skeleton directory is defined by the SKEL variable in /etc/default/useradd or, by default, /etc/skel.

       If possible, the ACLs and extended attributes are copied.

Now we only need a way to make those last changes be automatic.
Maybe replace /etc/skel/.zshrc with the final ~/.zshrc file generated in last steps.

Edit: I have changed the info in reply #2 to do exactly that :wink:

1 Like

Why would we use omz? It’s just one of the available plugin systems and not even the best one.

1 Like

Uhmmm ok that could be a personal preference then.
I didn’t know there were others or better ones…
Care to share links as comparison?

https://wiki.archlinux.org/index.php/zsh#Configuration_frameworks

Almost all other configuration frameworks have started as reaction to poor performance of of-my-zsh. Personally I’ve used zim, but antigen and prezto are also good. Oh-my-zsh is also quite good in it’s own right, but it is not the only game in town. It’s not a simple matter to choose between all the options. And if someone wants to use one of those, they are very easy to install. Also, custom zshrc makes it easy to have manjaro specific custom modules, like pamac based command-not-found hook.

2 Likes

I never said or implied that Oh-My-Zsh was the only one, but IMHO it’s the most versatile…
And poor performance? :roll_eyes:
I personally find the git backed-up update idea very innovative and wanted wrt rapid responding development of plugins in FOSS…
Plus ofcourse it also fits with the mantra of Manjaro “Enjoy the simplicity”…

Which is possible with Oh-My-Zsh
Manjaro could even put it in the git repo of Oh-My-Zsh like all other plugin writers do…
But anyhow it’s your choice to ship Zsh with “Yet another” custom plugin config on it’s own that is used on Manjaro only…

Can you point out examples about this versatility? Imho most config frameworks can use each others plugins without issues, so it’s probably something in the framework itself?

Sorry, I misinterpreted this:

I thought you were unfamiliar with the other options.

Conclusion : Vanilla ZSH is really fast, my setup is ~5x slower, Prezto is ~12x slower and OhMyZSH is ~15x slower out of the box. With adding more plugins, scripts and tooling to the mix the start up times go up significantly.

There are significant differences in speed between configuration frameworks. Since interactive shell gets used almost all the time, this adds up to much bigger performance difference than grub vs. systemd-boot.

Note that this is not a point in favor of the current configuration versus oh-my-zsh, because I haven’t done any benchmarking on the current configuration in a long time. I’m just bringing this up for comparison between the configuration frameworks.

Also, while I probably sounded like it, I’m not categorically against using configuration frameworks in manjaro-zsh-config. If you have an idea on how to implement this in well functioning way, you can send a pull request here:

And maybe set up a poll about it in the forum so we get an idea how well the idea is liked in the community.

2 Likes

The fact that it is “Community driven”.

Yes and still am because reading their descriptions made me choose Oh-My-Zsh since the first time i used any of them.

Every piece of software gets slower the more is added to the initial startup load.
So you can’t blame any framework for having poor performance wrt users-choice can you?
If the user does not enable any plugins i’m 100% sure all those frameworks would perform exactly the same…
(Because you would be left with plain Zsh :wink:)

See my selected solution…

That would be nice, but i’m only TL1 :wink:
(2d left for TL2)

1 Like

Aah, the “joys” of discourse platform… :sweat_smile:

2 Likes

I was thinking something more technical?

But you would not use a configuration framework without any plugins. And with same or similar plugins, other frameworks perform better than oh-my-zsh. Which why I was asking what you think oh-my-zsh brings to the table that is worth the performance hit.

Keeping in mind that they all need to use Zsh as the real engine that executes the plugins:

  • With “same” i find that very hard (imposible) to believe.
  • With “similar” ofcourse possible because they are different.

Things could be different if the plugins would need to be compiled (into binary code) because then the Framework’s (compiler’s) translation would make the difference, but not when the plugins need to be interpreted by Zsh