Skip to content

Commit

Permalink
[Lazy] Switch to zsh / oh-my-zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
nervo committed Oct 22, 2024
1 parent 5013584 commit 9eda8ff
Show file tree
Hide file tree
Showing 21 changed files with 517 additions and 558 deletions.
2 changes: 1 addition & 1 deletion lazy.ansible/.manala/Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sh:
else \
$(call manala_docker_command, \
$(if $(PORT),--publish $(PORT)), \
) bash --login ; \
) zsh --login ; \
fi
.PHONY: sh

Expand Down
47 changes: 27 additions & 20 deletions lazy.ansible/.manala/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ARG GOMPLATE_VERSION="4.1.0"
ARG DIRENV_VERSION="2.34.0"
ARG JQ_VERSION="1.7.1"
ARG YQ_VERSION="4.44.3"
ARG FZF_VERSION="0.55.0"

# The 'container' environment variable tells systemd that it's running inside a
# Docker container environment.
Expand All @@ -29,7 +30,6 @@ RUN \
apt-get --quiet update \
&& apt-get --quiet --yes --purge --autoremove upgrade \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
bash-completion \
bzip2 \
ca-certificates \
curl \
Expand All @@ -43,9 +43,10 @@ RUN \
socat \
sudo \
vim \
zsh \
# User
&& addgroup --gid ${MANALA_GROUP_ID} lazy \
&& adduser --home /home/lazy --shell /bin/bash --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \
&& adduser --home /home/lazy --shell /bin/zsh --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \
&& install --verbose --mode 0755 --group lazy --owner lazy --directory /run/user/${MANALA_USER_ID} \
&& echo "lazy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/lazy \
# Gosu
Expand All @@ -68,10 +69,16 @@ RUN \
&& curl -sSLf "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}" \
--output /usr/local/bin/yq \
&& chmod +x /usr/local/bin/yq \
# Bash completion
&& install --verbose --mode 0755 --directory /etc/bash_completion.d \
# Oh My Bash
&& git clone https://github.com/ohmybash/oh-my-bash.git /usr/local/share/oh-my-bash \
# Oh My Zsh
&& git clone https://github.com/ohmyzsh/ohmyzsh.git /usr/local/share/oh-my-zsh \
# See: https://github.com/ohmyzsh/ohmyzsh/issues/11995
&& git clone https://github.com/zsh-users/zsh-autosuggestions.git /usr/local/share/oh-my-zsh/custom/plugins/zsh-autosuggestions \
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /usr/local/share/oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
&& echo "ZDOTDIR=/etc/zsh" > /etc/zsh/zshenv \
# Fzf
&& curl -sSLf "https://github.com/junegunn/fzf/releases/download/v${FZF_VERSION}/fzf-${FZF_VERSION}-linux_{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}.tar.gz" \
| bsdtar -xvf - -C /usr/local/bin \
&& chmod +x /usr/local/bin/fzf \
# Clean
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -90,16 +97,13 @@ RUN \
openssh-client \
pipx \
python3 \
python3-argcomplete \
shellcheck \
sshpass \
{{- range $package := $apt.packages }}
{{ $package }} \
{{- end }}
# Sudo
&& echo "Defaults env_keep += \"PIPX_*\"" > /etc/sudoers.d/pipx \
# Bash completion
&& activate-global-python-argcomplete --dest /etc/bash_completion.d \
# Clean
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -177,14 +181,23 @@ RUN \
RUN \
pipx install --pip-args="--no-cache-dir" \
molecule=={{ $molecule.version }} \
&& _MOLECULE_COMPLETE=bash_source molecule > /etc/bash_completion.d/molecule \
{{- if $molecule.dependencies }}
&& pipx inject --pip-args="--no-cache-dir" molecule \
{{- range $i, $dependency := $molecule.dependencies }}
{{- if $i }} \{{- end }}
{{ $dependency }}
{{ $dependency }} \
{{- end }}
{{- end }}
# Oh My Zsh plugin
# See: https://github.com/ohmyzsh/ohmyzsh/pull/12760
&& mkdir /usr/local/share/oh-my-zsh/custom/plugins/molecule \
&& printf "\
if [[ ! -f \"\$ZSH_CACHE_DIR/completions/_molecule\" ]]; then\n\
typeset -g -A _comps\n\
autoload -Uz _molecule\n\
_comps[molecule]=_molecule\n\
fi\n\
_MOLECULE_COMPLETE=zsh_source molecule >| \"\$ZSH_CACHE_DIR/completions/_molecule\" &|\n\
" > /usr/local/share/oh-my-zsh/custom/plugins/molecule/molecule.plugin.zsh

{{ end -}}

Expand All @@ -194,17 +207,11 @@ RUN \
RUN \
curl -sSLf "https://releases.hashicorp.com/terraform/{{ $terraform.version }}/terraform_{{ $terraform.version }}_linux_{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}.zip" \
| bsdtar -xvf - -C /usr/local/bin \
&& chmod +x /usr/local/bin/terraform \
# Bash completion
&& echo "complete -C /usr/local/bin/terraform terraform" > /etc/bash_completion.d/terraform \
# Bash aliases
&& printf "alias tf='terraform'\n\
complete -C /usr/local/bin/terraform tf\n\
" > /etc/profile.d/terraform.sh
&& chmod +x /usr/local/bin/terraform

{{ end -}}

# Run
COPY docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
CMD ["zsh"]
148 changes: 0 additions & 148 deletions lazy.ansible/.manala/etc/profile.d/oh-my-bash.sh.tmpl

This file was deleted.

8 changes: 0 additions & 8 deletions lazy.ansible/.manala/etc/profile.d/zz-direnv.sh.tmpl

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 9eda8ff

Please sign in to comment.