Tested on Debian 6, Ubuntu 14.04, Ubuntu 16.04, macOS 10.12, CentOS 7.
For upgrade from viasite-ansible.zsh 1.x, 2.x to 3.0 see below.
Includes:
- zsh
- antigen
- oh-my-zsh
- powerlevel9k theme
- zsh-autosuggestions
- zsh-syntax-highlighting (except Debian Squeeze), with workaround for #zsh-syntax-highlighting/286
- unixorn/autoupdate-antigen.zshplugin
- ytet5uy4/fzf-widgets
- urbainvaes/fzf-marks
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
- install only plugins that useful for your machine. For example, plugin
docker
will not install if you have not Docker
1.5 mins demo
Color schemes
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:
If you use 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
Then configure terminal application.
Manual install
- Install Ansible. For Ubuntu:
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
- Download role:
sudo ansible-galaxy install viasite-ansible.zsh
- Write playbook or use playbook.yml:
- hosts: all
vars:
zsh_autosuggestions_bind_key: "^U"
roles:
- viasite-ansible.zsh
- Provision playbook:
sudo ansible-playbook -i "localhost," -c local 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 --extra-vars="zsh_user=otheruser"
- 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.
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
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
-
Download powerline fonts, install font that you prefer. You can see screenshots here.
-
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.
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+,
Default hotkeys from plugins:
- → - accept autosuggestion
- Ctrl+Z - move current application to background, press again for return to foreground
- Ctrl+G - jump to bookmarked directory. Use
mark
in directory for add to bookmarks - Ctrl+R - show command history
- Ctrl+@ - show all fzf-widgets
- Ctrl+@,C - fzf-change-dir, press fast!
- Ctrl+\ - fzf-change-recent-dir
- Ctrl+@,G - fzf-change-repository
- Ctrl+@,F - fzf-edit-files
- Ctrl+@,. - fzf-edit-dotfiles
- Ctrl+@,S - fzf-exec-ssh (using your ~/.ssh/config)
- Ctrl+@,G,A - fzf-git-add-file
- Ctrl+@,G,B - fzf-git-checkout-branch
- Ctrl+@,G,D - fzf-git-delete-branches
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.
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/zsh-autosuggestions@v0.3.3 # 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:
- 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.
- 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 | version_compare('4.3.17', '>=') }}"
# load only for macOS
- { name: brew, when: "{{ ansible_os_family != 'Darwin' }}" }
Note: you should wrap condition in "{{ }}"