-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from szymonos/feat/zsh-shell
feat: zsh shell
- Loading branch information
Showing
3 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
: ' | ||
sudo .assets/provision/install_zsh.sh >/dev/null | ||
' | ||
if [ $EUID -ne 0 ]; then | ||
printf '\e[31;1mRun the script as root.\e[0m\n' | ||
exit 1 | ||
fi | ||
|
||
# determine system id | ||
SYS_ID="$(sed -En '/^ID.*(alpine|arch|fedora|debian|ubuntu|opensuse).*/{s//\1/;p;q}' /etc/os-release)" | ||
# check if package installed already using package manager | ||
APP='zsh' | ||
case $SYS_ID in | ||
alpine) | ||
apk -e info $APP &>/dev/null && exit 0 || true | ||
;; | ||
arch) | ||
pacman -Qqe $APP &>/dev/null && exit 0 || true | ||
;; | ||
fedora | opensuse) | ||
rpm -q $APP &>/dev/null && exit 0 || true | ||
;; | ||
debian | ubuntu) | ||
dpkg -s $APP &>/dev/null && exit 0 || true | ||
;; | ||
esac | ||
|
||
printf "\e[92minstalling \e[1m$APP\e[0m\n" >&2 | ||
case $SYS_ID in | ||
alpine) | ||
apk add --no-cache $APP >&2 2>/dev/null | ||
;; | ||
arch) | ||
pacman -Sy --needed --noconfirm $APP >&2 2>/dev/null | ||
;; | ||
fedora) | ||
dnf install -y $APP >&2 2>/dev/null | ||
;; | ||
debian | ubuntu) | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get update >&2 && apt-get install -y $APP >&2 2>/dev/null | ||
;; | ||
opensuse) | ||
zypper in -y $APP >&2 2>/dev/null | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env zsh | ||
: ' | ||
.assets/provision/setup_profile_user_zsh.sh | ||
' | ||
# path variables | ||
PROFILE_PATH='/etc/profile.d' | ||
OMP_PATH='/usr/local/share/oh-my-posh' | ||
|
||
# *install plugins | ||
# ~zsh-autocomplete | ||
# https://github.com/marlonrichert/zsh-autocomplete | ||
if [ -d $HOME/.zsh/zsh-autocomplete ]; then | ||
git -C $HOME/.zsh/zsh-autocomplete pull --quiet | ||
else | ||
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $HOME/.zsh/zsh-autocomplete | ||
fi | ||
if ! grep -w 'zsh-autocomplete.plugin.zsh' ~/.zshrc 2>/dev/null; then | ||
cat <<'EOF' >>$HOME/.zshrc | ||
# *plugins | ||
source $HOME/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh | ||
EOF | ||
fi | ||
# ~zsh-autosuggestions | ||
# https://github.com/zsh-users/zsh-autosuggestions | ||
if [ -d $HOME/.zsh/zsh-autosuggestions ]; then | ||
git -C $HOME/.zsh/zsh-autosuggestions pull --quiet | ||
else | ||
git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.zsh/zsh-autosuggestions | ||
fi | ||
if ! grep -w 'zsh-autosuggestions.zsh' ~/.zshrc 2>/dev/null; then | ||
echo 'source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh' >>$HOME/.zshrc | ||
fi | ||
# ~zsh-syntax-highlighting | ||
# https://github.com/zsh-users/zsh-syntax-highlighting | ||
if [ -d $HOME/.zsh/zsh-syntax-highlighting ]; then | ||
git -C $HOME/.zsh/zsh-syntax-highlighting pull --quiet | ||
else | ||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.zsh/zsh-syntax-highlighting | ||
fi | ||
if ! grep -w 'zsh-syntax-highlighting.zsh' ~/.zshrc 2>/dev/null; then | ||
echo 'source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' >>$HOME/.zshrc | ||
fi | ||
if ! grep -q '^bindkey .* autosuggest-accept' $HOME/.zshrc; then | ||
echo "bindkey '^ ' autosuggest-accept\n" >>$HOME/.zshrc | ||
fi | ||
|
||
# *aliases | ||
# add common zsh aliases | ||
grep -qw 'd/aliases.sh' ~/.zshrc 2>/dev/null || cat <<EOF >>$HOME/.zshrc | ||
# *aliases | ||
if [ -f "$PROFILE_PATH/aliases.sh" ]; then | ||
source "$PROFILE_PATH/aliases.sh" | ||
fi | ||
EOF | ||
|
||
# add git aliases | ||
if ! grep -qw 'd/aliases_git.sh' ~/.zshrc 2>/dev/null && type git &>/dev/null; then | ||
cat <<EOF >>$HOME/.zshrc | ||
# git aliases | ||
if [ -f "$PROFILE_PATH/aliases_git.sh" ] && type git &>/dev/null; then | ||
source "$PROFILE_PATH/aliases_git.sh" | ||
fi | ||
EOF | ||
fi | ||
|
||
# add kubectl autocompletion and aliases | ||
if ! grep -qw 'kubectl' ~/.zshrc 2>/dev/null && type -f kubectl &>/dev/null; then | ||
cat <<EOF >>$HOME/.zshrc | ||
# kubectl autocompletion and aliases | ||
if type -f kubectl &>/dev/null; then | ||
if [ -f "$PROFILE_PATH/aliases_kubectl.sh" ]; then | ||
source "$PROFILE_PATH/aliases_kubectl.sh" | ||
fi | ||
fi | ||
EOF | ||
fi | ||
|
||
# *add conda initialization | ||
if ! grep -qw '__conda_setup' ~/.zshrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then | ||
$HOME/miniconda3/bin/conda init zsh >/dev/null | ||
fi | ||
|
||
# *add oh-my-posh invocation | ||
if ! grep -qw 'oh-my-posh' ~/.zshrc 2>/dev/null && type oh-my-posh &>/dev/null; then | ||
cat <<EOF >>~/.zshrc | ||
# initialize oh-my-posh prompt | ||
if [ -f "$OMP_PATH/theme.omp.json" ] && type oh-my-posh &>/dev/null; then | ||
eval "\$(oh-my-posh --init --shell zsh --config "$OMP_PATH/theme.omp.json")" | ||
fi | ||
EOF | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters