Verified Commit e02d2d17 authored by Leeward Bound's avatar Leeward Bound 💼

user-zsh is very wrong

parent ba4d1916
......@@ -4,6 +4,9 @@ antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search
antigen bundle zsh-users/zsh-autosuggestions
antigen theme skylerlee/zeta-zsh-theme
antigen theme $HOME/.zsh/netp-theme --loc=netp --no-local-clone
# antigen theme skylerlee/zeta-zsh-theme
antigen apply
......@@ -15,3 +15,9 @@ bindkey "^[[A" history-search-backward #up and down use search
bindkey "^[[B" history-search-forward #up and down use search
bindkey ' ' magic-space # also do history expansion on space
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
......@@ -9,6 +9,6 @@ git_prompt_info() {
setopt promptsubst
# Allow exported PS1 variable to override default prompt.
if ! env | grep -q '^PS1='; then
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}>%{$reset_color%} '
fi
#if ! env | grep -q '^PS1='; then
# PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}>%{$reset_color%} '
#fi
# Zeta theme for oh-my-zsh
# Tested on Linux, Unix and Windows under ANSI colors.
# Copyright: Skyler Lee, 2015
# Colors: black|red|blue|green|yellow|magenta|cyan|white
local black=$fg[black]
local red=$fg[red]
local blue=$fg[blue]
local green=$fg[green]
local yellow=$fg[yellow]
local magenta=$fg[magenta]
local cyan=$fg[cyan]
local white=$fg[white]
local black_bold=$fg_bold[black]
local red_bold=$fg_bold[red]
local blue_bold=$fg_bold[blue]
local green_bold=$fg_bold[green]
local yellow_bold=$fg_bold[yellow]
local magenta_bold=$fg_bold[magenta]
local cyan_bold=$fg_bold[cyan]
local white_bold=$fg_bold[white]
local highlight_bg=$bg[red]
local zeta='»'
# Machine name.
function get_box_name {
if [ -f ~/.box-name ]; then
cat ~/.box-name
else
echo $HOST
fi
}
# User name.
function get_usr_name {
local name="%n"
if [[ "$USER" == 'root' ]]; then
name="%{$highlight_bg%}%{$white_bold%}$name%{$reset_color%}"
fi
echo $name
}
# Directory info.
function get_current_dir {
local dir=$PWD
# Remove "Nextcloud/home" from prompt because we always symlink its children
dir=$(echo "${dir/Nextcloud\/home\//}")
# replace ~/p with cool purple @
local AT_PROJECTS="%{$magenta%}@%{$yellow_bold%}"
dir=$(echo "${dir/#$HOME\/p\//$AT_PROJECTS}")
# highlight and abbreviate net-prphet
local NETP="%{$blue%}netp%{$yellow_bold%}"
dir=$(echo "${dir/net-prophet/$NETP}")
echo "${dir/#$HOME/~}"
}
# Git info.
ZSH_THEME_GIT_PROMPT_PREFIX="%{$blue_bold%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$green_bold%} ✔ "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$red_bold%} ✘ "
# Git status.
ZSH_THEME_GIT_PROMPT_ADDED="%{$green_bold%}+"
ZSH_THEME_GIT_PROMPT_DELETED="%{$red_bold%}-"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$magenta_bold%}*"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$blue_bold%}>"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$cyan_bold%}="
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$yellow_bold%}?"
# Git sha.
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="[%{$yellow%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}]"
function get_git_prompt {
if [[ -n $(git rev-parse --is-inside-work-tree 2>/dev/null) ]]; then
local git_status="$(git_prompt_status)"
if [[ -n $git_status ]]; then
git_status="[$git_status%{$reset_color%}]"
fi
local git_prompt=" <$(git_prompt_info)$git_status>"
echo $git_prompt
fi
}
function get_time_stamp {
echo "%*"
}
function get_space {
local str=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local len=${#${(S%%)str//$~zero/}}
local size=$(( $COLUMNS - $len - 1 ))
local space=""
while [[ $size -gt 0 ]]; do
space="$space "
let size=$size-1
done
echo $space
}
# Prompt: # USER@MACHINE: DIRECTORY <BRANCH [STATUS]> --- (TIME_STAMP)
# > command
function print_prompt_head {
local left_prompt="\
%{$blue%}# \
%{$green_bold%}$(get_usr_name)\
%{$blue%}@\
%{$cyan_bold%}$(get_box_name): \
%{$yellow_bold%}$(get_current_dir)%{$reset_color%}\
$(get_git_prompt) "
local right_prompt="%{$blue%}($(get_time_stamp))%{$reset_color%} "
print -rP "$left_prompt$(get_space $left_prompt $right_prompt)$right_prompt"
}
function get_prompt_indicator {
if [[ $? -eq 0 ]]; then
echo "%{$magenta_bold%}$zeta %{$reset_color%}"
else
echo "%{$red_bold%}$zeta %{$reset_color%}"
fi
}
function kubectx_prompt {
local ctx=$(kubectx -c 2>/dev/null)
local ns=$(kubens -c 2>/dev/null)
if [[ ! -z "$ctx" ]]; then
echo "%{$reset_color%}[%{$white_bold%}$ctx%{$reset_color%}:%{$magenta%}$ns%{$reset_color%}]%{$reset_color%}"
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd print_prompt_head
setopt prompt_subst
PROMPT='$(get_prompt_indicator)'
RPROMPT='$(kubectx_prompt)'
\ No newline at end of file
......@@ -4,15 +4,6 @@ source ~/.zsh/antigen.zsh
export ANTIGEN_CACHE=~/.cache/antigen
antigen init ~/.zsh/.antigenrc
# TODO these need to be moved to the actual keybinds config file
bindkey -v
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
for function in ~/.zsh/functions/*; do
source $function
done
......@@ -58,7 +49,8 @@ _load_settings "$HOME/.zsh/config"
if [[ -f $HOME/.secrets/locked ]]; then
chmod +x $HOME/.secrets/locked;
pushd -q $HOME/.secrets
if $HOME/.secrets/locked ; then
if bash $HOME/.secrets/locked ; then
echo $yellow"[WARNING] ~/.secrets is locked, attempting to open it..."
python3 $HOME/.secrets/mount_secrets.py
fi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment