All Projects → viasite-ansible → Ansible Role Zsh

viasite-ansible / Ansible Role Zsh

Setup antigen with oh-my-zsh, powerlevel10k theme, fzf, autosuggestions, syntax-highlighting

Projects that are alternatives of or similar to Ansible Role Zsh

Zsh Vi Mode
💻 A better and friendly vi(vim) mode plugin for ZSH.
Stars: ✭ 181 (-13.81%)
Mutual labels:  zsh, oh-my-zsh
Twf
Standalone tree view file explorer, inspired by fzf.
Stars: ✭ 196 (-6.67%)
Mutual labels:  fzf, zsh
History Sync
An oh-my-zsh plugin for GPG encrypted internet synchronised Zsh history, with Git.
Stars: ✭ 135 (-35.71%)
Mutual labels:  zsh, oh-my-zsh
Fzf Tab Completion
Tab completion using fzf
Stars: ✭ 127 (-39.52%)
Mutual labels:  fzf, zsh
Z.lua
⚡ A new cd command that helps you navigate faster by learning your habits.
Stars: ✭ 2,164 (+930.48%)
Mutual labels:  fzf, zsh
Black Void Zsh
🔮 Awesome, Customable Zsh Starter Kit 🌠🌠
Stars: ✭ 206 (-1.9%)
Mutual labels:  fzf, zsh
Sheldon
A fast, configurable, shell plugin manager
Stars: ✭ 144 (-31.43%)
Mutual labels:  zsh, oh-my-zsh
Dotfiles
Alacritty + Tmux + Oh My Zsh + Neovim = ❤️
Stars: ✭ 95 (-54.76%)
Mutual labels:  zsh, oh-my-zsh
Zsh Proxy
🔩 An oh-my-zsh plugin to configure proxy
Stars: ✭ 162 (-22.86%)
Mutual labels:  zsh, oh-my-zsh
Enhancd
🚀 A next-generation cd command with your interactive filter
Stars: ✭ 2,049 (+875.71%)
Mutual labels:  fzf, zsh
Forgit
💤 A utility tool powered by fzf for using git interactively.
Stars: ✭ 1,823 (+768.1%)
Mutual labels:  fzf, zsh
Zsh In Docker
Install Zsh, Oh-My-Zsh and plugins inside a Docker container with one line!
Stars: ✭ 169 (-19.52%)
Mutual labels:  zsh, oh-my-zsh
Fzf
🌸 A command-line fuzzy finder
Stars: ✭ 40,965 (+19407.14%)
Mutual labels:  fzf, zsh
Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+2005.71%)
Mutual labels:  fzf, zsh
Zsh Nvm
Zsh plugin for installing, updating and loading nvm
Stars: ✭ 1,670 (+695.24%)
Mutual labels:  zsh, oh-my-zsh
Purify
🌈 Clean & vibrant color schemes for Vim, Terminals...
Stars: ✭ 142 (-32.38%)
Mutual labels:  zsh, oh-my-zsh
Castle Winbuntu
Homesick Castle for use on WSL.
Stars: ✭ 87 (-58.57%)
Mutual labels:  zsh, oh-my-zsh
Zsh to fish
How to make zsh like fish?
Stars: ✭ 93 (-55.71%)
Mutual labels:  zsh, oh-my-zsh
Zsh Theme
Yet another zsh theme
Stars: ✭ 153 (-27.14%)
Mutual labels:  zsh, oh-my-zsh
Dotfiles Win
🙈 oh-my-zsh on bash on windows configuration files
Stars: ✭ 167 (-20.48%)
Mutual labels:  zsh, oh-my-zsh

Build Status

Tested on Debian 10, Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, macOS 10.12, CentOS 8.

For upgrade from viasite-ansible.zsh 1.x, 2.x to 3.0 see below.

Zero-knowledge install:

If you using Ubuntu or Debian and not familiar with Ansible, you can just execute install.sh on target machine:

curl https://raw.githubusercontent.com/viasite-ansible/ansible-role-zsh/master/install.sh | bash

It will install pip3, ansible and setup zsh for root and current user.

Then configure terminal application.

Includes:

Features

  • customize powerlevel9k theme prompt segments and colors
  • default colors tested with solarized dark and default grey terminal in putty
  • add custom prompt elements from yml
  • custom zsh config with ~/.zshrc.local or /etc/zshrc.local
  • load /etc/profile.d scripts
  • install only plugins that useful for your machine. For example, plugin docker will not install if you have not Docker

1.5 mins demo

1.5 mins demo

Color schemes

colors demo

Midnight Commander Solarized Dark skin

If you using Solarized Dark scheme and mc, you should want to install skin, then set zsh_mc_solarized_skin: yes

Demo install in Vagrant

You can test work of role before install in real machine. Just execute vagrant up, then vagrant ssh for enter in virtual machine.

Note: you cannot install vagrant on VPS like Digital Ocean or in Docker. Use local machine for it. Download and install vagrant for your operating system.

Install for real machine

Zero-knowledge install: see above.

Manual install

  1. Install Ansible. For Ubuntu:
sudo apt update
sudo apt install python3-pip -y
sudo pip3 install ansible
  1. Download role:
ansible-galaxy install viasite-ansible.zsh --force
  1. Write playbook or use playbook.yml:
- hosts: all
  vars:
    zsh_antigen_bundles_extras:
      - nvm
      - joel-porquet/zsh-dircolors-solarized
    zsh_autosuggestions_bind_key: "^U"
  roles:
    - viasite-ansible.zsh
  1. Provision playbook:
ansible-playbook -i "localhost," -c local -K playbook.yml

If you want to provision role for root user on macOS, you should install packages manually:

brew install zsh git wget

It will install zsh environment for ansible remote user. If you want to setup zsh for other users, you should define variable zsh_user:

Via playbook:

- hosts: all
  roles:
    - { role: viasite-ansible.zsh, zsh_user: otheruser }
    - { role: viasite-ansible.zsh, zsh_user: thirduser }

Or via command:

ansible-playbook -i hosts zsh.yml -e zsh_user=otheruser
  1. Install fzf without shell extensions, download binary or brew install fzf for macOS.

Note: I don't use tmux-fzf and don't tested work of it.

Multiuser shared install

If you have 10+ users on host, probably you don't want manage tens of configurations and thousands of files.

In this case you can deploy single zsh config and include it to all users.

It causes some limitations:

  • Users have read only access to zsh config
  • Users cannot disable global enabled bundles
  • Possible bugs such cache write permission denied
  • Possible bugs with oh-my-zsh themes

For install shared configuration you should set zsh_shared: yes. Configuration will install to /usr/share/zsh-config, then you just can include to user config:

source /usr/share/zsh-config/.zshrc

You can still provision custom configs for several users.

Configure

You should not edit ~/.zshrc! Add your custom config to ~/.zshrc.local (per user) or /etc/zshrc.local (global). .zshrc.local will never touched by ansible.

Configure terminal application

  1. Download powerline fonts, install font that you prefer. You can see screenshots here.

  2. Set color scheme.

Personaly, I prefer Solarized Dark color sceme, Droid Sans Mono for Powerline in iTerm and DejaVu Sans Mono in Putty.

iTerm

Profiles - Text - Change Font - select font "for Powerline"

Profiles - Colors - Color Presets... - select Solarized Dark

Putty

Settings - Window - Appearance - Font settings

You can download Solarized Dark for Putty.

Gnome Terminal

gnome-terminal have built-in Solarized Dark, note that you should select both background color scheme and palette scheme.

Hotkeys

You can view hotkeys in defaults/main.yml, zsh_hotkeys.

Sample hotkey definitions:

- { hotkey: '^r', action: 'fzf-history' }
# with dependency of bundle
- { hotkey: '`', action: autosuggest-accept, bundle: zsh-users/zsh-autosuggestions }

Useful to set autosuggest-accept to ` hotkey, but it conflicts with Midnight Commander (break Ctrl+O subshell).

You can add your custom hotkeys without replace default hotkeys with zsh_hotkeys_extras variable:

zsh_hotkeys_extras:
  - { hotkey: '^[^[[D', action: backward-word } # alt+left
  - { hotkey: '^[^[[C', action: forward-word } # alt+right
  # Example <Ctrl+.><Ctrl+,> inserts 2nd argument from end of prev. cmd
  - { hotkey: '^[,', action: copy-earlier-word } # ctrl+,

Aliases

You can use aliases for your command with easy deploy. Aliases config mostly same as hotkeys config:

zsh_aliases:
  - { alias: 'dfh', action: 'df -h | grep -v docker' }
# with dependency of bundle and without replace default asiases
- zsh_aliases_extra
  - { alias: 'dfh', action: 'df -h | grep -v docker', bundle: }

Default hotkeys from plugins:

Configure bundles

You can check default bundles in defaults/main.yml. If you like default bundles, but you want to add your bundles, use zsh_antigen_bundles_extras variable (see example playbook above). If you want to remove some default bundles, you should use zsh_antigen_bundles variable.

Format of list matches antigen. All bellow variants valid:

- docker # oh-my-zsh plugin
- zsh-users/zsh-autosuggestions # plugin from github
- zsh-users/[email protected] # plugin from github with fixed version
- ~/projects/zsh/my-plugin --no-local-clone # plugin from local directory

Note that bundles can use conditions for load. There are two types of conditions:

  1. Command conditions. Just add command to bundle:
- { name: docker, command: docker }
- name: docker-compose
  command: docker-compose

Bundles docker and docker-compose will be added to config only if commands exists on target system.

  1. When conditions. You can define any ansible conditions as you define in when in tasks:
# load only for zsh >= 4.3.17
- name: zsh-users/zsh-syntax-highlighting
  when: "{{ zsh_version is version_compare('4.3.17', '>=') }}"
# load only for macOS
- { name: brew, when: "{{ ansible_os_family != 'Darwin' }}" }

Note: you should wrap condition in "{{ }}"

Upgrade

viasite-ansible.zsh v3.0 introduces antigen v2.0, it don't have backward compatibility to antigen 1.x.

I don't spent much time for smooth upgrade, therefore you probably should do some manual actions: if powerlevel9k prompt don't loaded after provision role, you should execute antigen reset.

After reopen shell all should be done.

Downgrade to antigen v1

Antigen v2 much faster (up to 2x more faster startup), but if something went wrong, you can downgrade to antigen v1, see note for zsh 4.3 users below.

For users with zsh 4.x

Antigen v2 not work on zsh < 5.0, if you use zsh 4.x, please add to you playbook:

zsh_antigen_version: v1.4.1

Known bugs

su username caused errors

See antigen issue. If both root and su user using antigen, you should use su - username in place of su username.

Or you can use bundled alias suser.

Also, you can try to fix it, add to ~/.zshrc.local:

alias su='su -'

But this alias can break you scripts, that using su.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].