From 7ca8ed574f8d2b0a1680fede9d2fabe415c70cbf Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 15 Jun 2021 10:33:52 +0200 Subject: [PATCH] Feat: update zsh config --- files/dotfiles/zsh_plugins.txt | 10 ---- files/dotfiles/zshenv | 17 +++++++ files/dotfiles/zshrc | 66 ++++++++++++++++++++++-- files/dotfiles/zshrc.local | 45 ----------------- tasks/dotfiles.yml | 91 +++++++++++++++++++++------------- tasks/zsh.yml | 72 +++++++++++++++++++++------ 6 files changed, 192 insertions(+), 109 deletions(-) delete mode 100644 files/dotfiles/zsh_plugins.txt create mode 100644 files/dotfiles/zshenv delete mode 100644 files/dotfiles/zshrc.local diff --git a/files/dotfiles/zsh_plugins.txt b/files/dotfiles/zsh_plugins.txt deleted file mode 100644 index 59e948e..0000000 --- a/files/dotfiles/zsh_plugins.txt +++ /dev/null @@ -1,10 +0,0 @@ -zsh-users/zsh-syntax-highlighting -zsh-users/zsh-autosuggestions -zsh-users/zsh-history-substring-search -desyncr/auto-ls -andrewferrier/fzf-z - -https://github.com/denysdovhan/spaceship-prompt spaceship - - - diff --git a/files/dotfiles/zshenv b/files/dotfiles/zshenv new file mode 100644 index 0000000..11a0b62 --- /dev/null +++ b/files/dotfiles/zshenv @@ -0,0 +1,17 @@ +export TERM='rxvt-256color' + +# XDG +export XDG_CONFIG_HOME=$HOME/.config + +# editor +export EDITOR="nvim" +export VISUAL="nvim" + + +# zsh +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export HISTFILE="$ZDOTDIR/.zhistory" # History filepath +export HISTSIZE=10000 # Maximum events for internal history +export SAVEHIST=10000 # Maximum events in history file + + diff --git a/files/dotfiles/zshrc b/files/dotfiles/zshrc index 505c561..697afbc 100644 --- a/files/dotfiles/zshrc +++ b/files/dotfiles/zshrc @@ -1,5 +1,61 @@ -# Created by newuser for 5.5.1 -source <(antibody init) -antibody bundle < ~/.zsh_plugins.txt -PATH="$PATH:$(ruby -e 'print Gem.user_dir')/bin:$(yarn config get prefix)/bin" -source ~/.zshrc.local +fpath+=$ZDOTDIR/pure + +autoload -U compinit +zstyle ':completion:*' menu select +zmodload zsh/complist +compinit +_comp_options+=(globdots) # Include hidden files. + +# Prompt theme +# git clone https://github.com/sindresorhus/pure ~/.config/zsh/ +autoload -U promptinit; promptinit +prompt pure + +# Cursor for vimode +# ZLE hooks for prompt's vi mode status +function zle-line-init zle-keymap-select { + # Change the cursor style depending on keymap mode. + case $KEYMAP { + vicmd) + printf '\e[0 q' # Box. + ;; + + viins|main) + printf '\e[6 q' # Vertical bar. + ;; + } +} +zle -N zle-line-init +zle -N zle-keymap-select + +# Switch between vimode quickly +export KEYTIMEOUT=1 + +# Alias +## Colors +alias ls='ls --color' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +## Prompt when over right +alias cp='cp -iv' +alias mv='mv -iv' +alias rm='rm -i' + + +# Autosuggestions +# git clone https://github.com/zsh-users/zsh-autosuggestions ~/.config/zsh/ +source ~/.config/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh +ZSH_AUTOSUGGEST_STRATEGY=(history completion) + +# Syntax Highlight +# git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.config/zsh/ +source ~/.config/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +# Auto-ls +source ~/.config/zsh/auto-ls/auto-ls.zsh + + +source /usr/share/fzf/key-bindings.zsh +source /usr/share/fzf/completion.zsh + diff --git a/files/dotfiles/zshrc.local b/files/dotfiles/zshrc.local deleted file mode 100644 index f933b07..0000000 --- a/files/dotfiles/zshrc.local +++ /dev/null @@ -1,45 +0,0 @@ -# Lines configured by zsh-newuser-install -HISTFILE=~/.zsh_history -HISTSIZE=1000 -SAVEHIST=1000 -setopt appendhistory nomatch -# End of lines configured by zsh-newuser-install -# The following lines were added by compinstall -zstyle :compinstall filename '/home/lafrite/.zshrc' - -autoload -Uz compinit -compinit -# End of lines added by compinstall - -# Autocompletion insensitive to case -zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' - -export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=245" -# automatic color scheme with pywall - -# Vim keybindings -bindkey -v - -# substring search -bindkey '^[[A' history-substring-search-up -bindkey '^[[B' history-substring-search-down - -bindkey -M vicmd 'k' history-substring-search-up -bindkey -M vicmd 'j' history-substring-search-down - -# fzf -source /usr/share/fzf/key-bindings.zsh -source /usr/share/fzf/completion.zsh - -# fzf-z -export FZFZ_EXTRA_DIRS="/media/documents/" - -# Alias -alias notes="vim -c Note" -# taskwarrior alias -alias in="task add +in" - -export EDITOR="vim" - -# auto_ls pluting -export AUTO_LS_COMMANDS=(ls git-status) diff --git a/tasks/dotfiles.yml b/tasks/dotfiles.yml index ac20661..6767ee0 100644 --- a/tasks/dotfiles.yml +++ b/tasks/dotfiles.yml @@ -1,4 +1,13 @@ --- +- name: dotfiles -- Copying Xdefaults + template: + src: files/dotfiles/Xdefaults + dest: /home/{{ item.username }}/.Xdefaults + owner: "{{ item.username }}" + group: "{{ item.group }}" + with_items: "{{ dotusers }}" + +# Tmux - name: dotfiles -- Copy tmux.conf template: src: files/dotfiles/tmux.conf @@ -7,51 +16,63 @@ group: "{{ item.group }}" with_items: "{{ dotusers }}" -# Zsh config -- name: dotfiles -- Download antibody - get_url: - url: https://raw.githubusercontent.com/getantibody/installer/master/install - dest: /tmp/antibody.sh - mode: 0770 - when: prompt == "zsh" -- name: dotfiles -- Execute the antibody.sh - shell: /tmp/antibody.sh - become: yes - ignore_errors: yes - when: prompt == "zsh" - -- name: dotfiles -- Remove the antibody.sh - file: path=/tmp/antibody.sh state=absent - when: prompt == "zsh" +# ZSH +- name: dotiles -- create .config/zsh directory + file: + path: /home/{{ item.username }}/.config/zsh/ + state: directory + mode: '0755' + with_items: "{{ dotusers }}" + when: prompt == 'zsh' - name: dotfiles -- Copy local zshrc template: src: files/dotfiles/zshrc - dest: /home/{{ item.username }}/.zshrc + dest: /home/{{ item.username }}/.config/zsh/.zshrc owner: "{{ item.username }}" group: "{{ item.group }}" with_items: "{{ dotusers }}" when: prompt == 'zsh' -- name: dotfiles -- Copy local zshrc.local +- name: dotfiles -- Copy local zshenv template: - src: files/dotfiles/zshrc.local - dest: /home/{{ item.username }}/.zshrc.local + src: files/dotfiles/zshenv + dest: /home/{{ item.username }}/.zshenv owner: "{{ item.username }}" group: "{{ item.group }}" with_items: "{{ dotusers }}" when: prompt == 'zsh' -- name: dotfiles -- Copy local zsh_plugins.txt - template: - src: files/dotfiles/zsh_plugins.txt - dest: /home/{{ item.username }}/.zsh_plugins.txt - owner: "{{ item.username }}" - group: "{{ item.group }}" +- name: dotiles -- clone zsh syntax-hightlighting + git: + repo: https://github.com/zsh-users/zsh-syntax-highlighting.git + dest: /home/{{ item.username }}/.config/zsh/zsh-syntax-highlighting with_items: "{{ dotusers }}" when: prompt == 'zsh' +- name: dotiles -- clone zsh autosuggestions + git: + repo: https://github.com/zsh-users/zsh-autosuggestions.git + dest: /home/{{ item.username }}/.config/zsh/zsh-autosuggestions + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh auto-ls + git: + repo: https://github.com/desyncr/auto-ls + dest: /home/{{ item.username }}/.config/zsh/auto-ls + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh pure prompt + git: + repo: https://github.com/sindresorhus/pure.git + dest: /home/{{ item.username }}/.config/zsh/pure + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + + # Fish config - name: dotfiles -- Create fish config directory file: @@ -131,6 +152,15 @@ with_items: "{{ dotusers }}" when: editor == 'nvim' +# coc snippets +- name: dotfiles -- Copying snippets + copy: + src: files/dotfiles/ultisnips/ + dest: /home/{{ item.username }}/.config/coc/ultisnips + owner: "{{ item.username }}" + group: "{{ item.group }}" + with_items: "{{ dotusers }}" + # Alacritty terminal - name: dotfiles -- Copy alacritty config copy: @@ -168,12 +198,3 @@ group: "{{ item.group }}" with_items: "{{ dotusers }}" when: not server - -# coc snippets -- name: dotfiles -- Copying snippets - copy: - src: files/dotfiles/ultisnips/ - dest: /home/{{ item.username }}/.config/coc/ultisnips - owner: "{{ item.username }}" - group: "{{ item.group }}" - with_items: "{{ dotusers }}" diff --git a/tasks/zsh.yml b/tasks/zsh.yml index 5b6c583..8801735 100644 --- a/tasks/zsh.yml +++ b/tasks/zsh.yml @@ -1,20 +1,9 @@ --- -# - name: download default grml configuration -# get_url: -# url: http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc -# dest: /etc/zsh/newuser.zshrc.recommended -# backup: yes -# -# - name: download default grml configuration -# get_url: -# url: http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc -# dest: /etc/zsh/zshrc -# force: yes -# backup: yes - - name: Install base CLI packages pacman: - name: zsh + name: + - zsh + - grml-zsh-config state: present - name: Set shell for root to zsh @@ -24,3 +13,58 @@ tags: - first_deployement + +# ZSH dotfiles +- name: dotiles -- create .config/zsh directory + file: + path: /home/{{ item.username }}/.config/zsh/ + state: directory + mode: '0755' + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotfiles -- Copy local zshrc + template: + src: files/dotfiles/zshrc + dest: /home/{{ item.username }}/.config/zsh/.zshrc + owner: "{{ item.username }}" + group: "{{ item.group }}" + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotfiles -- Copy local zshenv + template: + src: files/dotfiles/zshenv + dest: /home/{{ item.username }}/.zshenv + owner: "{{ item.username }}" + group: "{{ item.group }}" + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh syntax-hightlighting + git: + repo: https://github.com/zsh-users/zsh-syntax-highlighting.git + dest: /home/{{ item.username }}/.config/zsh/zsh-syntax-highlighting + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh autosuggestions + git: + repo: https://github.com/zsh-users/zsh-autosuggestions.git + dest: /home/{{ item.username }}/.config/zsh/zsh-autosuggestions + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh auto-ls + git: + repo: https://github.com/desyncr/auto-ls + dest: /home/{{ item.username }}/.config/zsh/auto-ls + with_items: "{{ dotusers }}" + when: prompt == 'zsh' + +- name: dotiles -- clone zsh pure prompt + git: + repo: https://github.com/sindresorhus/pure.git + dest: /home/{{ item.username }}/.config/zsh/pure + with_items: "{{ dotusers }}" + when: prompt == 'zsh'