aboutsummaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2024-01-25 01:52:22 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2024-01-25 01:52:22 +0100
commitb6bcca60081fdd8b099781000b8016b5874e710f (patch)
tree0ed8cf8280df9661124677b5b399384c14413292 /zsh
parentc08097229eb142dd312da76b250428bf83949944 (diff)
Adjust startup logic
Diffstat (limited to 'zsh')
-rw-r--r--zsh/functions/status.zsh61
-rw-r--r--zsh/modules/aliases.zsh12
-rw-r--r--zsh/modules/prompt.zsh68
3 files changed, 62 insertions, 79 deletions
diff --git a/zsh/functions/status.zsh b/zsh/functions/status.zsh
new file mode 100644
index 0000000..690b2ea
--- /dev/null
+++ b/zsh/functions/status.zsh
@@ -0,0 +1,61 @@
+function tool_versions() {
+ if [[ -s ".tool-versions" ]]; then
+ echo '.tool-versions'
+ return
+ fi
+ echo "${HOME}/.tool-versions"
+}
+
+function env_info_provider() { echo "%{%F{green}%}n/a"; }
+function env_info {
+ echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]"
+}
+
+function python_info {
+ pythoninfo=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
+ pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo}
+ venv="${VIRTUAL_ENV##*/}"
+ echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
+}
+
+function rust_info {
+ rustinfo=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2`
+ rustinfo=${ASDF_RUST_VERSION:-$rustinfo}
+ echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-no}"
+}
+
+function node_info {
+ nodeinfo=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
+ nodeinfo=${ASDF_NODEJS_VERSION:-$nodeinfo}
+ echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
+}
+
+function git_info {
+ branch=$(git branch --show-current 2> /dev/null)
+
+ if [ ! -z $branch ]; then
+ echo -n "@%F{cyan}$branch%f"
+
+ status_output=$(git status --short)
+
+ if echo "$status_output" | rg -q '^??'; then
+ echo -n "%{%F{magenta}%}?%f"
+ fi
+
+ if echo "$status_output" | rg -q '^ M'; then
+ echo -n "%{%F{magenta}%}!%f"
+ fi
+
+ if echo "$status_output" | rg -q '^ D'; then
+ echo -n "%{%F{magenta}%}×%f"
+ fi
+
+ if echo "$status_output" | rg -q '^A '; then
+ echo -n "%{%F{green}%}+%f"
+ fi
+ fi
+}
+
+function status {
+ echo '%{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)'
+}
diff --git a/zsh/modules/aliases.zsh b/zsh/modules/aliases.zsh
index 2037e9e..0ff13f2 100644
--- a/zsh/modules/aliases.zsh
+++ b/zsh/modules/aliases.zsh
@@ -27,17 +27,5 @@ alias gl="git pull"
alias gm='git merge'
alias gp='git push'
-# Graphicsmagick override
-if command -v brew &> /dev/null; then
- alias grm="$(brew --prefix)/bin/gm"
-fi
-
# JS friendly tree
alias arbol="tree -I 'node_modules|bower_components|doc|__pycache__|\.pyc'"
-
-# Load Script Version Managers because they slow
-alias enable-nvm='source $(brew --prefix nvm)/nvm.sh'
-alias workon="echo 'DISABLED: run enable-virtualenvwrapper to enable'"
-alias enable-virtualenvwrapper="unalias workon; source /usr/local/bin/virtualenvwrapper.sh"
-alias enable-rvm="source $HOME/.rvm/scripts/rvm"
-alias t="things.sh"
diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh
index 18e5cc4..615ca95 100644
--- a/zsh/modules/prompt.zsh
+++ b/zsh/modules/prompt.zsh
@@ -1,76 +1,10 @@
autoload -Uz promptinit && promptinit
-function tool_versions() {
- if [[ -s ".tool-versions" ]]; then
- echo '.tool-versions'
- return
- fi
- echo "${HOME}/.tool-versions"
-}
-
if [[ "$TERM" == (dumb|linux|*bsd*) ]] || (( $#prompt_argv < 1 )); then
prompt 'off'
fi
#
-# Functions
-#
-
-function env_info_provider() { echo "%{%F{green}%}n/a"; }
-function env_info {
- echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]"
-}
-
-function python_info {
- pythoninfo=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
- pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo}
- venv="${VIRTUAL_ENV##*/}"
- echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
-}
-
-function rust_info {
- rustinfo=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2`
- rustinfo=${ASDF_RUST_VERSION:-$rustinfo}
- echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-no}"
-}
-
-function node_info {
- nodeinfo=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
- nodeinfo=${ASDF_NODEJS_VERSION:-$nodeinfo}
- echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
-}
-
-function git_info {
- branch=$(git branch --show-current 2> /dev/null)
-
- if [ ! -z $branch ]; then
- echo -n "@%F{cyan}$branch%f"
-
- status_output=$(git status --short)
-
- if echo "$status_output" | grep -q '^??'; then
- echo -n "%{%F{magenta}%}?%f"
- fi
-
- if echo "$status_output" | grep -q '^ M'; then
- echo -n "%{%F{magenta}%}!%f"
- fi
-
- if echo "$status_output" | grep -q '^ D'; then
- echo -n "%{%F{magenta}%}×%f"
- fi
-
- if echo "$status_output" | grep -q '^A '; then
- echo -n "%{%F{green}%}+%f"
- fi
- fi
-}
-
-function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
-}
-
-#
# ZLE widgets
#
@@ -113,7 +47,7 @@ function prompt_setup {
# Define prompts.
PROMPT='
%{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)
-%{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(box_name)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%}
+%{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(hostname -s)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%}
%(?,,%{${%B%F{white}%}[%?]%{%f%b%} )%% '
}