Skip to content

Commit

Permalink
✨ [ADD] gndx zsh theme
Browse files Browse the repository at this point in the history
  • Loading branch information
gndx committed Jun 8, 2021
1 parent 954bbd5 commit 5882e10
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# gndx-zsh-theme
An oh-my-zsh theme.

## Introducion
![gndx zsh theme](https://raw.githubusercontent.com/gndx/gndx-zsh-theme/master/screenshot.png)

## Installation
1. Write in your terminal `git clone https:/gndx/gndx-zsh-theme/ $ZSH_CUSTOM/themes/gndx-zsh-theme`
2. Open your `.zshrc`
3. Change your `ZSH_THEME` to *`gndx-zsh-theme/macos-theme`*

REF: [Oh-My-Zsh External themes](https:/ohmyzsh/ohmyzsh/wiki/External-themes)

### Extras
Add to the plugins zsh-autosuggestions and zsh-syntax-highlighting

### Contributing
If someone wants to add or improve something, I invite you to collaborate directly in this repository: [gndx-zsh-theme](https:/gndx/gndx-zsh-theme)

### Contributors

- Oscar Barajas : [https:/gndx](https:/gndx)

### License
gndx-zsh-theme is released under the [MIT License](https://opensource.org/licenses/MIT).
110 changes: 110 additions & 0 deletions gndx.zsh-theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
function real_time() {
local color="%{$fg_no_bold[cyan]%}";
local color2="%{$fg_no_bold[yellow]%}";
local time="[$(date +%H:%M)]";
local color_reset="%{$reset_color%}";
echo "${color}🧔🏻$(host_name)${color_reset} 🤖 ${color}${time}${color_reset}";
}

function host_name() {
local color="%{$fg_no_bold[cyan]%}"; # color in PROMPT need format in %{XXX%} which is not same with echo
local ip
if [[ "$OSTYPE" == "linux-gnu" ]]; then
ip="$(hostname)";
elif [[ "$OSTYPE" == "darwin"* ]]; then
ip="$(hostname)";
else
fi
local color_reset="%{$reset_color%}";
echo "${color}[%n@${ip}]${color_reset}";
}

function directory() {
local color="%{$fg_no_bold[white]%}";
local directory="${PWD/#$HOME/~}";
local color_reset="%{$reset_color%}";
echo "📁${color}${directory}${color_reset}";
}

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_no_bold[red]%}[%{$fg_no_bold[yellow]%}";
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} ";
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_no_bold[red]%}] 🔥";
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_no_bold[red]%}] 💚";

function update_git_status() {
GIT_STATUS=$(git_prompt_info);
}

function git_status() {
echo "${GIT_STATUS}"
}

function update_command_status() {
local arrow="";
local color_reset="%{$reset_color%}";
local reset_font="%{$fg_no_bold[white]%}";
if $1;
then
arrow="%{$fg_bold[yellow]%}❱%{$fg_bold[blue]%}❱%{$fg_bold[red]%}❱";
else
arrow="%{$fg_bold[red]%}❱❱❱";
fi
COMMAND_STATUS="${arrow}${reset_font}${color_reset}";
}

update_command_status true;

function command_status() {
echo "${COMMAND_STATUS}"
}

output_command_execute_after() {
if [ "$COMMAND_TIME_BEIGIN" = "-20200325" ] || [ "$COMMAND_TIME_BEIGIN" = "" ];
then
return 1;
fi

local cmd="${$(fc -l | tail -1)#* }";
local color_cmd="";
if $1;
then
color_cmd="$fg_no_bold[green]";
else
color_cmd="$fg_bold[red]";
fi
local color_reset="$reset_color";
cmd="${color_cmd}${cmd}${color_reset}"

local time="[$(date +%H:%M:%S)]"
local color_time="$fg_no_bold[cyan]";
time="${color_time}${time}${color_reset}";
}


precmd() {
local last_cmd_return_code=$?;
local last_cmd_result=true;
if [ "$last_cmd_return_code" = "0" ];
then
last_cmd_result=true;
else
last_cmd_result=false;
fi

update_git_status;

update_command_status $last_cmd_result;

output_command_execute_after $last_cmd_result;
}

setopt PROMPT_SUBST;

TMOUT=1;
TRAPALRM() {
if [ "$WIDGET" = "" ] || [ "$WIDGET" = "accept-line" ] ; then
zle reset-prompt;
fi
}

PROMPT='$(real_time) $(directory) $(git_status)$(command_status) ';
Binary file added screenshot.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 5882e10

Please sign in to comment.