From 63457caed529cf98708ac931d6ddb621bda53b20 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sun, 7 Mar 2021 22:23:50 +0000 Subject: [PATCH 1/2] updating todo --- tasks.todo | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks.todo b/tasks.todo index c22b3df..cb58a86 100644 --- a/tasks.todo +++ b/tasks.todo @@ -1,5 +1,6 @@ Tasks: ☐ Configure nebula + ☐ Add a simplified zsh setup with Agnoster for root user Done: ✔ Create initial folder layout @started(21-02-28 23:29) @done(21-03-03 14:30) @lasted(2d15h1m16s) From 3c0e08ac91df0c9bb51ea7ec07c5283ad70841be Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sun, 7 Mar 2021 23:08:35 +0000 Subject: [PATCH 2/2] adding oh-my-zsh for root user --- roles/cleanup/tasks/main.yml | 20 +++++-- roles/shell/tasks/main.yml | 68 +++++++++++++++++++++++ roles/shell/templates/.zshrc.root.j2 | 82 ++++++++++++++++++++++++++++ tasks.todo | 2 +- 4 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 roles/shell/templates/.zshrc.root.j2 diff --git a/roles/cleanup/tasks/main.yml b/roles/cleanup/tasks/main.yml index a4a0d68..994d8aa 100644 --- a/roles/cleanup/tasks/main.yml +++ b/roles/cleanup/tasks/main.yml @@ -1,5 +1,15 @@ -- name: Remove temporary directory - file: - path: "{{ temp_install_dir.path }}" - state: absent - when: temp_install_dir.path is defined +- name: Cleanup tasks + tags: cleanup + become: true + block: + - name: Remove temporary directory + file: + path: "{{ temp_install_dir.path }}" + state: absent + when: temp_install_dir.path is defined + + - name: Remove temporary root directory + file: + path: "{{ temp_install_dir_root.path }}" + state: absent + when: temp_install_dir_root.path is defined diff --git a/roles/shell/tasks/main.yml b/roles/shell/tasks/main.yml index a97fbe2..7cc4254 100644 --- a/roles/shell/tasks/main.yml +++ b/roles/shell/tasks/main.yml @@ -88,3 +88,71 @@ group: "{{ default_user_group }}" force: yes mode: 0644 + +- name: Configure shell for root user + tags: shell + become: true + block: + - name: Get root home + user: + name: root + state: present + shell: /bin/zsh + register: root_user_details + + - name: Set root home + set_fact: + root_user_home: "{{ root_user_details.home }}" + + - name: Print root user home + debug: + var: root_user_home + + - name: Install .tmux.conf to root user + copy: + src: .tmux.conf + dest: "{{ root_user_home }}/.tmux.conf" + force: yes + mode: 0644 + + - name: Create temporary root install directory + tempfile: + path: "{{ root_user_home }}" + state: directory + suffix: .tmp + register: temp_install_dir_root + changed_when: false + + - name: Download oh-my-zsh + get_url: + url: https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh + dest: "{{ temp_install_dir_root.path }}" + mode: 0777 + + - name: Install oh-my-zsh + shell: "sh {{ temp_install_dir_root.path }}/install.sh --unattended" + args: + creates: "{{ root_user_home }}/.oh-my-zsh" + + - name: Install zsh-syntax-highlighting + git: + repo: "https://github.com/zsh-users/zsh-syntax-highlighting.git" + version: master + dest: "{{ root_user_home }}/.zsh/zsh-syntax-highlighting" + clone: yes + update: yes + + - name: Install zsh-autosuggestions + git: + repo: https://github.com/zsh-users/zsh-autosuggestions + version: master + dest: "{{ root_user_home }}/.zsh/zsh-autosuggestions" + clone: yes + update: yes + + - name: Install .zshrc to root user + template: + src: .zshrc.root.j2 + dest: "{{ root_user_home }}/.zshrc" + force: yes + mode: 0644 diff --git a/roles/shell/templates/.zshrc.root.j2 b/roles/shell/templates/.zshrc.root.j2 new file mode 100644 index 0000000..a7f1dba --- /dev/null +++ b/roles/shell/templates/.zshrc.root.j2 @@ -0,0 +1,82 @@ +# Path to your oh-my-zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +ZSH_THEME="agnoster" + +# Which plugins would you like to load? +# Standard plugins can be found in ~/.oh-my-zsh/plugins/* +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=( + git + sudo + colored-man-pages + copydir + cp + jump + tmux + docker + docker-compose +) + +ZSH_DISABLE_COMPFIX="true" +source $ZSH/oh-my-zsh.sh + +HISTSIZE=50000 +SAVEHIST=10000 +setopt extended_history +setopt hist_expire_dups_first +setopt hist_ignore_dups +setopt hist_ignore_space +setopt inc_append_history +setopt share_history + +# Changing directories +setopt auto_cd +setopt auto_pushd +unsetopt pushd_ignore_dups +setopt pushdminus + +# Completion +setopt auto_menu +setopt always_to_end +setopt complete_in_word +unsetopt flow_control +unsetopt menu_complete +zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' +zstyle ':completion::complete:*' use-cache 1 +zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR +zstyle ':completion:*' list-colors '' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' + +# Other +setopt prompt_subst + +################################################################ +# ZSH # +################################################################ + +source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh + +################################################################ +# ALIASES # +################################################################ +alias ls="exa" +alias ll="exa -l" +alias pbat="bat -Pp" +alias vsource="source .venv/bin/activate" +alias size='du -c -h -d 1 | sort -h' + +################################################################ +# PATH # +################################################################ +export PATH=/usr/sbin:$PATH +export PATH="$PATH:$HOME/.local/bin" + +################################################################ +# RUST # +################################################################ +export PATH="{{ default_user_home }}/.cargo/bin:$PATH" diff --git a/tasks.todo b/tasks.todo index cb58a86..671e6e8 100644 --- a/tasks.todo +++ b/tasks.todo @@ -1,6 +1,6 @@ Tasks: ☐ Configure nebula - ☐ Add a simplified zsh setup with Agnoster for root user + ✔ Add a simplified zsh setup with Agnoster for root user @done(21-03-07 23:08) Done: ✔ Create initial folder layout @started(21-02-28 23:29) @done(21-03-03 14:30) @lasted(2d15h1m16s)