This prompt is a specialisation of repository called "Informative git prompt for zsh" for Kali Linux, which you can find here. Thanks to its author for the idea and implementation!
A zsh
prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
You can find all the repository state designations in the zsh-git-kali-prompt.zsh
file by copying the repository.
In order for git prompt for Linux to work, the following components must be installed on your local machine:
- Git.
- Python 3. In scripts, references to Python 3 appear as
python3
. If you havepython
installed, create a symbolic or hard-drive link with theln
command topython3
, or simply rename them in thezsh-git-kali-prompt.zsh
file. - For the git information prompt to work correctly, your Kali Linux must use the
zsh
UNIX command shell. - GCC (optional). If you are going to use the faster C script compiled to a binary file, you will need
gcc
for the compilation.
- Use the standard installation methods specific to your plugin under zsh.
-
Clone this repository to the $HOME directory or some other location (I'll do it in $HOME, and use that as the path in the future).
-
Source the file
zsh-git-kali-prompt.plugin.zsh
from your~/.zshrc
config file, and configure your prompt. So, somewhere (might be in the end of the file) in~/.zshrc
(recommended at the end of the file), you should have:# zsh git prompt setup. source $HOME/zsh-git-kali-prompt/zsh-git-kali-prompt.plugin.zsh
-
Restart the console, or write the
zsh
command to start a new session with the applied changes to the~/.zshrc
settings. -
Go in a git repository and test it! This only works if you are in a repository.
If you want to reduce delay when reloading the prompt shown in the terminal, you can switch from the python script that collects the git information from the current repository to a binary file coming from a C script. The ulity works the same, it just changes the way of executing the same instructions.
To do this follow the next steps:
- From the directory where you cloned the repo, compile the C script into a binary file with the next command:
gcc -O2 -o gitstatus gitstatus.c
- From the shell script
zsh-git-kali-prompt.zsh
replace the env variableGIT_PROMPT_EXECUTABLE
found in line 9 tobinary
. The line should look like this:
export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_EXECUTABLE:-"binary"}
- Restart the console so the changes are applied.
- Go in a git repository and test it! This only works if you are in a repository.
To remove the git command prompt, you need to remove the entire zsh-git-kali-prompt
directory (where all the prompt scripts are located), and lines in ~/.zshrc
that you added there during installation.
- You may redefine the function
git_super_status
(after thesource
statement) to adapt it to your needs (to change the order in which the information is displayed). - Define the variable
ZSH_THEME_GIT_PROMPT_CACHE
in order to enable caching. - You may also change a number of variables (which name start with
ZSH_THEME_GIT_PROMPT_
) to change the appearance of the prompt. Take a look in the filezsh-git-kali-prompt.zsh
to see how the functiongit_super_status
is defined, and what variables are available.