Skip to content

Latest commit

 

History

History
executable file
·
491 lines (321 loc) · 19.6 KB

README.md

File metadata and controls

executable file
·
491 lines (321 loc) · 19.6 KB

A powerful theme for ZSH

Tests Python Versions Updates Python Whell PyPI PyPI - Implementation Isort Mypy Code style: Black PyPI - Downloads GitHub license


Built with ❤︎ by: William Canin in free time, to the sound of the playlist: Bursting Of The Tympanum


ZSHPower is a theme for ZSH; especially for the developer of various programming languages and users Linux and macOS. Pleasant to look at, the ZSHPower comforts you with its vibrant colors and icons.

Installing ZSHPower is the easiest thing you will see in any existing theme for ZSH, because there is a manager.

The changes in the theme become more dynamic through a configuration file, where the user can make various combinations for the style of ZSHPower.

The ZSHPower supports installation along with Oh My ZSH, where changes to: enable and disable an Oh My ZSH theme are easier, all in a simplified command line, without opening any files or creating symbolic links.

In addition, the ZSHPower manager downloads Oh My Zsh and the zsh-autosuggestions and zsh-syntax-highlighting plugins automatically, everything to make your ZSH very power.

Note: While this project is in beta, it will present some difficulties in terms of performance. Currently a prototype.


Here is an example of the installed ZSHPower:

ZSHPower in Terminator

Contributions

Features

  • Oh My Zsh installation automatically;*

  • Automatically install zsh-autosuggestions and zsh-syntax-highlighting;*

  • Automated installation and uninstallation;

  • Enable and disable ZSHPower anytime;*

  • Open configuration file in the terminal itself;

  • Reset the settings with one command only;

  • Personalized directory with truncate option;

  • Current Git branch and rich repo status;

    • untracked changes;
    • new files added;
    • deleted files;
    • new modified files;
    • commits made;
    • and more.
  • Application versions shown with icons, they are:

    .NET, C, C++, CMake, Crystal, Dart, Deno, Docker, Elixir, Ember, Erlang, Go, Gulp, Helm, Java, Julia, Kotlin,

    Lua, Nim, NodeJS (Javascript), OCaml, Perl, Php, Python, Ruby, Rust, Scala, V, Vagrant, Zig

  • Package versions such as Crystal, Helm, NodeJS, Python, Rust shown;

  • Shows the time in the upper right corner;

  • and, many other dynamic settings in $HOME/.zshpower/config/zshpower.toml.

*features if used with Oh My ZSH.

Requirements

To work correctly, you will first need:

  • Git (v2.25 or recent) must be installed;
  • Zsh (v5.2 or recent) must be installed;
  • Python (v3.9 or recent);
  • Sqlite3 (v3.35 or recent);
  • Pip (v21.0.1 or recent) must be installed;
  • Some Nerd Font font installed;
  • One of that editor vim, nano or emacs must be installed;

Pre install

1 - Install the required packages in your distribution:

Arch Linux and derivatives

sudo pacman -S zsh vim curl git sqlite python python-pip

Debian and derivatives

sudo apt update
sudo apt install zsh vim curl git sqlite3 python3 python3-pip python3-venv

Fedora and derivatives

sudo dnf update
sudo dnf install zsh vim curl git sqlite python3 python3-pip util-linux-user

2 - Adding user's bin path to PATH:

Linux:

export PATH=$PATH:$HOME/.local/bin

macOS:

py_version=$(python3 -c 'import sys; sys.stdout.write(f"{sys.version_info[0]}.{sys.version_info[1]}")')
export PATH=$PATH:$HOME/Library/Python/${py_version}/bin

2.1 - Switch from Bash to Zsh and export PATH's (Optional):

sudo chsh -s /usr/bin/zsh $(whoami)
exec zsh
export PATH="$PATH:$HOME/.local/bin"

Note: By default, ZSHPower already performs this step at configuration time.

Installing

1 - It's time to install ZSHPower manager. To do this, do:

NOTE: Global installation is not recommended. The easiest and most convenient way to use ZSHPower is to install for each different user on the machine, including for the super user (root)

$ python3 -m pip install zshpower --user -U

NOTE: If you are installing to the user's local environment, be sure to add the environment variables to the zshrc file.

