]> git.r.bdr.sh - rbdr/dotfiles/commitdiff
Merge branch 'main' of git.sr.ht:~rbdr/dotfiles
authorRuben Beltran del Rio <redacted>
Mon, 29 Jan 2024 16:41:49 +0000 (16:41 +0000)
committerRuben Beltran del Rio <redacted>
Mon, 29 Jan 2024 16:41:49 +0000 (16:41 +0000)
runcoms/zshrc
zsh/functions/status.zsh [new file with mode: 0644]
zsh/modules/aliases.zsh
zsh/modules/prompt.zsh

index 3b61e08f874b01982ec385e0f8e15940ecfd6266..07d4269777b51fc72acb4f349705ebe317222ec8 100644 (file)
@@ -6,6 +6,7 @@ source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/functions/graphviz.zsh"
 source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/functions/short-uptime.zsh"
 source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/functions/figlet-sample.zsh"
 source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/functions/prettify-json.zsh"
+source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/functions/status.zsh"
 
 ################################################################################
 # Load Modules
@@ -23,23 +24,17 @@ source "${ZDOTDIR:-$HOME}/.dotfiles/zsh/modules/aliases.zsh"
 # ENV VARIABLES
 ################################################################################
 # Terminal related
-export TERM=xterm-256color-italic
+export TERM=xterm-256color
 
 # Paths
 # export JAVA_HOME=$(/usr/libexec/java_home) # Enable if using JDK, otherwise disable for performance
 export XDG_CONFIG_HOME=$HOME/.config
-export GOPATH=$HOME/Projects/go
+export GOPATH=$HOME/projects/go
 export ANDROID_HOME=$HOME/Library/Android/sdk
 export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk-bundle
-export NVM_DIR=$HOME/.nvm
 export PATH=$PATH:$HOME:${GOPATH//://bin:}/bin
 export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_NDK_HOME:/Applications/calibre.app/Contents/MacOS
 
-# Python related variables
-export VIRTUAL_ENV_DISABLE_PROMPT=1
-export WORKON_HOME=$HOME/.virtualenvs
-export PROJECT_HOME=$HOME/Documents/projects
-
 # GPG
 export GPG_TTY=$(tty)
 
@@ -50,15 +45,6 @@ export GPG_TTY=$(tty)
 
 export FZF_DEFAULT_COMMAND='/usr/bin/env rg --color never --files --hidden -g \!.git'
 export FZF_DEFAULT_OPTS='--preview ''bat --style=numbers --color=always {} | head -500'''
-if [[ -s "/opt/homebrew/bin/brew" ]]; then
-  export FZF_VIM_PATH=/opt/homebrew/opt/fzf
-else
-  if [[ -s "/usr/local/bin/brew" ]]; then
-    export FZF_VIM_PATH=/usr/local/opt/fzf
-  else
-    export FZF_VIM_PATH=/usr/share/doc/fzf/examples
-  fi
-fi
 
 ################################################################################
 # SECRET ENV VARS!!
@@ -75,13 +61,20 @@ if [[ -s "${ZDOTDIR:-$HOME}/.zshrc.local" ]]; then
 fi
 
 if [[ -s "/opt/homebrew/bin/brew" ]]; then
+  # Brew Setup
   export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:$PATH
-fi
-
-# Z
-if [[ -s "/opt/homebrew/bin/brew" ]]; then
+  export FZF_VIM_PATH=/opt/homebrew/opt/fzf
   . /opt/homebrew/etc/profile.d/z.sh
+  . /opt/homebrew/opt/asdf/libexec/asdf.sh
 else
+  # FZF Vim (Linux)
+  if [[ -s "/usr/local/bin/brew" ]]; then
+    export FZF_VIM_PATH=/usr/local/opt/fzf
+  else
+    export FZF_VIM_PATH=/usr/share/doc/fzf/examples
+  fi
+
+  # Z (Linux)
   if [[ -s "/usr/libexec/z.sh" ]]; then
     . /usr/libexec/z.sh
   else
@@ -91,19 +84,16 @@ else
       . /usr/local/etc/profile.d/z.sh
     fi
   fi
-fi
 
-# ASDF
-if ! command -v brew &>  /dev/null; then
+  # ASDF (Linux)
   if [[ -s "/opt/asdf-vm/asdf.sh" ]]; then
     . /opt/asdf-vm/asdf.sh
   else
     . $HOME/.asdf/asdf.sh
   fi
-else
-  . $(brew --prefix asdf)/libexec/asdf.sh
 fi
 
+# ASDF Java
 if [[ -s "~/.asdf/plugins/java/set-java-home.zsh" ]]; then
   . ~/.asdf/plugins/java/set-java-home.zsh
 fi
diff --git a/zsh/functions/status.zsh b/zsh/functions/status.zsh
new file mode 100644 (file)
index 0000000..3da8977
--- /dev/null
@@ -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 {
+  print -P '%{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)'
+}
index 2037e9e9313cb6176960399b9bdb34c2d2058ad9..0ff13f2d873f5b76764caa7d9c65604d80a84047 100644 (file)
@@ -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"
index 18e5cc4c4de2583bc41156688b23dc221c3d4cb0..615ca95749ec84c5f7bc3742261a5ae9b6df9519 100644 (file)
@@ -1,75 +1,9 @@
 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%} )%% '
 }