Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from antigen to zplug #67

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# psh ![CI](https://github.com/pascal-zarrad/psh/workflows/CI/badge.svg?branch=master)
psh - which stands for Pascal's Shell is a configuration tool for zsh. It is a composition of the finest plugins and a nice looking theme (currently it is one bundled with oh-my-zsh) that helps myself and hopefully also others to grow their productivity by customizing their shell experience.

This installer enables the fast installation of zsh, antigen (bundled with oh-my-zsh) and other stuff that is required for a great zsh experience on the shell. The installer generates always a custom .zshrc which can be modified by adding own customizations to the plugins folder. To make customizations even easier, psh has a template system that allows the import of personalized .zshrc snippets that are composed together and inserted into the generated configuration!

It was never that easy and therefore fast to install a customized shell than with psh - and with some knowledge about shell scripting with bash, you will be able to implement everything you could imagine in a configuration for zsh.
psh - which stands for Pascal's Shell is a configuration tool for zsh.
It is a composition of the finest plugins and a nice looking theme (currently it is one bundled with oh-my-zsh)
that helps myself and hopefully also others to grow their productivity by customizing their shell experience.

This installer enables the fast installation of zsh, zplug and other stuff that is required for a great zsh experience on the shell.
The installer generates always a custom .zshrc which can be modified by adding own customizations to the plugins folder.
To make customizations even easier, psh has a template system that allows the import of personalized .zshrc snippets that are composed together
and inserted into the generated configuration!

It was never that easy and therefore fast to install a customized shell than with psh - and with some knowledge about shell scripting with bash,
you will be able to implement everything you could imagine in a configuration for zsh.

> Why psh if I could just use zplug?
>
> First of all, psh is pre-configured in a way that is already quite powerful.
> Secondly, psh takes care of dependencies. You setup your new os, clone this repository
> and run the `install.sh` script. If your system is supported, psh installs literally
> everything necessary - from zsh to git or curl - you can just start working without
> any further manual stuff to do for your shell setup.

