diff options
Diffstat (limited to 'zsh')
| -rw-r--r-- | zsh/.zprofile | 6 | ||||
| -rw-r--r-- | zsh/.zshrc | 70 | ||||
| -rw-r--r-- | zsh/config/aliases.zsh | 18 | ||||
| -rw-r--r-- | zsh/config/environment.zsh | 12 | ||||
| -rw-r--r-- | zsh/config/prompt.zsh | 42 | ||||
| -rw-r--r-- | zsh/oh-my-zsh/iTerm2-ssh.zsh | 28 |
6 files changed, 95 insertions, 81 deletions
diff --git a/zsh/.zprofile b/zsh/.zprofile deleted file mode 100644 index 95d30b4..0000000 --- a/zsh/.zprofile +++ /dev/null @@ -1,6 +0,0 @@ -eval "$(/opt/homebrew/bin/brew shellenv)" - -# Setting PATH for Python 3.9 -# The original version is saved in .zprofile.pysave -PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}" -export PATH @@ -1,54 +1,30 @@ -export ZSH="/Users/leonardo/.oh-my-zsh" +# Source environment +source $HOME/.config/zsh/environment.zsh -DEFAULT_USER="leonardo" +# Load plugins +plugins=(git zsh-autosuggestions zsh-syntax-highlighting) -autoload -Uz vcs_info - -directory() { - echo "%{$fg_bold[magenta]%}%~%{$reset_color%}" -} - -current_time() { - echo "%{$fg[white]%}[%*]" -} - -return_status() { - local LAST_EXIT_CODE=$? - if [[ $LAST_EXIT_CODE -ne 0 ]]; then - local EXIT_CODE_PROMPT=' ' - EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}" - echo "$EXIT_CODE_PROMPT " - fi -} +source $ZSH/oh-my-zsh.sh -precmd() { - vcs_info - VCS_STATUS="" - if [[ -n ${vcs_info_msg_0_} ]]; then - STATUS=$(command git status --porcelain 2> /dev/null | tail -n1) - if [[ -n $STATUS ]]; then - VCS_STATUS="(%F{yellow}${vcs_info_msg_0_}%f) " - else - VCS_STATUS="(%F{green}${vcs_info_msg_0_}%f) " - fi +# Source configurations +typeset -ga sources +sources+="$ZSH_CONFIG/environment.zsh" +sources+="$ZSH_CONFIG/prompt.zsh" +sources+="$ZSH_CONFIG/aliases.zsh" + +foreach file (`echo $sources`) + if [[ -a $file ]]; then + source $file fi - PROMPT='%B$(directory)%b %# ' - RPROMPT='$(return_status)${VCS_STATUS}$(current_time)' -} +end -zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:git*' formats "%b%u%c" -zstyle ':vcs_info:git*' actionformats "%b|%a%u%c" -zstyle ':vcs_info:*' unstagedstr ' *' -zstyle ':vcs_info:*' stagedstr ' +' +# =============================== +export NVM_DIR="$HOME/.nvm" +[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" +[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" -setopt prompt_subst - -plugins=(git zsh-autosuggestions) - -source $ZSH/oh-my-zsh.sh +export PYENV_ROOT="$HOME/.pyenv" +command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" -export PATH="/opt/homebrew/opt/python@3.10/bin:$PATH" -alias vim="nvim" -alias vi="nvim" -alias vimdiff="nvim -d" diff --git a/zsh/config/aliases.zsh b/zsh/config/aliases.zsh new file mode 100644 index 0000000..261161f --- /dev/null +++ b/zsh/config/aliases.zsh @@ -0,0 +1,18 @@ +# Neovim +alias vim="nvim" +alias vi="nvim" +alias vimdiff="nvim -d" + +# Python version +alias python="python3" + +# Ls to exa +alias ls="exa --icons" +alias ll="exa -lbhF --icons --git" +alias llm="exa -lbhd --icons --git --sort=modified" +alias la="exa -lbahF --icons --git" +alias lA="exa -lbhHigUmuSa --icons --time-style=long-iso --git --color-scale" +alias lx="exa -lbhHigUmuSa@ --icons --time-style=long-iso --git --color-scale" +alias lS="exa -1" +alias lt="exa --tree --level=2" + diff --git a/zsh/config/environment.zsh b/zsh/config/environment.zsh new file mode 100644 index 0000000..fdea1da --- /dev/null +++ b/zsh/config/environment.zsh @@ -0,0 +1,12 @@ +DEFAULT_USER="leonardo" + +ZSH_CONFIG=$HOME/.config/zsh + +# Oh-my-zsh +export ZSH="$HOME/.oh-my-zsh" + +# User /bin +export PATH="$HOME/bin:$PATH" + +# Exa colours +export EXA_COLORS="uu=37:un=37:gu=37:gn=37:da=37" diff --git a/zsh/config/prompt.zsh b/zsh/config/prompt.zsh new file mode 100644 index 0000000..1a9776b --- /dev/null +++ b/zsh/config/prompt.zsh @@ -0,0 +1,42 @@ +autoload -Uz vcs_info + +directory() { + echo "%{$fg_bold[magenta]%}%~%{$reset_color%}" +} + +current_time() { + echo "%{$fg[white]%}[%*]" +} + +return_status() { + local LAST_EXIT_CODE=$? + if [[ $LAST_EXIT_CODE -ne 0 ]]; then + local EXIT_CODE_PROMPT=' ' + EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}" + echo "$EXIT_CODE_PROMPT " + fi +} + +precmd() { + vcs_info + VCS_STATUS="" + if [[ -n ${vcs_info_msg_0_} ]]; then + STATUS=$(command git status --porcelain 2> /dev/null | tail -n1) + if [[ -n $STATUS ]]; then + VCS_STATUS="(%F{yellow}${vcs_info_msg_0_}%f) " + else + VCS_STATUS="(%F{green}${vcs_info_msg_0_}%f) " + fi + fi + PROMPT='%B$(directory)%b %# %f' + RPROMPT='$(return_status)${VCS_STATUS}$(current_time)%f' +} + +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:git*' formats "%b%u%c" +zstyle ':vcs_info:git*' actionformats "%b|%a%u%c" +zstyle ':vcs_info:*' unstagedstr ' *' +zstyle ':vcs_info:*' stagedstr ' +' + +setopt prompt_subst + diff --git a/zsh/oh-my-zsh/iTerm2-ssh.zsh b/zsh/oh-my-zsh/iTerm2-ssh.zsh deleted file mode 100644 index 6f19818..0000000 --- a/zsh/oh-my-zsh/iTerm2-ssh.zsh +++ /dev/null @@ -1,28 +0,0 @@ -function tabc() { - NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi - echo -e "\033]50;SetProfile=$NAME\a" -} - -function tab-reset() { - NAME="Default" - echo -e "\033]50;SetProfile=$NAME\a" -} - -function colorssh() { - if [[ -n "$ITERM_SESSION_ID" ]]; then - trap "tab-reset" INT EXIT - if [[ "$*" =~ "ceres" ]]; then - tabc "SSH - Ceres" - elif [[ "$*" =~ "ug04" || "$*" =~ "tw" ]]; then - tabc "SSH - SoCS" - else - tabc "SSH - Unknown" - fi -# tabc SSH - fi - ssh $* -} -compdef _ssh tabc=ssh - -alias ssh="colorssh" - |
