zsh styling

This commit is contained in:
Tobias J. Endres 2025-02-11 19:11:07 +01:00
parent 627008ea6a
commit 65984df2f3
6 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,116 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
#ZSH_THEME="powerlevel9k/powerlevel9k"
#POWERLEVEL9K_MODE="nerdfont-complete"
#source $ZSH/themes/powerlevel9k/powerlevel9k.zsh-theme
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time Oh My Zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
CASE_SENSITIVE="false"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
HIST_STAMPS="dd.mm.yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='nvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch $(uname -m)"
# Set personal aliases, overriding those provided by Oh My Zsh libs,
# plugins, and themes. Aliases can be placed here, though Oh My Zsh
# users are encouraged to define aliases within a top-level file in
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
# - $ZSH_CUSTOM/aliases.zsh
# - $ZSH_CUSTOM/macos.zsh
# For a full list of active aliases, run `alias`.
#
# Example aliases
alias zshconfig="nano ~/.zshrc"
#alias ls="colorls"
#function cd { builtin cd "$@" && colorls }
#PATH=$PATH:~/.local/share/gem/ruby/3.3.0/bin
alias cat="batcat"
alias top="htop"
archey
ls

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: zsh_with_style/subroles/zsh

View File

@ -0,0 +1,33 @@
- name: Check if Oh My Zsh is already installed
stat:
path: "{{ user_home }}/.oh-my-zsh"
register: oh_my_zsh_installed
notify: Debug Oh My Zsh installation status
- name: Debug Oh My Zsh installation status
debug:
msg: "Oh My Zsh is {{ 'installed' if oh_my_zsh_installed.stat.exists else 'not installed' }}"
when: oh_my_zsh_installed is defined
- name: Download Oh My Zsh install script using wget
get_url:
url: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
dest: /tmp/install-ohmyzsh.sh
mode: '0755' # Makes it executable
when: not oh_my_zsh_installed.stat.exists
- name: Install Oh My Zsh for the current user
shell: |
RUNZSH=no CHSH=no sh /tmp/install-ohmyzsh.sh
args:
creates: "{{ user_home }}/.oh-my-zsh"
when: not oh_my_zsh_installed.stat.exists
become: true
become_user: "{{ ansible_user }}"
- name: Clone zsh-syntax-highlighting repository
git:
repo: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
dest: "{{ user_home }}/.oh-my-zsh/plugins/zsh-syntax-highlighting"
version: master

View File

@ -0,0 +1,2 @@
---
# No dependencies for this subrole

View File

@ -0,0 +1,14 @@
---
- name: Install zsh
apt:
name: zsh
state: present
- name: Set zsh as the default shell
shell: chsh -s $(which zsh) {{ ansible_user }}
become: true
when: ansible_user != "root"
register: chsh_result
failed_when: chsh_result.rc != 0
changed_when: false

View File

@ -0,0 +1,79 @@
---
- name: Set home directory for the user
set_fact:
user_home: "/home/{{ ansible_user }}"
- name: Set up Zsh
include_role:
name: zsh_with_style/subroles/zsh
- name: Set up Oh My Zsh
include_role:
name: zsh_with_style/subroles/ohmyzsh
- name: Install bat
apt:
name: bat
state: present
update_cache: true
become: true
- name: Ensure ~/.local/bin directory exists
file:
path: "{{ user_home }}/.local/bin"
state: directory
mode: '0755'
- name: Create symlink from batcat to bat
file:
src: /usr/bin/batcat
dest: "{{ user_home }}/.local/bin/bat"
state: link
- name: Deploy custom .zshrc file
copy:
src: .zshrc
dest: ~{{ ansible_user }}/.zshrc
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0644'
when: ansible_user != "root"
- name: Source .zshrc to apply changes
shell: |
source {{ user_home }}/.zshrc
args:
executable: /bin/zsh
become_user: "{{ ansible_user }}"
become: true
changed_when: false
# - name: Ensure Ruby is installed
# apt:
# name: ruby
# state: present
# become: yes
# - name: Get Ruby version
# command: ruby -e 'puts RUBY_VERSION'
# register: ruby_version_output
# become: yes
# - name: Set Ruby version fact
# set_fact:
# ruby_version: "{{ ruby_version_output.stdout }}"
# # - name: Ensure gem binary directory is in the user's PATH
# # lineinfile:
# # path: "{{ ansible_user_dir }}/.zshrc"
# # line: 'export PATH="$HOME/.local/share/gem/ruby/{{ ruby_version }}/bin:$PATH"'
# # create: yes
# # become: yes
# # become_user: "{{ ansible_user }}"
# - name: Install colorls gem for the current user
# gem:
# name: colorls
# become: yes
# become_user: "{{ ansible_user }}"