feat: prompt setup improvements

This commit is contained in:
2025-05-19 23:10:26 +03:00
parent 11e2bc95a7
commit 755054c11e
4 changed files with 93 additions and 100 deletions

View File

@@ -1,11 +1,5 @@
# dotfiles
alias dots=$DOTFILES/install
# jump around
alias j="z"
# zip
alias tarz="tar -czvf"
# unzip
alias tarx="tar -xzvf"
alias taru="tarx"
alias bench='ZSH_BENCH=1 exec zsh'
alias dots='$DOTFILES/install'
alias j='z'
alias reload='source ~/.zshrc'
alias zen='curl -s https://api.github.com/zen && echo'

View File

@@ -1,100 +1,49 @@
# U _____ u _ _ __ __
# \| ___"|/| \ |"| \ \ /"/u
# | _|" <| \| |> \ \ / //
# | |___ U| |\ |u /\ V /_,-.
# |_____| |_| \_| U \_/-(_/
# << >> || \\,-.//
# (__) (__)(_") (_/(__)
#
# xdg data & config
# -----------------------------------------------------------------
export XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME/.local/share"}
mkdir -p "$XDG_DATA_HOME"
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}
mkdir -p "$XDG_CONFIG_HOME"
# local user binaries
local_bin_path="$HOME/.local/bin"
if [[ ":$PATH:" != *":$local_bin_path:"* ]]; then
export PATH="$local_bin_path:$PATH"
# -----------------------------------------------------------------
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
mkdir -p ~/.local/bin
unset local_bin_path
# homebrew
brew_path="/opt/homebrew/bin/brew"
if [ -x "$brew_path" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
unset brew_path
mkdir -p $HOME/.local/bin
# workspace
# -----------------------------------------------------------------
export WORKSPACE=${WORKSPACE:-"$HOME/Workspace"}
mkdir -p "$WORKSPACE"
# dotfiles
# -----------------------------------------------------------------
export DOTFILES=${DOTFILES:-"$HOME/.dotfiles"}
# nvm
# -----------------------------------------------------------------
if [ -z "$NVM_DIR" ]; then
export NVM_DIR=${NVM_DIR:-"$HOME/.nvm"}
mkdir -p "$NVM_DIR"
fi
[ -f "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
# node (default v20 "iron" LTS version)
node_alias="$NVM_DIR/alias/lts/iron"
if [ -f "$node_alias" ]; then
VERSION=`cat $node_alias`
if [ -x `command -v nvm` ]; then
nvm install "$VERSION" > /dev/null 2>&1 & disown
fi
node_bin_path="$NVM_DIR/versions/node/$VERSION/bin"
if [[ ":$PATH:" != *":$node_bin_path:"* ]]; then
export PATH="$node_bin_path:$PATH"
fi
fi
unset node_alias node_bin_path VERSION
# pyenv
# -----------------------------------------------------------------
export PYENV_ROOT=${PYENV_ROOT:-"$HOME/.pyenv"}
pyenv_bin_path="$PYENV_ROOT/bin"
if [[ ":$PATH:" != *":$pyenv_bin_path:"* ]]; then
export PATH="$pyenv_bin_path:$PATH"
if [[ ":$PATH:" != *":$PYENV_ROOT/bin:"* ]]; then
export PATH="$PYENV_ROOT/bin:$PATH"
fi
if [ -x `command -v pyenv` ]; then
eval "$(pyenv init --path)"
fi
unset pyenv_bin_path
# poetry
# -----------------------------------------------------------------
export POETRY_ROOT=${POETRY_ROOT:-"$HOME/.poetry"}
poetry_bin_path="$POETRY_ROOT/bin"
if [[ ":$PATH:" != *":$poetry_bin_path:"* ]]; then
export PATH="$poetry_bin_path:$PATH"
fi
unset poetry_bin_path
# z (jump around)
export Z_DATA_DIR=${Z_DATA:-"$XDG_DATA_HOME/z"}
export Z_DATA=${Z_DATA:-"$Z_DATA_DIR/data"}
export Z_OWNER=${Z_OWNER:-$USER}
# nix
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
. $HOME/.nix-profile/etc/profile.d/nix.sh
if [[ ":$PATH:" != *":$POETRY_ROOT/bin:"* ]]; then
export PATH="$POETRY_ROOT/bin:$PATH"
fi
# _ _ _ ____
# U /"\ u |"| ___ U /"\ u / __"| u
# \/ _ \/ U | | u |_"_| \/ _ \/ <\___ \/
# / ___ \ \| |/__ | | / ___ \ u___) |
# /_/ \_\ |_____| U/| |\u /_/ \_\ |____/>>
# \\ >> // \\.-,_|___|_,-.\\ >> )( (__)
# (__) (__)(_")("_)\_)-' '-(_/(__) (__)(__)
#
# aliases
# -----------------------------------------------------------------
if [ -f ~/.aliases ]; then
source ~/.aliases
fi

View File

@@ -1,15 +1,66 @@
source $HOME/.profile
# Prefix all functions with "_dots" for easier profiling
# -----------------------------------------------------------------------------
if [[ -n "$ZSH_BENCH" ]]; then
zmodload zsh/zprof
fi
export DISABLE_AUTO_UPDATE="true"
export ZSH="$HOME/.oh-my-zsh"
# Load profile
# -----------------------------------------------------------------------------
_dots_load_profile() {
source $HOME/.profile
}
_dots_load_profile
# https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
plugins=(
# Load oh-my-zsh
# -----------------------------------------------------------------------------
_dots_load_omz() {
export DISABLE_AUTO_UPDATE="true"
export ZSH="$HOME/.oh-my-zsh"
plugins=(
z
zsh-autosuggestions
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
)
source $ZSH/oh-my-zsh.sh
}
_dots_load_omz
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Load nvm
# -----------------------------------------------------------------------------
_dots_load_nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
}
_dots_load_nvm
# -----------------------------------------------------------------------------
_dots_load_brew() {
export HOMEBREW_NO_ANALYTICS=1
[ -x "/opt/homebrew/bin/brew" ] && eval "$(/opt/homebrew/bin/brew shellenv)"
}
_dots_load_brew
# -----------------------------------------------------------------------------
_dots_load_pyenv() {
[ -x `command -v pyenv` ] && eval "$(pyenv init --path)"
}
_dots_load_pyenv
# -----------------------------------------------------------------------------
_dots_build_prompt() {
local final_prompt=""
local dir_section="%{$fg_bold[blue]%}%~"
final_prompt+="$dir_section "
local prompt_char="%{$reset_color%}%%"
final_prompt+="$prompt_char "
PROMPT="$final_prompt"
}
_dots_build_prompt
# -----------------------------------------------------------------------------
if [[ -n "$ZSH_BENCH" ]]; then
zprof
fi

View File

@@ -22,23 +22,22 @@ if [ ! -d "$ZSH" ]; then
# https://github.com/ohmyzsh/ohmyzsh#unattended-install
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
export ZSH_CUSTOM="$ZSH/custom"
# install zsh-syntax-highlighting
export ZSH_SYNTAX_HIGHLIGHTING="$ZSH/custom/plugins/zsh-syntax-highlighting"
export ZSH_SYNTAX_HIGHLIGHTING="$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
if [ ! -d "$ZSH_SYNTAX_HIGHLIGHTING" ]; then
git clone -q https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_SYNTAX_HIGHLIGHTING
git clone -q \
https://github.com/zsh-users/zsh-syntax-highlighting.git \
$ZSH_SYNTAX_HIGHLIGHTING
fi
# install zsh-autosuggestions
export ZSH_AUTOSUGGESTIONS="$ZSH/custom/plugins/zsh-autosuggestions"
export ZSH_AUTOSUGGESTIONS="$ZSH_CUSTOM/plugins/zsh-autosuggestions"
if [ ! -d "$ZSH_AUTOSUGGESTIONS" ]; then
git clone -q https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_AUTOSUGGESTIONS
fi
# install powerlevel10k
export POWERLEVEL10K="$ZSH/custom/themes/powerlevel10k"
if [ ! -d "$POWERLEVEL10K" ]; then
git clone -q --depth=1 https://github.com/romkatv/powerlevel10k.git $POWERLEVEL10K
git clone -q \
https://github.com/zsh-users/zsh-autosuggestions.git \
$ZSH_AUTOSUGGESTIONS
fi
# change default shell to zsh