Compare commits

...

10 Commits

9 changed files with 112 additions and 6 deletions

View File

@ -5,4 +5,5 @@
* Provides a unique syntax for running ssh sessions. You can simply type `command@target-host --args` to run a one shot command on target-host (or `@target-host` to open a full ssh session)
* Customizes the prompt according to developer's personal preferences (framework for customization coming soon!)
* Automatically updates itself, and is capable of installing itself with just a stub zshrc
* Support for some developer environment tools, such as OPAM and conda
* And more, as needed!

View File

@ -4,4 +4,4 @@ function precmd_tab_directory () {
print -Pn "\e]0;%n@%m: %~\a"
}
precmd_functions+="precmd_tab_directory"
precmd_functions+="precmd_tab_directory"

24
base/prompt.zsh Normal file
View File

@ -0,0 +1,24 @@
typeset -ag prompt_functions
typeset -ag rprompt_functions
function prompt_builder () {
result=""
for prompt_func in $prompt_functions; do
result="${result}$($prompt_func)%{$reset_color%} "
done
# prompt will always end with "% " (or "# " if we're somehow root)
result="${result}%#%{$reset_color%} "
print "${result}"
}
function rprompt_builder () {
result=""
for rprompt_func in $rprompt_functions; do
result="$($rprompt_func)%{$reset_color%} ${result}"
done
result="${result}%{$reset_color%}"
print "${result}"
}
PROMPT='$(prompt_builder)'
RPROMPT='$(rprompt_builder)'

View File

@ -1,4 +1,7 @@
cols=$(stty -a | grep -Po '(?<=columns )\d+' | tr -d "\n")
#cols=$(stty -a | grep -Po '(?<=columns )\d+' | tr -d "\n")
cols=$COLUMNS
setopt prompt_subst
function ticker_message () {
if [[ $_zeeshdev_ticker_newlines == 0 ]]; then

19
modules/base_prompt.zsh Normal file
View File

@ -0,0 +1,19 @@
# PROMPT="%{$fg_bold[cyan]%}%n%{$fg_bold[white]%}@%{$fg_bold[magenta]%}%m %{$fg_bold[white]%}%~ %# %{$reset_color%}"
# RPROMPT="%(?..%{$fg[red]%}%? )$RPROMPT"
function prompt_userathost () {
print "%{$fg_bold[cyan]%}%n%{$fg_bold[white]%}@%{$fg_bold[magenta]%}%m %{$fg_bold[white]%}%~"
}
prompt_functions+=prompt_userathost
function rprompt_clock () {
print "%{$fg_bold[black]%}%T"
}
function rprompt_retval () {
print "%(?..%{$fg[red]%}%?)"
}
rprompt_functions+=rprompt_clock
rprompt_functions+=rprompt_retval

17
modules/conda.zsh Normal file
View File

@ -0,0 +1,17 @@
# Note: location of conda can be unpredictable; user is expected to
# run `conda init zsh` as normal then move resulting .zshrc
# modifications to .zshrc.preload
# recommended settings for .condarc:
# auto_assign_base: false
# changeps1: false
function conda_prompt() {
if [[ -v CONDA_DEFAULT_ENV && "$CONDA_DEFAULT_ENV" != "base" ]]; then
print "%{$fg[cyan]%}$CONDA_DEFAULT_ENV"
fi
}
if (( ${+commands[conda]} )); then
rprompt_functions+=conda_prompt
fi

36
modules/git.zsh Normal file
View File

@ -0,0 +1,36 @@
(( $+commands[git] )) || return
if (( $+commands[git-lfs] )); then
# ensures git-lfs is functional if installed
git config --get filter.lfs.process &> /dev/null || git lfs install
fi
function git_prompt() {
git rev-parse --is-inside-work-tree &> /dev/null
__git_prompt__is_git_dir=$?
if [[ $__git_prompt__is_git_dir -eq 0 ]]; then
commithash=$(git log --pretty=format:"%h" -n 1)
fullbranchname=$(git name-rev --name-only ${commithash})
branchtype=$(echo ${fullbranchname} | cut -d"/" -f1)
if [[ "${branchtype}" == "refs" ]]; then
branchname=$(echo ${fullbranchname} | cut -d"/" -f3)
elif [[ "${branchtype}" == "remotes" ]]; then
branchname=$(echo ${fullbranchname} | cut -d"/" -f2-)
elif [[ "${branchtype}" == "tags" ]]; then
branchname=$(echo ${fullbranchname} | cut -d"/" -f2)
elif [[ "${branchtype}" == "${fullbranchname}" ]]; then
# git did it for us
branchname=${fullbranchname}
else
branchname=${fullbranchname}
# output a warning to stderr, convenience for maintenance
echo "warning: unrecognized branch type ${branchtype}" >&2
fi
print "%{$fg_bold[yellow]%}${branchname} %{$reset_color%}%{$fg[yellow]%}${commithash}"
fi
}
rprompt_functions+=git_prompt

View File

@ -10,9 +10,9 @@ if [[ $cols -lt 80 ]]; then
hostemoji="🖥"
fi
PROMPT="👤%{$fg_bold[white]%}@${hostemoji} %~ %# %{$reset_color%}"
else
PROMPT="%{$fg_bold[cyan]%}%n%{$fg_bold[white]%}@%{$fg_bold[magenta]%}%m %{$fg_bold[white]%}%~ %# %{$reset_color%}"
RPROMPT="%(?..%{$fg[red]%}%? )$RPROMPT"
#else
# PROMPT="%{$fg_bold[cyan]%}%n%{$fg_bold[white]%}@%{$fg_bold[magenta]%}%m %{$fg_bold[white]%}%~ %# %{$reset_color%}"
# RPROMPT="%(?..%{$fg[red]%}%? )$RPROMPT"
fi
TMOUT=60
TRAPALRM () {
@ -20,6 +20,7 @@ TRAPALRM () {
}
source ~/.local/share/zeesh/base/precmd.zsh
source ~/.local/share/zeesh/base/prompt.zsh
source ~/.local/share/zeesh/base/updates.zsh
# TODO: handle whether or not to load given modules]

View File

@ -1,9 +1,12 @@
# vim: ft=zsh :
# Hint: If you're looking to add things to zshrc, make a new file called .zshrc.local and
# put your changes there to avoid it getting clobbered by zeesh updates.
autoload -U colors && colors
PROMPT="%{$fg[cyan]%}%n%{$fg[white]%}@%{$fg[magenta]%}%m %{$fg[white]%}%~ %# "
RPROMPT="%{$fg_bold[black]%}%T%{$reset_color%}"
RPROMPT=""
_zeesh_fresh_install=0
@ -23,4 +26,6 @@ fpath=(
~/.local/share/zeesh/plugins
"${fpath[@]}"
)
[[ -f ~/.zshrc.preload ]] && source ~/.zshrc.preload
source ~/.local/share/zeesh/zeesh.zsh
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local