Commit d3aca31d authored by root's avatar root
Browse files

Install ZSH with most used plugins and tmux

parent 5d2f4b15
......@@ -18,6 +18,7 @@ Login as root and type:
- adjust SSH daemon features
- 3G/4G LTE modem management
- run apt update and upgrade
- toogle BASH/ZSH with [Oh My ZSH](https://ohmyz.sh/) and [tmux](https://en.wikipedia.org/wiki/Tmux)
- toggle desktop and login manager (desktop builds)
- adjusting the display resolution (some boards)
- enabling read only root filesystem (Ubuntu)
......
......@@ -746,6 +746,75 @@ function jobs ()
fi
;;
# ZSH
#
"BASH" )
# change shell for root
chsh -s /bin/bash
add_choose_user
if [ -n "$CHOSEN_USER" ]; then
chsh -s /bin/bash $CHOSEN_USER
fi
# cleanup
rm -rf /etc/oh-my-zsh /etc/skel/.zshrc /etc/skel/.oh-my-zsh
rm -rf /root/{.zshrc,.oh-my-zsh}
# and for selected normal user
add_choose_user
if [ -n "$CHOSEN_USER" ]; then
rm -rf /home/$CHOSEN_USER/{.zshrc,.oh-my-zsh}
fi
# change shell for future users
sed -i "s/^SHELL=.*/SHELL=\/bin\/bash/" /etc/default/useradd
# remove crontab
crontab -l | grep -v oh-my | crontab -
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1BASH\Z0\n\nPlease logout & login from this session!" 9 47
;;
# ZSH
#
"ZSH" )
if ! is_package_manager_running; then
if ! check_if_installed zsh ; then
debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get install -y zsh tmux
fi
rm -rf /etc/oh-my-zsh
git clone --quiet https://github.com/robbyrussell/oh-my-zsh.git /etc/oh-my-zsh
cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrc
mkdir -p /etc/skel/.oh-my-zsh/cache
# change shell for future users
sed -i "s/^SHELL=.*/SHELL=\/usr\/bin\/zsh/" /etc/default/useradd
# we have common settings
sed -i "s/^export ZSH=.*/export ZSH=\/etc\/oh-my-zsh/" /etc/skel/.zshrc
# user cache
sed -i "/^export ZSH=.*/a export ZSH_CACHE_DIR=~\/.oh-my-zsh\/cache" /etc/skel/.zshrc
# define theme
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="risto"/' /etc/skel/.zshrc
# remove default plugins
sed -i '/^ git.*/ d' /etc/skel/.zshrc
sed -i "/^plugins=.*/a git git-extras debian tmux screen history extract colorize web-search docker" /etc/skel/.zshrc
# change shell for root
chsh -s $(grep /zsh$ /etc/shells | tail -1)
# copy cache directory
cp -R --attributes-only /etc/skel/.oh-my-zsh /root/.oh-my-zsh
cp /etc/skel/.zshrc /root/.zshrc
# and for selected normal user
add_choose_user
if [ -n "$CHOSEN_USER" ]; then
chsh -s $(grep /zsh$ /etc/shells | tail -1) $CHOSEN_USER
# copy cache directory
cp -R --attributes-only /etc/skel/.oh-my-zsh /home/$CHOSEN_USER/.oh-my-zsh
cp /etc/skel/.zshrc /home/$CHOSEN_USER/.zshrc
chown -R ${CHOSEN_USER}:${CHOSEN_USER} /home/${CHOSEN_USER}/{.zshrc,.oh-my-zsh}
fi
# add a cronjob to update oh-my-zsh once per month
(crontab -l 2>/dev/null; echo "0 0 1 * * cd /etc/oh-my-zsh ; git -q pull origin master >/dev/null 2>/dev/null") | crontab -
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1ZSH\Z0\n\nPlease logout & login from this session!" 9 47
fi
;;
# Firmware update
#
"Firmware" )
......@@ -806,7 +875,7 @@ function jobs ()
dialog --title " Desktop is enabled and running " --backtitle "$BACKTITLE" \
--yes-label "Stop" --no-label "Cancel" --yesno "\nDo you want to stop and disable this service?" 7 50
exitstatus=$?;
if [[ $exitstatus = 0 ]]; then
if [[ $exitstatus = 0 ]]; then
service nodm stop >/dev/null 2>&1 && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm
service lightdm stop >/dev/null 2>&1 && systemctl disable lightdm.service >/dev/null 2>&1
fi
......
......@@ -72,6 +72,14 @@ while true; do
LIST+=( "SSH" "Reconfigure SSH daemon" )
LIST+=( "Firmware" "Run apt update & apt upgrade" )
if [[ "$SHELL" != "/bin/bash" ]]; then
LIST+=( "BASH" "Revert to stock BASH shell" )
else
LIST+=( "ZSH" "Install ZSH with most used plugins and tmux" )
fi
[[ "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" && \
-n $(bin2fex </boot/script.bin 2>/dev/null | grep -w "hdmi_used = 1") ]] && LIST+=( "Display" "set the display resolution" )
[[ "$LINUXFAMILY" = odroidc* && "$BRANCH" = "default" ]] && LIST+=( "Display" "set the display resolution" )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment