Skip to content

Commit

Permalink
axis7818.zsh-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
axis7818 committed Jan 26, 2025
1 parent f0f8d75 commit 2ec8e32
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"MD025": false,
"MD026": false,
"MD031": false,
"MD033": false
"MD033": false,
"MD034": false,
"MD051": false
}
76 changes: 76 additions & 0 deletions content/projects/axis7818.zsh-theme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
+++
title = "axis7818.zsh-theme"
description = "My custom ZSH theme"
weight = 1
template = "page.html"

[taxonomies]
tags = ["software"]

[extra]
local_image = "img/axis7818.zsh-theme.png"
add_src_to_code_block = true
+++

![axis7818.zsh-theme](/img/axis7818.zsh-theme.png)

I built this ZSH Theme from scratch. It took a while to strike a balance between useful information and spacious layout without taking up too much space in the terminal. This theme shows the current directory and git repo information. The prompt line is separate from that information to make it easier to use a narrower window without dealing with word wrap. It also shows failed exit codes and injects an extra newline between commands to visually

# axis7818.zsh-theme

{{ add_src_to_code_block(src="https://github.com/axis7818/dotfiles/blob/master/zsh/custom/themes/axis7818.zsh-theme") }}
```zsh
export VIRTUAL_ENV_DISABLE_PROMPT=1
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo `basename $VIRTUAL_ENV`' '
}

function git_info() {
check_git=$(command git rev-parse --is-inside-work-tree 2> /dev/null) || return 0
echo "$(git_prompt_info)$(git_prompt_status)$FG[default]"
}

local user_color='blue'; [ $UID -eq 0 ] && user_color='red'
local wd_color='green'
local date_time="%{$fg[default]%}%*%{$reset_color%} $FG[default]]"
local user="%{$fg_bold[$user_color]%}%n"
local post_wd="$reset_color$FG[default]"

local prompt_line="%{$fg_bold[magenta]%}%(!.#.❱)%{$reset_color%} "

local return_status="%{$fg_bold[red]%}%(?..%?
)%{$reset_color%}"

local pwd="%{$fg[$wd_color]%}%~"

# Set Prompt
PROMPT='${return_status}
$FG[default]${pwd}${post_wd} %{$fg_bold[yellow]%}$(virtualenv_info)$(git_info)
${prompt_line}'
PROMPT2="%{$fg[red]%}\ %{$reset_color%}"
RPROMPT=''

# Git Fields
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[yellow]%}∼%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[green]%}+%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[blue]%}✱%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[magenta]%}➦%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[yellow]%}✂%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}?%{$reset_color%}"
```

# Usage

I recommend using [ohmyzsh](https://github.com/ohmyzsh/ohmyzsh?tab=readme-ov-file#getting-started) to set up zsh on your machine.

After ohmyzsh is set up, create a file at `~/.oh-my-zsh/custom/themes/axis7818.zsh-theme`, and past the [axis7818.zsh-theme](#axis7818-zsh-theme) contents into it.

Finally, set your theme by updating your `.zshrc` file:

```zsh
ZSH_THEME="axis7818"
```
Binary file added static/img/axis7818.zsh-theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ec8e32

Please sign in to comment.