![PSH Installer](https://github.com/pascal-zarrad/psh/raw/master/.github/MEDIA/psh.gif)

Expand All @@ -22,13 +36,12 @@ But as the installer uses ```apt```, you need any system that supports ```apt```
Currently psh is only tested in the following environments:
* Arch Linux
* Manjaro Linux
* Ubuntu 22.04 (Windows Subsystem for Linux 1) (Take a look at "Note on WSL 1")
* Ubuntu 22.04 (Windows Subsystem for Linux 2)
* Ubuntu 22.04
* Ubuntu 20.04 (Windows Subsystem for Linux 1) (Take a look at "Note on WSL 1")
* Ubuntu 20.04 (Windows Subsystem for Linux 2)
* Ubuntu 20.04
* Debian 11
+ Windows Subsystem for Linux 2 (WSL2)
* Ubuntu
* Debian
+ PopOs!

Always assume that the newest operating system version relativ to the newest release has been used.

You can find further information in the wiki under [Compatibility](https://github.com/pascal-zarrad/psh/wiki/Compatibility).

Expand Down
59 changes: 30 additions & 29 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,30 @@ fi
print_success "Installed all system dependencies for psh!"
print_message ""

# Install antigen to ~/.antigen/antigen.sh
# Install zplug to ~/.zplug
print_message ""
print_message "The basic installation of zsh is now done."
print_message "Now components required for customization will be installed."
print_message "Antigen is used for plugin management."
print_message "zplug is used for plugin management."
print_message "To enable this plugin manager, it will now be installed..."
readonly ANTIGEN_FOLDER_PATH="${CUSTOM_USER_HOME_DIR}/.antigen"
readonly ANTIGEN_PATH="${ANTIGEN_FOLDER_PATH}/antigen.zsh"
if [ -f "${ANTIGEN_PATH}" ]
readonly ZPLUG_FOLDER_PATH="${CUSTOM_USER_HOME_DIR}/.zplug"
readonly ZPLUG_PATH="${ZPLUG_FOLDER_PATH}/init.zsh"
if [ -f "${ZPLUG_PATH}" ]
then
print_success "Antigen is already installed."
print_success "zplug is already installed."
else
if ! [ -d "${ANTIGEN_FOLDER_PATH}" ]; then
mkdir "${ANTIGEN_FOLDER_PATH}"
if ! [ -d "${ZPLUG_FOLDER_PATH}" ]; then
mkdir "${ZPLUG_FOLDER_PATH}"
fi
if curl -L git.io/antigen > "${ANTIGEN_PATH}"
if git clone https://github.com/zplug/zplug "${ZPLUG_FOLDER_PATH}"
then
print_success "Successfully installed antigen to ${ANTIGEN_PATH}"
print_success "Successfully installed zplug to ${ZPLUG_PATH}"
else
print_error "Failed to install antigen!"
print_error "Failed to install zplug!"
exit 1
fi
fi
fix_user_permissions "${start_arg_install_for_user_parameter}" "${ANTIGEN_FOLDER_PATH}"
fix_user_permissions "${start_arg_install_for_user_parameter}" "${ZPLUG_FOLDER_PATH}"

# Load plugin API
source "lib/plugin_api.sh"
Expand Down Expand Up @@ -263,7 +263,7 @@ print_message ""
source "lib/template_engine.sh"
print_message ""

# Now reset ~/.zshrc, as we build our own only using antigen
# Now reset ~/.zshrc, as we build our own only using zplug
# to load things
{
echo "# This .zshrc has been generated by psh."
Expand All @@ -274,20 +274,14 @@ print_message ""
# Include templates the the start of the file after the header
include_templates "${TEMPLATE_START}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"

# Enable antigen
# Enable zplug
{
echo "# Enable antigen"
echo "source ${ANTIGEN_PATH}"
echo "# Enable zplug"
echo "source ${ZPLUG_PATH}"
} >> "${ZSHRC_PATH}"

# Include templates after antigen has been loaded but before oh-my-zsh is being loaded
include_templates "${TEMPLATE_BETWEEN_ANTIGEN_AND_OH_MY_ZSH}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"

# Load oh-my-zsh library
{
echo "# Load oh-my-zsh library"
echo "antigen use oh-my-zsh"
} >> "${ZSHRC_PATH}"
# Include templates after zplug has been loaded but before oh-my-zsh is being loaded
include_templates "${TEMPLATE_BETWEEN_ZPLUG_AND_OH_MY_ZSH}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"

# Include templates between oh-my-zsh and the plugin execution
include_templates "${TEMPLATE_BETWEEN_OH_MY_ZSH_AND_PLUGINS}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"
Expand Down Expand Up @@ -333,14 +327,21 @@ if [ "${start_arg_disable_plugin_system_parameter}" -ne 1 ]; then
print_message ""
fi

# Include templates after plugins being loaded but before antigen settings are applied
include_templates "${TEMPLATE_AFTER_PLUGINS_BEFORE_ANTIGEN_APPLY}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"
# Include templates after plugins being loaded but before zplug settings are applied
include_templates "${TEMPLATE_AFTER_PLUGINS_BEFORE_ZPLUG_APPLY}" "${start_arg_disable_template_engine_parameter}" "${ZSHRC_PATH}"

{
# Now finish by telling antigen to apply the bundles and themes
# Now finish by telling zplug to inhstall and load the bundles and themes
# Now load oh-my-zsh library
echo "# Apply everything"
echo "antigen apply"
echo "# Install plugins"
echo "if ! zplug check --verbose; then"
echo " printf \"Install? [y/N]: \""
echo " if read -q; then;"
echo " echo; zplug install"
echo " fi"
echo "fi"
echo "# Load plugins"
echo "zplug load"
} >> "${ZSHRC_PATH}"

# Include templates at the end of the .zshrc
Expand Down
37 changes: 24 additions & 13 deletions lib/plugin_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,35 @@ function write_zshrc() {
echo "$content" >> "${ZSHRC_PATH}"
}

# Function that checks if antigen bundle is loaded or not
# and then adds the bundle to the .zshrc
#
# @param $1 The bundle to add to the .zshrc
function apply_antigen_bundle() {
antigen_bundle="$1"
if ! grep -q "$antigen_bundle" "${ZSHRC_PATH}" ; then
write_zshrc "antigen bundle ${antigen_bundle}"
# Function that checks if zplug plugin is loaded or not
# and then adds the plugin to the .zshrc
#
# @param $1 The plugin to add to the .zshrc
function apply_plugin() {
zplug_plugin="$1"
if ! grep -q "zplug \"${zplug_plugin}\"" "${ZSHRC_PATH}" ; then
write_zshrc "zplug \"${zplug_plugin}\""
fi
}

# Function that checks if zplug oh-my-zsh plugin is loaded or not
# and then adds the plugin to the .zshrc
#
# @param $1 The plugin to add to the .zshrc
function apply_ohmyzsh_plugin() {
zplug_plugin="$1"
if ! grep -q "zplug \"plugins/${zplug_plugin}\", from:oh-my-zsh" "${ZSHRC_PATH}" ; then
write_zshrc "zplug \"plugins/${zplug_plugin}\", from:oh-my-zsh"
fi
}

# Function that checks if antigen theme is loaded or not
# Function that checks if zplug theme is loaded or not
# and then adds the theme to the .zshrc
#
# @param $1 The name if the theme that should be added to the zshrc
function apply_antigen_theme() {
antigen_theme="$1"
if ! grep -q "antigen theme" "${ZSHRC_PATH}" ; then
write_zshrc "antigen theme ${antigen_theme}"
function apply_ohmyzsh_theme() {
zplug_theme="$1"
if ! grep -q "zplug \"themes/${zplug_theme}\", from:oh-my-zsh, as:theme" "${ZSHRC_PATH}" ; then
write_zshrc "zplug \"themes/$zplug_theme\", from:oh-my-zsh, as:theme"
fi
}
24 changes: 12 additions & 12 deletions lib/template_engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
export readonly TEMPLATE_DIRECTIVE="#PSH_TEMPLATE="
# Different template insertion points
export readonly TEMPLATE_START="START"
export readonly TEMPLATE_BETWEEN_ANTIGEN_AND_OH_MY_ZSH="BETWEEN_ANTIGEN_AND_OH_MY_ZSH"
export readonly TEMPLATE_BETWEEN_ZPLUG_AND_OH_MY_ZSH="BETWEEN_ZPLUG_AND_OH_MY_ZSH"
export readonly TEMPLATE_BETWEEN_OH_MY_ZSH_AND_PLUGINS="BETWEEN_OH_MY_ZSH_AND_PLUGINS"
export readonly TEMPLATE_AFTER_PLUGINS_BEFORE_ANTIGEN_APPLY="AFTER_PLUGINS_BEFORE_ANTIGEN_APPLY"
export readonly TEMPLATE_AFTER_PLUGINS_BEFORE_ZPLUG_APPLY="AFTER_PLUGINS_BEFORE_ZPLUG_APPLY"
export readonly TEMPLATE_END="END"

# Store the paths of our different template types in the arrays
# to reduce I/O operations in comparison to v1 of the engine.
templates_start=()
templates_between_antigen_and_oh_my_zsh=()
templates_between_zplug_and_oh_my_zsh=()
templates_between_oh_my_zsh_and_plugins=()
templates_after_plugins_before_antigen_apply=()
templates_after_plugins_before_zplug_apply=()
templates_end=()
# Load our templates
echo "Searching for templates..."
Expand All @@ -53,14 +53,14 @@ do
"${TEMPLATE_DIRECTIVE}$TEMPLATE_START")
templates_start=("${templates_start[@]}" "$templateFile")
;;
"${TEMPLATE_DIRECTIVE}$TEMPLATE_BETWEEN_ANTIGEN_AND_OH_MY_ZSH")
templates_between_antigen_and_oh_my_zsh=("${templates_between_antigen_and_oh_my_zsh[@]}" "$templateFile")
"${TEMPLATE_DIRECTIVE}$TEMPLATE_BETWEEN_ZPLUG_AND_OH_MY_ZSH")
templates_between_zplug_and_oh_my_zsh=("${templates_between_zplug_and_oh_my_zsh[@]}" "$templateFile")
;;
"${TEMPLATE_DIRECTIVE}$TEMPLATE_BETWEEN_OH_MY_ZSH_AND_PLUGINS")
templates_between_oh_my_zsh_and_plugins=("${templates_between_oh_my_zsh_and_plugins[@]}" "$templateFile")
;;
"${TEMPLATE_DIRECTIVE}$TEMPLATE_AFTER_PLUGINS_BEFORE_ANTIGEN_APPLY")
templates_after_plugins_before_antigen_apply=("${templates_after_plugins_before_antigen_apply[@]}" "$templateFile")
"${TEMPLATE_DIRECTIVE}$TEMPLATE_AFTER_PLUGINS_BEFORE_ZPLUG_APPLY")
templates_after_plugins_before_zplug_apply=("${templates_after_plugins_before_zplug_apply[@]}" "$templateFile")
;;
"${TEMPLATE_DIRECTIVE}$TEMPLATE_END")
templates_end=("${templates_end[@]}" "$templateFile")
Expand Down Expand Up @@ -96,14 +96,14 @@ function include_templates() {
"$TEMPLATE_START")
currentTemplateFiles=("${templates_start[@]}")
;;
"$TEMPLATE_BETWEEN_ANTIGEN_AND_OH_MY_ZSH")
currentTemplateFiles=("${templates_between_antigen_and_oh_my_zsh[@]}")
"$TEMPLATE_BETWEEN_ZPLUG_AND_OH_MY_ZSH")
currentTemplateFiles=("${templates_between_zplug_and_oh_my_zsh[@]}")
;;
"$TEMPLATE_BETWEEN_OH_MY_ZSH_AND_PLUGINS")
currentTemplateFiles=("${templates_between_oh_my_zsh_and_plugins[@]}")
;;
"$TEMPLATE_AFTER_PLUGINS_BEFORE_ANTIGEN_APPLY")
currentTemplateFiles=("${templates_after_plugins_before_antigen_apply[@]}")
"$TEMPLATE_AFTER_PLUGINS_BEFORE_ZPLUG_APPLY")
currentTemplateFiles=("${templates_after_plugins_before_zplug_apply[@]}")
;;
"$TEMPLATE_END")
currentTemplateFiles=("${templates_end[@]}")
Expand Down
2 changes: 1 addition & 1 deletion plugins/alias-finder/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "alias-finder"
apply_ohmyzsh_plugin "alias-finder"
2 changes: 1 addition & 1 deletion plugins/aliases-cheatsheet/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "aliases"
apply_ohmyzsh_plugin "aliases"
2 changes: 1 addition & 1 deletion plugins/ansible/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "ansible"
apply_ohmyzsh_plugin "ansible"
2 changes: 1 addition & 1 deletion plugins/aws/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "aws"
apply_ohmyzsh_plugin "aws"
2 changes: 1 addition & 1 deletion plugins/azure/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "azure"
apply_ohmyzsh_plugin "azure"
2 changes: 1 addition & 1 deletion plugins/bgnotify/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "bgnotify"
apply_ohmyzsh_plugin "bgnotify"
2 changes: 1 addition & 1 deletion plugins/brew/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "brew"
apply_ohmyzsh_plugin "brew"
2 changes: 1 addition & 1 deletion plugins/bun-js/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "bun"
apply_ohmyzsh_plugin "bun"
2 changes: 1 addition & 1 deletion plugins/catimg/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "catimg"
apply_ohmyzsh_plugin "catimg"
2 changes: 1 addition & 1 deletion plugins/command-not-found/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : nicojust@users.noreply.github.com
#==================================================================

