From 44558263b02ff9b4dc51d609b34d02f95ebb7d10 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Thu, 19 Mar 2020 18:17:57 +0100 Subject: [PATCH] [CODE] essentials: install pip, customizable zshrc --- README.md | 1 + defaults/main.yml | 3 + files/dotfiles | 2 +- tasks/essentials-Archlinux.yml | 3 +- tasks/essentials-Centos.yml | 13 ++++- tasks/essentials-Darwin.yml | 3 +- tasks/essentials-Debian.yml | 4 +- tasks/essentials.yml | 2 +- tasks/usersettings.yml | 27 ++++++++- templates/_zshrc.j2 | 102 +++++++++++++++++++++++++++++++++ 10 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 templates/_zshrc.j2 diff --git a/README.md b/README.md index bb6aa10..f00da2e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ The User Setup will change the user shell and global gitconfig. This can be disa - `usersetup_gitconfig`: Boolean to disable overriding the global gitconfig (default: true) * `gitconfig_name`: User's name in .gitconfig file (default: n.a.) * `gitconfig_email`: User's email in .gitconfig file (default: n.a.) +- `usersetup_virtualenvwrapper`: Boolean to enable the virtualenvwrapper plugin in oh-my-zsh (default: false) The development environment for different programming languages can be setup automatically. To enable, that Visual Studio Code will be installed and configured, set `user_vscode` to true, otherwise only the bare development toolchain will be installed. diff --git a/defaults/main.yml b/defaults/main.yml index af32e48..63dfee7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,9 @@ usersetup_chsh: true # override global gitconfig usersetup_gitconfig: true +# enable virtualenvwrapper plugin in oh-my-zsh +usersetup_virtualenvwrapper: false + # install VS Code and selectively activate different programming languages user_vscode: false user_lang_cpp: false diff --git a/files/dotfiles b/files/dotfiles index f311d13..4f88023 160000 --- a/files/dotfiles +++ b/files/dotfiles @@ -1 +1 @@ -Subproject commit f311d13eeaccdeab4dec4977c24b9dd4c3e8e92f +Subproject commit 4f8802334f8793e056dfe842657c67765d1fae9f diff --git a/tasks/essentials-Archlinux.yml b/tasks/essentials-Archlinux.yml index 2081abe..53f11ae 100644 --- a/tasks/essentials-Archlinux.yml +++ b/tasks/essentials-Archlinux.yml @@ -1,5 +1,5 @@ --- -# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - ArchLinux Version +# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh, pip) - ArchLinux Version - name: essentials - Install essential utilities become: yes @@ -14,3 +14,4 @@ - zsh - vim - tmux + - python-pip diff --git a/tasks/essentials-Centos.yml b/tasks/essentials-Centos.yml index fc65595..60aa934 100644 --- a/tasks/essentials-Centos.yml +++ b/tasks/essentials-Centos.yml @@ -1,5 +1,5 @@ --- -# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - CentOS Version +# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh, pip) - CentOS Version - name: essentials - Install essential utilities become: yes @@ -13,3 +13,14 @@ - zsh - vim - tmux + +- name: essentials - Install pip - Activate EPEL + become: yes + yum: + name: epel-release + state: present +- name: essentials - Install pip - Install + become: yes + yum: + name: python-pip + state: present diff --git a/tasks/essentials-Darwin.yml b/tasks/essentials-Darwin.yml index d9f3fed..035a6bd 100644 --- a/tasks/essentials-Darwin.yml +++ b/tasks/essentials-Darwin.yml @@ -1,5 +1,5 @@ --- -# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - macOS Version +# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh, pip) - macOS Version - name: essentials - Install essential utilities package: @@ -12,3 +12,4 @@ - zsh - vim - tmux + - python # includes pip diff --git a/tasks/essentials-Debian.yml b/tasks/essentials-Debian.yml index 88c1af4..d59c497 100644 --- a/tasks/essentials-Debian.yml +++ b/tasks/essentials-Debian.yml @@ -1,5 +1,5 @@ --- -# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - Debian Version +# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh, pip) - Debian Version - name: essentials - Install essential utilities become: yes @@ -14,3 +14,5 @@ - zsh - vim - tmux + - python-pip + - python3-pip diff --git a/tasks/essentials.yml b/tasks/essentials.yml index 956cd4b..278d4c1 100644 --- a/tasks/essentials.yml +++ b/tasks/essentials.yml @@ -1,5 +1,5 @@ --- -# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) +# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh, pip) - name: essentials - Install essential utilities include_tasks: "{{ item }}" diff --git a/tasks/usersettings.yml b/tasks/usersettings.yml index a39a605..ff28188 100644 --- a/tasks/usersettings.yml +++ b/tasks/usersettings.yml @@ -16,6 +16,27 @@ when: - fzf_git.after != fzf_git.before +- name: usersettings - Install pip virtualenvwrapper + block: + - name: usersettings - Install pip virtualenvwrapper (Debian) + become: yes + pip: + name: virtualenvwrapper + extra_args: --system + when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Debian" + - name: usersettings - Install pip virtualenvwrapper (macOS) + environment: + PATH: "/usr/local/bin:{{ ansible_env.PATH }}" + pip: + name: virtualenvwrapper + when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin" + - name: usersettings - Install pip virtualenvwrapper (CentOS, ArchLinux) + become: yes + pip: + name: virtualenvwrapper + when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Centos" or + (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Archlinux" + when: usersetup_virtualenvwrapper - name: usersettings - Copy dotfiles copy: src: "{{ item.src }}" @@ -24,9 +45,13 @@ - { src: "{{ role_path }}/files/dotfiles/_gitignore_global", dest: ".gitignore_global" } - { src: "{{ role_path }}/files/dotfiles/_tmux.conf", dest: ".tmux.conf" } - { src: "{{ role_path }}/files/dotfiles/_vimrc", dest: ".vimrc" } - - { src: "{{ role_path }}/files/dotfiles/_zshrc", dest: ".zshrc" } - { src: "{{ role_path }}/files/dotfiles/_oh-my-zsh/custom/themes/agnoster.zsh-theme", dest: ".oh-my-zsh/custom/themes/agnoster.zsh-theme" } - { src: "{{ role_path }}/files/dotfiles/_oh-my-zsh/custom/themes/jtbx.zsh-theme", dest: ".oh-my-zsh/custom/themes/jtbx.zsh-theme" } +- name: usersettings - Set zshrc + template: + src: "{{ role_path }}/templates/_zshrc.j2" + dest: "{{ ansible_user_dir }}/.zshrc" + when: usersetup_gitconfig == true - name: usersettings - Set global gitconfig template: src: "{{ role_path }}/templates/_gitconfig.j2" diff --git a/templates/_zshrc.j2 b/templates/_zshrc.j2 new file mode 100644 index 0000000..a353ae2 --- /dev/null +++ b/templates/_zshrc.j2 @@ -0,0 +1,102 @@ +# Unified zshrc of Jannik Beyerstedt +export TERM=xterm-256color +{% if usersetup_virtualenvwrapper|default(false)|bool %} +VIRTUALENVWRAPPER_PYTHON=$(which python3) +{% endif %} + +DEFAULT_USER="jannik" +DISABLE_UPDATE_PROMPT=true + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load. +ZSH_THEME="jtbx" + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Case sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Oh-my-zsh Update settings +DISABLE_AUTO_UPDATE="true" +# export UPDATE_ZSH_DAYS=13 + +# 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. +# COMPLETION_WAITING_DOTS="true" + +# This makes repository status check for large repositories much, much faster. +DISABLE_UNTRACKED_FILES_DIRTY="true" + +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +HIST_STAMPS="yyyy-mm-dd" + +# Example format: plugins=(rails git textmate ruby lighthouse) +plugins=( + git + docker + docker-compose + fzf + pip +{% if usersetup_virtualenvwrapper|default(false)|bool %} + virtualenvwrapper +{% endif %} +) + +source $ZSH/oh-my-zsh.sh + +# User configuration +if [ "$(uname)" != "Darwin" ]; then + export LANG="en_US.UTF-8" + export LC_CTYPE="en_US.UTF-8" + export LC_NUMERIC="de_DE.UTF-8" + export LC_TIME="de_DE.UTF-8" + export LC_COLLATE="de_DE.UTF-8" + export LC_MONETARY="de_DE.UTF-8" + export LC_MESSAGES="en_US.UTF-8" + export LC_PAPER="de_DE.UTF-8" + export LC_NAME="de_DE.UTF-8" + export LC_ADDRESS="de_DE.UTF-8" + export LC_TELEPHONE="de_DE.UTF-8" + export LC_MEASUREMENT="de_DE.UTF-8" +else + export LANG="en_US.UTF-8" +fi + +# load host specific settings +[[ -f "$HOME/.zshrc-host" ]] && source $HOME/.zshrc-host + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# 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 the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +alias pip3-upgrade="pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U" +alias pip3-list-updates="pip3 list --outdated" + +alias rsync-copy="rsync -avz --progress -h" +alias rsync-move="rsync -avz --progress -h --remove-source-files" +alias rsync-update="rsync -avzu --progress -h" +alias rsync-synchronize="rsync -avzu --delete --progress -h" + +# stolen from: https://eldritch.cafe/@lexi/103707492979358755 +alias doch='sudo sh -c "$(fc -n -l -- -1)"'