SOLVED oh-my-zsh on base system

Jacopx

Patron
Joined
Feb 19, 2016
Messages
367
Buonasera a tutti,
I'm using ZSH on my macOS, Raspberri Pi, Linux and other machine... I already use ZSH in my FreeNAS environment and I like to add the oh-my-zsh "plugins" is there anyone that have already tried to do this? :)

oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh
 

Jacopx

Patron
Joined
Feb 19, 2016
Messages
367
UPDATE: I've tried to install omz in a jail and everything goes fine... Looking at this positive result I decide to install on the main system to and it's properly works! ;)

I use ZSH + oh-my-zsh + iTerm2 on macOS ;)

Here a screenshot:
 

Attachments

  • oh-my-zsh.png
    oh-my-zsh.png
    407.1 KB · Views: 991

appliance

Explorer
Joined
Nov 6, 2019
Messages
96
using zsh+omz+slimzsh+zshautosuggestions+zshnavigationtools+zshsyntaxhighlightning+fasd+powerlevel10k on base system, now i wonder how can i spread it across jails automatically :)
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
using zsh+omz+slimzsh+zshautosuggestions+zshnavigationtools+zshsyntaxhighlightning+fasd+powerlevel10k on base system, now i wonder how can i spread it across jails automatically :)
could you do step by step guide on this please?
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
UPDATE: I've tried to install omz in a jail and everything goes fine... Looking at this positive result I decide to install on the main system to and it's properly works! ;)

I use ZSH + oh-my-zsh + iTerm2 on macOS ;)

Here a screenshot:
do you have instructions?
 

Jacopx

Patron
Joined
Feb 19, 2016
Messages
367
do you have instructions?

Execute the following command:
Code:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
 

appliance

Explorer
Joined
Nov 6, 2019
Messages
96
could you do step by step guide on this please?
sorry but I have only a geeky answer. i had it finetuned to little detail, so it's actually hard to present it.. i needed each jail to have zsh with my config, keep history, have perfect hotkeys, aliases etc, then have full repository enabled, update hostnames per jail (so that e.g. Plex knows where is Transmission, Sonarr knows where is Jackett) etc.

i had scheduled updater of jails:
Code:
for jail in $(jails_running); do ~/update_jails.sh $jail; done
jails_refresh_hostnames


the update script was separate in /root/update_jails.sh (parameter = name of jail), and it installed some stuff with or without OMV (once installed, you don't need to install anymore - the files stay where they are):

Code:
if [ "$1" == "" ]; then echo enter jail name; exit 1; fi
jls | grep $1
if [ ! $? == 0 ]; then echo jail is not active; exit 2; fi
jail=$1

#####enable full repository
echo "FreeBSD: { enabled: yes }" > /jails/$jail/root/usr/local/etc/pkg/repos/FreeBSD.conf
#####install packages (chew ~100MB per jail just for our comfort!)
iocage exec $jail "pkg update; pkg install -y ncdu htop micro zsh zsh-autosuggestions zsh-completions fasd fzf zsh-syntax-highlighting"
#####run zsh from csh if interactive shell is detected
if ! (grep "# replace shell" /jails/$jail/root/root/.cshrc); then echo -e "if (\$?prompt) then\n\texec zsh # replace shell\nendif" >> /jails/$jail/root/root/.cshrc; fi
#####copy configs from mr.root
cp ~/.zshrc /jails/$jail/root/root/.zshrc #####or copy a modified jail version config
cp -pr ~/.config/htop /jails/$jail/root/root/.config #####htop :)


interestingly i didnt want to set zsh as shell as it'd interfere with everything (e.g. use too much memory for simple system tasks, compatibility issue, and a potentional critical issue of ZSH not executing if config is broken - then u might not get to the SSH shell). So i ran zsh FROM csh if interactive shell is detected. The SSH user can't care less.

the functions were sourced from functions.zsh in .zshrc:
Code:
function jails() {
    iocage list -P;
}
function jails_all() {
    jls -sd|awk '{print $36}' | cut -d'=' -f2
}
function jails_running() {
    jls -s|awk '{print $36}' | cut -d'=' -f2
}
function jails_enabled() {
    iocage list -lh|grep on | awk '{print $2}'
}
function jails_disabled() {
    iocage list -lh|grep off | awk '{print $2}'
}
function jails_dhcp() {
    iocage list -h|grep DHCP | awk '{print $2}'
}
function jails_nat() {
    iocage list -h|grep -v DHCP | awk '{print $2}'
}
function jails_refresh_hostnames() {
    iocage list -h | awk '{print $5 " " $2}' | grep -v "DHCP" > /tmp/hosts.jails;
    while read jail; do
    cp /tmp/hosts.jails /jails/$(cut -d' ' -f2 <<< $jail)/root/etc/hosts;
    done < /tmp/hosts.jails; ####not sure /jails is in root by default, "ln -s" it (permanent) or edit here
    cp /tmp/hosts.jails /etc/hosts;
}
function datasets() {
    zfs list -o name,aclmode,used,usedbysnapshots,exec,snapdir
}


there was more.. detect boot drive fitness to avoid hanging, detect missing datasets, also harvest signifficant errors from each jail (e.g. Transmission failed to unpack RAR) and send it via email.. (and speak the error in English via USB speaker lol).

i also didn't schedule hostname update like above, but rather detected if ANY of them actually re/started:
Code:
    changed=0 ###this is part of bigger monitoring script scheduled
    for jail in $(jails_running); do
    #check if any jail was restarted, and refresh static dns records
    if [ ! -z $(find /jails/$jail/root/etc/resolv.conf -newer /tmp/hosts.jails) ]; then
        logger -t $0 jail $jail refresh needed
        ((changed++))
    fi

    if [ $changed -gt 0 ]; then
    logger -t $0 $changed of $(jails|wc -l) jails changed, refreshing
    jails_refresh_hostnames

this was rather important as i had all jails running on virtual IP (always changing) and FreeNas didn't maintain their hostnames except DHCPish Plex and no, i dont want to ridiculously run dns server for this. Then you just go to Radarr/Sonarr/Lidarr UI and set "jackett", "plex", "nzbget", "transmission" as hostnames and they will happily start to cooperate asap.

so this is the language i speak here, unfortunately not much english. however some code snippets can be useful for some folks as it takes time to figure out exact techniques.
 
Top