apply_antigen_bundle "command-not-found"
apply_ohmyzsh_plugin "command-not-found"
2 changes: 1 addition & 1 deletion plugins/common-aliases/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "common-aliases"
apply_ohmyzsh_plugin "common-aliases"
2 changes: 1 addition & 1 deletion plugins/composer/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "composer"
apply_ohmyzsh_plugin "composer"
2 changes: 1 addition & 1 deletion plugins/copypath/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "copypath"
apply_ohmyzsh_plugin "copypath"
2 changes: 1 addition & 1 deletion plugins/direnv/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "direnv"
apply_ohmyzsh_plugin "direnv"
6 changes: 3 additions & 3 deletions plugins/docker/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "docker"
apply_antigen_bundle "docker-compose"
apply_antigen_bundle "ctop"
apply_ohmyzsh_plugin "docker"
apply_ohmyzsh_plugin "docker-compose"
apply_ohmyzsh_plugin "ctop"
2 changes: 1 addition & 1 deletion plugins/encode64/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "encode64"
apply_ohmyzsh_plugin "encode64"
2 changes: 1 addition & 1 deletion plugins/extract/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "extract"
apply_ohmyzsh_plugin "extract"
2 changes: 1 addition & 1 deletion plugins/genpass/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "genpass"
apply_ohmyzsh_plugin "genpass"
6 changes: 3 additions & 3 deletions plugins/git/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "git"
apply_antigen_bundle "gitignore"
apply_antigen_bundle "git-commit"
apply_ohmyzsh_plugin "git"
apply_ohmyzsh_plugin "gitignore"
apply_ohmyzsh_plugin "git-commit"
2 changes: 1 addition & 1 deletion plugins/github-cli/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "gh"
apply_ohmyzsh_plugin "gh"
2 changes: 1 addition & 1 deletion plugins/golang/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Email : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "golang"
apply_ohmyzsh_plugin "golang"
Loading