2 - After installing ZSHPower, you need to generate the configuration files, how you will use ZSHPower. You basically have two ways to use ZSHPower. The first is to use independently, and the second is to use with Oh My ZSH.

To use independently, without any framework, do:

$ zshpower init

NOTE: This option you will have to add the following code to the .zshrc file.

eval $(zshpower init --path)

If you want to use it with Oh My ZSH and, to make ZSHPower more powerfull, do:

$ zshpower init --omz

Post-Install

The ZSHPower project uses the "Nerd Font". You must install any of these fonts to terminally recognize the symbols.

However, by default, ZSHPower already downloads the font DejaVuSansMono Nerd Font in the folder ($HOME/.fonts) of user fonts using Linux system.

Editors, IDE and Terminal

After install ZSHPower and the DejaVuSansMono Nerd Font, you must configure your text editor and terminal to recognize the icons used by the ZSHPower.

Visual Studio Code:

Add the font family in Visual Studio Code, opening the global settings for Visual Studio Code and add this information:

{
	"terminal.integrated.fontFamily": "'<Your main source>', 'DejaVuSansMono Nerd Font'"
}

Atom:

For the Atom editor, there are no secrets either. In the family font settings, do:

editor:
    fontFamily: "Menlo, Consolas, DejaVu Sans Mono, monospace, DejaVuSansMono Nerd Font"

PyCharm:

For PyCharm, you must make the following font settings:

File > Settings > Editor > Color Schema > Console Font > Font: DejaVuSansMono Nerd Font

Terminator:

If you use Terminator as the default terminal, change its font to the DejaVuSansMono Nerd Font Book font.

For other terminals, do the same, changing the font to DejaVuSansMono Nerd Font Book.

NOTE: You can install any font from "Nerd Font". They are compatible with the ZSHPower.

Theme configuration

About

ZSHPower allows you to open its settings in the terminal itself using vim, nano or emacs. After exiting the editor, ZSHPower will reload the settings in case there are any changes, it will take effect.

$ zshpower config --open

In the keys containing the call "color", you must enter a color that is in accordance with Ansi Escape Color . By default, the supported values are:

black|white|blue|red|cyan|magenta|green|yellow

The "enable" keys must receive Boolean values supported by TOML. The values for these keys are true or false (In lower case).

The symbol keys, receive icons or their values in Unicode. By default, the icons will only be shown via localhost, if the connection is via SSH, the icons will be disabled.

Configuration file

The configuration file is found in $HOME/.zshpower/config/zshpower.toml.

By default, most settings are set to false.

The ZSHPower configuration file is very intuitive, and just a glance gives you an idea of what each option does. But even so, note some of the main keys:

  • color.enable - If true, enable the colors, otherwise false enters negative mode. Default: true

  • jump_line.enable - If this option is true, you will skip a line each time you execute a command. Default: true

  • separator.element - Add separators to each information shown by ZSHPower. Default: -

  • config.editor - Choose of terminal editor that will open the configuration file. Default: vim

  • separator.color - Changes the color of the separator. Default: negative

  • position - This option changes the position of certain sections. To show the information for a given tool, it must be listed in position.

  • enable - If it is "true", it will activate the functionality where the "enable" key is.

  • symbol - Must receive an icon, whether in unicode or not.

  • lock.symbol - It will appear when there is a directory without certain permissions.

  • color - Change the color of a particular block. Supported colors are: black|white|blue|red|cyan|magenta|green|yellow

  • color.symbol - Option to change the color of the informed symbol.

  • prefix.color - Changes the prefix color before the object shown.

  • prefix.text - Before showing the object, show a prefix. You can put any text you like.

  • truncation_length - This option receives an integer from 0 to 4. You will be responsible for truncating the path levels of the directory. Default: 1 (Note: Value 0 (zero), show all path.)

  • branch.color - Option to change the color of the informed branch.

  • symbols.enable - Receives true or false. If true, shows the git status icons through each defined value. Remember that these icons will not be shown if you are via SSH. Default: true

  • new_line.enable - Receive true or false. If true, skip a line in the command entry. Default: true

  • error.symbol - Shows a symbol if the command output is false. Default: \uf553

  • error.color - Error exit symbol color. Default: red

  • display - A list of programming languages that support packaging. If you don't want the version of a package for a specific programming language to appear, just remove it from this list. Default: ["python", "node", "rust", "scala", "crystal", "helm"]

  • version.enable - If true, show version information for a particular tool. Default: false

  • version.micro.enable - If true, show the micro version information of a given tool. Note: The version.enable key must be true. Default: true

  • involved - Element that will enclose the name of an object. By default you should be given two unique elements. Default: []

  • normal.enable - If the option is true, it will show the real name of the virtual machine. If the option is false, the user has the possibility to enter text. Default: true

  • py.enable - Shows the version of python on behalf of the virtual machine. Default: true

  • hash.enable - Displays the hash of the virtual machine name if it was created using Poetry. Default: true

  • seconds.enable - Receive true or false. If it has true, show the seconds of the clock. Default: false

  • show_greater_than - It will only be shown if the return time of the command if it is greater than the value of this option. Default: 1 > NOTE: It must be a value in seconds.

