Skip to content

Commit

Permalink
Merge pull request #6 from quantumfate/powerlevel9k_to_powerlevel10k
Browse files Browse the repository at this point in the history
moved from p9k to p10k by default
  • Loading branch information
quantumfate authored Nov 7, 2022
2 parents 5250b3d + 47de88f commit 5c61981
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 188 deletions.
1 change: 0 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Then [configure terminal application](#configure-terminal-application).
- zsh
- [antigen](https://github.com/zsh-users/antigen)
- [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
- [powerlevel9k theme](https://github.com/bhilburn/powerlevel9k)
- [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
- [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
- [unixorn/autoupdate-antigen.zshplugin](https://github.com/unixorn/autoupdate-antigen.zshplugin)
Expand Down
124 changes: 49 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ This is a detached fork from [viasite-ansible/ansible-role-zsh](History.md).

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

## Zero-knowledge install:
- [Easy Zero-knowlegde Install](#zero-knowledge-install)
- [Features](#features)
- [Install](#install)
- [Theming](#theming)
- [Basic Configuration](#basic-bonfiguration)
- [Additional Configuration](#additional-bonfiguration)
- [Notes](#notes)
- [Known Bugs](#known-bugs)


## Zero-knowledge install
If you using Ubuntu or Debian and not familiar with Ansible, you can just execute [install.sh](install.sh) on target machine:
```
curl https://raw.githubusercontent.com/quantumfate/ansible-role-zsh/master/install.sh | bash
Expand All @@ -21,44 +31,27 @@ curl https://raw.githubusercontent.com/quantumfate/ansible-role-zsh/master/insta

Then [configure terminal application](#configure-terminal-application).

## Features
- theming
- customize powerlevel10k 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

## Includes:
- zsh
### Includes:
- [zsh](https://www.zsh.org/)
- [antigen](https://github.com/zsh-users/antigen)
- [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
- [powerlevel9k theme](https://github.com/bhilburn/powerlevel9k)
- [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
- [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
- [unixorn/autoupdate-antigen.zshplugin](https://github.com/unixorn/autoupdate-antigen.zshplugin)
- [ytet5uy4/fzf-widgets](https://github.com/ytet5uy4/fzf-widgets)
- [urbainvaes/fzf-marks](https://github.com/popstas/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`
- 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](https://github.com/popstas/popstas.github.io/blob/master/images/2017-03/ansible-role-zsh-demo.gif?raw=true)

## Color schemes
![colors demo](https://github.com/popstas/popstas.github.io/blob/master/images/2017-03/ansible-role-zsh-colors.gif?raw=true)

## 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](https://www.vagrantup.com/downloads.html) and install vagrant for your operating system.


## Install for real machine
## Install
Zero-knowledge install: see [above](#zero-knowledge-install).

### Manual install
Expand Down Expand Up @@ -119,9 +112,7 @@ or `brew install fzf` for macOS.

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



## Multiuser shared install
### 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.
Expand All @@ -142,7 +133,20 @@ source /usr/share/zsh-config/.zshrc

You can still provision custom configs for several users.

## Configure
## Theming

By default [pk10 theme](https://github.com/romkatv/powerlevel10k) will be used. Follow their [docs](https://github.com/romkatv/powerlevel10k/blob/master/README.md) for additional theme configuration.


### Using a different theme

You can use any theme. Just use the following variable and your theme will be applied after reloading your shell.

```yaml
zsh_antigen_theme: <yourtheme>
```
## Basic Configuration
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.
Expand All @@ -158,29 +162,6 @@ zsh_personal_config: true
zsh_alternative_name: /.zshrc_personal # Optional | Use the value skel uses to load your personal configs
```

### Configure terminal application
1. Download [powerline fonts](https://github.com/powerline/fonts), install font that you prefer.
You can see screenshots [here](https://github.com/powerline/fonts/blob/master/samples/All.md).
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](https://github.com/altercation/solarized/tree/master/putty-colors-solarized).
#### 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](defaults/main.yml), `zsh_hotkeys`.

Expand Down Expand Up @@ -218,6 +199,8 @@ zsh_hotkeys_extras:
- <kbd>Ctrl+@,G,B</kbd> - fzf-git-checkout-branch
- <kbd>Ctrl+@,G,D</kbd> - fzf-git-delete-branches

## Additional configuration

### Aliases
You can use aliases for your command with easy deploy.
Aliases config mostly same as hotkeys config:
Expand All @@ -230,8 +213,6 @@ zsh_aliases_extra:
- { alias: 'dfh', action: 'df -h | grep -v docker', bundle: }
```

## Additional configuration

Providing the name is not mandatory.

### Sources
Expand Down Expand Up @@ -261,7 +242,7 @@ zsh_paths_extras:
- { name: 'Lua language server', path: '/usr/bin/lua-language-server'}
```

## Configure bundles
### Configure bundles
You can check default bundles in [defaults/main.yml](defaults/main.yml#L37).
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.
Expand Down Expand Up @@ -295,30 +276,23 @@ Bundles `docker` and `docker-compose` will be added to config only if commands e
Note: you should wrap condition in `"{{ }}"`


## Custom config
### Custom config
You can add any code in variable `zsh_custom_before`, `zsh_custom_after`.

- zsh_custom_before - before include antigen.zsh
- zsh_custom_after - before include ~/.zshrc.local

## Upgrade
quantumfate.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.
## Notes

### 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.
### 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`

### 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:
``` yaml
zsh_antigen_version: v1.4.1
```
### 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](https://www.vagrantup.com/downloads.html) and install vagrant for your operating system.

## Known bugs
### `su username` caused errors
Expand Down
52 changes: 2 additions & 50 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---

zsh_user: "{{ ansible_user_id }}"

# .zshrc config
zsh_hist_stamps: yyyy-mm-dd
zsh_share_history: no
Expand All @@ -11,7 +10,7 @@ zsh_term: xterm-256color
zsh_mc_solarized_skin: no

zsh_personal_config: false
zsh_alternative_name: .zshrc_personal
zsh_alternative_name: .zshrc-personal

zsh_path:
- "{{ zsh_fzf_path }}"
Expand Down Expand Up @@ -162,52 +161,5 @@ zsh_fzf_ctrl_r_opts: '--exact'
zsh_command_time_min_seconds: 3
zsh_command_time_echo: ""

# powerlevel9k
zsh_powerlevel9k_left_prompt:
- context
- dir

zsh_powerlevel9k_right_prompt:
- status
- background_jobs
- vcs
- command_execution_time
- time

zsh_powerlevel_custom_elements:
- name: command_time
command: "zsh_command_time"
background: "248"
foreground: "000"

zsh_powerlevel9k_hide_host_on_local: yes
zsh_powerlevel9k_always_show_context: no # hide hostname and username from prompt on local machine
zsh_powerlevel9k_always_show_user: no # hide username from prompt on local machine
zsh_powerlevel9k_prompt_on_newline: no
zsh_powerlevel9k_shorten_dir_length: 3
zsh_powerlevel9k_status_verbose: 0

# dir (context) colors
zsh_powerlevel9k_context_default_foreground: "255" # white
zsh_powerlevel9k_context_default_background: "024" # blue
zsh_powerlevel9k_context_root_foreground: "255" # white
zsh_powerlevel9k_context_root_background: "124" # red
zsh_powerlevel9k_dir_foreground: "255" # white
zsh_powerlevel9k_dir_background: "240" # gray
zsh_powerlevel9k_dir_etc_foreground: "{{ zsh_powerlevel9k_dir_foreground }}"
zsh_powerlevel9k_dir_etc_background: "{{ zsh_powerlevel9k_dir_background }}"
zsh_powerlevel9k_dir_path_highlight_foreground: "{{ zsh_powerlevel9k_dir_foreground }}"
zsh_powerlevel9k_dir_path_highlight_background: "{{ zsh_powerlevel9k_dir_background }}"

# vcs colors
zsh_powerlevel9k_vcs_foreground: "232" # about black on any palette
zsh_powerlevel9k_vcs_clean_background: "100" # dirty green
zsh_powerlevel9k_vcs_modified_background: "094" # orange
zsh_powerlevel9k_vcs_untracked_background: "094" # orange

# command execution time
zsh_powerlevel9k_command_execution_time_foreground: "000"
zsh_powerlevel9k_command_execution_time_background: "248"

# powerlevel10k
zsh_powerlevel10k_instant_prompt: no
zsh_powerlevel10k_instant_prompt: yes
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ galaxy_info:
author: Leon Connor Holm
namespace: quantumfate
role_name: zsh
description: oh-my-zsh with powerlevel9k theme, fzf and other plugins
description: oh-my-zsh with powerlevel10k theme, fzf and other plugins

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
Expand Down
57 changes: 0 additions & 57 deletions templates/zshrc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ antigen bundle {{ bundle }}
{% endif %}
{% endfor %}

POWERLEVEL9K_INSTALLATION_PATH=$ANTIGEN_BUNDLES/bhilburn/powerlevel9k/powerlevel9k.zsh-theme

antigen theme {{ zsh_antigen_theme }}

antigen apply
Expand Down Expand Up @@ -123,61 +121,6 @@ declare -p FZF_WIDGET_OPTS > /dev/null 2>&1 && FZF_WIDGET_OPTS[insert-history]="
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE={{ zsh_autosuggestions_max_length }}
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=240" # gray highlight

# powerlevel9k
POWERLEVEL9K_SHORTEN_DIR_LENGTH={{ zsh_powerlevel9k_shorten_dir_length }}
POWERLEVEL9K_STATUS_VERBOSE={{ zsh_powerlevel9k_status_verbose }}

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=({{ zsh_powerlevel9k_left_prompt | join(" ") }})
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=({{ zsh_powerlevel9k_right_prompt | join(" ") }})
{% if zsh_powerlevel9k_hide_host_on_local and zsh_user != 'root' %}DEFAULT_USER=$USER{% endif %}

POWERLEVEL9K_ALWAYS_SHOW_CONTEXT={{ zsh_powerlevel9k_always_show_context_bool }}
POWERLEVEL9K_ALWAYS_SHOW_USER={{ zsh_powerlevel9k_always_show_user_bool }}

{% if zsh_powerlevel_custom_elements is defined and zsh_powerlevel_custom_elements %}
{% for element in zsh_powerlevel_custom_elements %}
{% set prefix = "POWERLEVEL9K_CUSTOM_" + element.name | upper %}
{{ prefix }}="{{ element.command }}"
{{ prefix }}_BACKGROUND="{{ element.background }}"
{{ prefix }}_FOREGROUND="{{ element.foreground }}"
{% endfor %}
{% endif %}

# https://github.com/bhilburn/powerlevel9k#command_execution_time
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD="{{ zsh_command_time_min_seconds }}"

POWERLEVEL9K_PROMPT_ON_NEWLINE={{ zsh_powerlevel9k_prompt_on_newline_bool }}
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true

POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="{{ zsh_powerlevel9k_context_default_foreground }}"
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="{{ zsh_powerlevel9k_context_default_background }}"
POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND="{{ zsh_powerlevel9k_context_default_foreground }}"
POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND="{{ zsh_powerlevel9k_context_default_background }}"
POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND="{{ zsh_powerlevel9k_context_root_foreground }}"
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND="{{ zsh_powerlevel9k_context_root_background }}"

POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="{{ zsh_powerlevel9k_dir_foreground }}"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="{{ zsh_powerlevel9k_dir_background }}"
POWERLEVEL9K_DIR_HOME_FOREGROUND="{{ zsh_powerlevel9k_dir_foreground }}"
POWERLEVEL9K_DIR_HOME_BACKGROUND="{{ zsh_powerlevel9k_dir_background }}"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="{{ zsh_powerlevel9k_dir_foreground }}"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="{{ zsh_powerlevel9k_dir_background }}"
POWERLEVEL9K_DIR_ETC_FOREGROUND="{{ zsh_powerlevel9k_dir_etc_foreground }}"
POWERLEVEL9K_DIR_ETC_BACKGROUND="{{ zsh_powerlevel9k_dir_etc_background }}"
POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND="{{ zsh_powerlevel9k_dir_path_highlight_foreground }}"
POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BACKGROUND="{{ zsh_powerlevel9k_dir_path_highlight_background }}"

POWERLEVEL9K_VCS_CLEAN_BACKGROUND="{{ zsh_powerlevel9k_vcs_clean_background }}"
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="{{ zsh_powerlevel9k_vcs_modified_background }}"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="{{ zsh_powerlevel9k_vcs_untracked_background }}"
POWERLEVEL9K_VCS_CLEAN_FOREGROUND="{{ zsh_powerlevel9k_vcs_foreground }}"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="{{ zsh_powerlevel9k_vcs_foreground }}"
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND="{{ zsh_powerlevel9k_vcs_foreground }}"

POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND="{{ zsh_powerlevel9k_command_execution_time_foreground }}"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND="{{ zsh_powerlevel9k_command_execution_time_background }}"

# SOURCES
{% for source in zsh_sources %}
{% if source.path is defined and source.path != '' %}
Expand Down
4 changes: 0 additions & 4 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ zsh_fzf_arch: "{% if '64' in ansible_architecture %}amd64{% elif 'arm' in ansibl
zsh_fzf_url: "https://github.com/junegunn/fzf/releases/download/{{ zsh_fzf_version }}/fzf-{{ zsh_fzf_version }}-{{ zsh_fzf_os }}_{{ zsh_fzf_arch }}.tar.gz"
zsh_antigen_fzf_path: "{{ zsh_antigen_path }}/repos/https-COLON--SLASH--SLASH-github.com-SLASH-junegunn-SLASH-fzf.git"
zsh_fzf_default_opts: "--height {{ zsh_fzf_height }}{% if zsh_fzf_reverse %} --reverse{% endif %}{% if zsh_fzf_border %} --border{% endif %}"

zsh_powerlevel9k_prompt_on_newline_bool: "{% if zsh_powerlevel9k_prompt_on_newline %}true{% else %}false{% endif %}"
zsh_powerlevel9k_always_show_context_bool: "{% if zsh_powerlevel9k_always_show_context %}true{% else %}false{% endif %}"
zsh_powerlevel9k_always_show_user_bool: "{% if zsh_powerlevel9k_always_show_user %}true{% else %}false{% endif %}"

0 comments on commit 5c61981

Please sign in to comment.