I am going to share about a small customization that I did to my zshrc theme.
 |
Oh My ZSH homepage |
Introduction
What is zshrc? What is zsh? what is z shell? What is a shell?
Shell
In short, a shell is a command line interpreter that interprets the command you type on your terminal (on a Macbook)
A Unix shell is a command-line interpreter or shell that provides a traditional Unix-like command line user interface. Users direct the operation of the computer by entering commands as text for a command line interpreter to execute, or by creating text scripts of one or more such commands.
Taken from the above post:
In unix terminology, the short answer is that
terminal = tty = text input/output environment
console = physical terminal
shell = command line interpreter
Z Shell (zsh)
In short, Z Shell is a shell that focuses on interactive use.
Taken from
Z Shell homepage
Zsh is a shell designed for interactive use, although it is also a powerful scripting language. More information can be found on the "Zsh Web Pages" sites.
The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh is an extended Bourne shell with a large number of improvements, including some features of Bash, ksh, and tcsh.
ZSHRC
Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes
ZSHRC Installation
Prerequisites
Unix-like operating system (macOS or Linux)
Zsh should be installed (v4.3.9 or more recent). If not pre-installed (zsh --version to confirm), check the following instruction here: Installing ZSH
curl or wget should be installed
git should be installed
curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
wget
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
ZSHRC Theme Customization
Using a theme
For those themes that come with the repo, you just have to open up your ~/.zshrc file and change robbyrussell to the name of the theme that you like
ZSH_THEME="robbyrussell"
 |
zshrc set theme ZSH_THEME |
Customizing a theme
My terminal looks like this now with sushi as the prefix.
 |
Terminal with zshrc |
I got my idea by referring to mainly these 3 themes:
i)
emojiparty.zsh-theme
ii)
random-emoji.zsh-theme
iii)
oh-my-zsh-random-emoji.zsh-theme
This is what I added to my ~/.zshrc and changed my terminal profiles to get the above effect.
PROMPT="🍣 "
RPROMPT='%{$fg[yellow]%}%c$(git_prompt_info) %t'
ZSH_THEME_GIT_PROMPT_PREFIX=": "
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}*"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}"
 |
Terminal preferences - profiles |
Variables
PROMPT - define the prompt line from left hand side
RPROMPT - define the prompt line from right hand side
git_prompt_info - print git branch from git plugin
ZSH_THEME_GIT_PROMPT_PREFIX - define the prompt line before git_prompt_info
ZSH_THEME_GIT_PROMPT_SUFFIX - define the prompt line after git_prompt_info
ZSH_THEME_GIT_PROMPT_DIRTY - define the text colour of git prompt when there is uncommitted change
ZSH_THEME_GIT_PROMPT_CLEAN - define the text colour of git prompt
%{$fg[yellow]%} - set text colour
%t - print out time
Check out
zsh prompting document to learn about prompts
Function
You can also write call a function within your zshrc to further customize your shell.
EMOJI=(🐷 🐼 🐶)
function random_emoji {
echo -n "$EMOJI[$RANDOM % $#EMOJI+1]"
}
Thank you for reading!
Jun
Comments
Post a Comment