Synchronize

ZSHPower stores some information in a database (SQLite 3) to obtain better performance and speed in the display of data. This data is currently the versions of the applications that ZSHPower shows on the console. Before, ZSHPower showed this information in real time, but it compromised performance and display time.

With that, every time you update the program you work on (or even the entire system), you need to synchronize. To synchronize you have two options, the first is manual and the other automatically using a task scheduler, such as Cronie.

Sync manually:

$ zshpower sync

If you always want manual synchronization, it would be interesting whenever you update the system or a particular package that ZSHPower supports, add the synchronization command as well. For example:

# Debian and derivatives
$ sudo apt upgrade && zshpower sync
# Arch Linux and derivatives
$ sudo pacman -Syu && zshpower sync
# Fedora and derivatives
$ sudo dnf update && zshpower sync

Automatically sync:

IMPORTANT: Only if you have root permission.

ZSHPower has an option to create the task for database synchronization. This option is via the command:

zshpower cron --create

With this command, a ZSHPower task will be created in Cron, however you need to have Cron installed and have superuser (root) permission to perform the task creation, otherwise, nothing will happen.

By default, the task is created with comment, and you will have to set the values. For this, ZSHPower provides a command to open the Cron task file, with the command:

zshpower cron --open

As stated before, you can use a task scheduler. Just access Cron to schedule a task at any time and call this script. You can use the Crontab Guru website to make it easier to understand Cron.

You can get more information about Cron through sample sites like these:

or use the Crontab main:

$ man crontab

An example using the Cronie scheduling synchronization every 2 hours:

Create or changing a file (with superuser)/etc/cron.d/zshpower and put the following line

# ZSHPower Task - BEGIN
SHELL=/bin/zsh
PATH=/home/<USER>/.local/bin:/bin:/usr/local/bin:$PATH
export PATH
# Every 2 hours
0 */2 * * * <USER> zshpower sync
# ZSHPower Task - END

In put the logged in user on the machine.

Upgrading

If ZSHPower has any new features, please update the command line below:

$ python3 -m pip install zshpower --user -U
$ zshpower init [--omz]

Reset settings

If you made any changes to the configuration file and regretted it, you can reset everything with the command below:

$ zshpower reset --config

You can also reset the ZSHPower database if it is corrupted with the command below:

$ zshpower reset --db

Deactivate and Activate theme for Oh My ZSH

You can activate and deactivate ZSHPower at any time, without opening any files, if using with Oh My ZH. To do this, follow the steps below:

  • Deactivate
$ zshpower deactivate

When deactivate, the manager will return to the default Oh My Zsh theme, the robbyrussell. If you want to deactivate with another theme already installed, use the --theme option. Example:

$ zshpower deactivate --theme=agnoster
  • Activate
$ zshpower activate

Uninstalling

We will be sad if you want to stop using ZSHPower, but for an easier and more effective uninstall, we also have the command:

$ zshpower uninstall

NOTE: If you installed "ZSHPower" with 'sudo', use 'sudo' to uninstall as well.

$ sudo zshpower uninstall

More Commands

For more command information, use:

$ zshpower --help

Donation

Click on the image below to be redirected the donation forms:

License

The project is available as open source under the terms of the MIT License ©

Credits

See, AUTHORS.