Last active
February 20, 2026 11:55
-
-
Save nakwa/09069ceba8d8ce59b2ced38d064c1563 to your computer and use it in GitHub Desktop.
.zshprofile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -------------------------------------------------------------------- | |
| # --------------------------------ZSHENV------------------------------ | |
| # -------------------------------------------------------------------- | |
| # ----------------------------------------------------- # | |
| # Profile # | |
| # ----------------------------------------------------- # | |
| [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" | |
| export ZSH="/Users/user/.zsh" | |
| export PATH=/opt/homebrew/bin:$PATH | |
| # -------------------------------------------------------------------- | |
| # ------------------------------ZSHRC--------------------------------- | |
| # -------------------------------------------------------------------- | |
| # ----------------------------------------------------- # | |
| # Theme # | |
| # ----------------------------------------------------- # | |
| ZSH_THEME=() | |
| # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
| # ----------------------------------------------------- # | |
| # Options # | |
| # ----------------------------------------------------- # | |
| unsetopt share_history | |
| setopt no_share_history | |
| CASE_SENSITIVE="true" | |
| # ENABLE_CORRECTION="true" | |
| # HYPHEN_INSENSITIVE="true" | |
| # DISABLE_AUTO_UPDATE="true" | |
| # DISABLE_UPDATE_PROMPT="true" | |
| # DISABLE_MAGIC_FUNCTIONS=true | |
| # DISABLE_LS_COLORS="true" | |
| # DISABLE_AUTO_TITLE="true" | |
| # COMPLETION_WAITING_DOTS="true" | |
| # DISABLE_UNTRACKED_FILES_DIRTY="true" | |
| # HIST_STAMPS="mm/dd/yyyy" | |
| # ZSH_CUSTOM=/path/to/new-custom-folder | |
| # export LANG=en_US.UTF-8 | |
| # export ARCHFLAGS="-arch x86_64" | |
| # export UPDATE_ZSH_DAYS=13 | |
| # ----------------------------------------------------- # | |
| # Plugins # | |
| # ----------------------------------------------------- # | |
| plugins=( | |
| macos | |
| git | |
| ) | |
| # git | |
| # bundler | |
| # dotenv | |
| # osx | |
| # rake | |
| # rbenv | |
| # ruby | |
| source $ZSH/oh-my-zsh.sh | |
| # ----------------------------------------------------- # | |
| # Dynamically set # | |
| # ----------------------------------------------------- # | |
| 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 | |
| export PATH="/opt/homebrew/sbin:$PATH" | |
| # -------------------------------------------------------------------- | |
| # -------------------------------PROFILE------------------------------ | |
| # -------------------------------------------------------------------- | |
| # Source order: | |
| # .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes]. | |
| # ----------------------------------------------------- # | |
| # INIT # | |
| # ----------------------------------------------------- # | |
| autoload -U add-zsh-hook | |
| ulimit -n 10240 | |
| # ----------------------------------------------------- # | |
| # PATH # | |
| # ----------------------------------------------------- # | |
| export PATH="$PATH:$HOME/.local/bin" | |
| export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH" | |
| # ----------------------------------------------------- # | |
| # Locales # | |
| # ----------------------------------------------------- # | |
| export LC_ALL=en_US.UTF-8 | |
| # ----------------------------------------------------- # | |
| # NVM # | |
| # ----------------------------------------------------- # | |
| export NVM_DIR="/Users/user/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | |
| load-nvmrc() { | |
| if test -f ".nvmrc"; then | |
| local node_version="$(nvm version)" | |
| local nvmrc_path="$(nvm_find_nvmrc)" | |
| if [ -n "$nvmrc_path" ]; then | |
| local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
| if [ "$nvmrc_node_version" = "N/A" ]; then | |
| nvm install | |
| elif [ "$nvmrc_node_version" != "$node_version" ]; then | |
| nvm use | |
| fi | |
| elif [ "$node_version" != "$(nvm version default)" ]; then | |
| echo "Reverting to nvm default version" | |
| nvm use default | |
| fi | |
| fi | |
| } | |
| # autoload -U add-zsh-hook | |
| add-zsh-hook chpwd load-nvmrc | |
| load-nvmrc | |
| # ----------------------------------------------------- # | |
| # Env # | |
| # ----------------------------------------------------- # | |
| export PHP_AUTOCONF="/usr/local/bin/autoconf" | |
| export GIT_PS1_SHOWDIRTYSTATE=1 | |
| export CLICOLOR=1 | |
| export LSCOLORS=GxFxCxDxBxegedabagaced | |
| export VISUAL=emacs | |
| export EDITOR="$VISUAL" | |
| export GUI_EDITOR="sublime" | |
| export EMAIL="user@mail.com" | |
| export GIT_COMMITTER_NAME="User Name" | |
| export GIT_AUTHOR_NAME="User Name" | |
| # ----------------------------------------------------- # | |
| # Prompt # | |
| # ----------------------------------------------------- # | |
| parse_git_branch() { | |
| branch="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')" | |
| if [ -n "$branch" ]; then | |
| echo "(%{$fg[red]%}$branch%{$reset_color%})" | |
| fi | |
| } | |
| PROMPT="%{$fg_bold[green]%}%n%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}\$(parse_git_branch)%(?:%{$fg[white]%}$%{$reset_color%}:%{$fg[grey]%}$%{$reset_color%}) " | |
| # ----------------------------------------------------- # | |
| # Core aliases # | |
| # ----------------------------------------------------- # | |
| alias gls='gls --color=auto --group-directories-first --time-style="+%Y-%m-%d %H:%M"' | |
| alias ll='gls -alFh' | |
| alias la='gls -alFh' | |
| alias l='gls -lFh' | |
| alias cd..='cd ..' | |
| alias emacs='emacs -nw' | |
| alias profile="$GUI_EDITOR ~/.profile" | |
| alias devenv="$GUI_EDITOR ~/.dev.env" | |
| alias edit="$GUI_EDITOR . -a" | |
| alias ide="$GUI_EDITOR -a ." | |
| alias reload=". ~/.profile && . ~/.dev.env && reset" | |
| alias desk="cd ~/Desktop" | |
| # ----------------------------------------------------- # | |
| # Functions # | |
| # ----------------------------------------------------- # | |
| encrypt() { | |
| openssl enc -aes-256-cbc -salt -in $1.txt -out $1.enc | |
| #openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc | |
| #-pass pass:mySillyPassword | |
| } | |
| decrypt() { | |
| openssl enc -d -aes-256-cbc -in $1.enc -out $1-dec.txt | |
| #openssl enc -d -aes-256-cbc -a -in file.enc -out file.txt | |
| #-pass pass:mySillyPassword | |
| } | |
| who_use_this_port(){ | |
| lsof -n -i4TCP:$1 | grep LISTEN | |
| } | |
| kill_process() { | |
| ps -ax -o pid= -o ucomm= | awk -v proc="$1" '$2 == proc {print $1}' | xargs -r kill -9 | |
| } | |
| find_pidof() { | |
| ps -ax -o pid= -o ucomm= | awk -v proc="$1" '$2 == proc {print $1}' | xargs | |
| } | |
| uncompress_archive() { | |
| tar -xvf $1 | |
| } | |
| clean_logs() { | |
| # echo | find . -name '*.log' -type f | |
| sudo find . -name '*.log' -type f -delete -print | |
| } | |
| clean_tree() { | |
| find . -name '.DS_Store*' -type f -delete -print | |
| find . -name '*~' -type f -delete -print | |
| find . -name '#*#' -type f -delete -print | |
| find . -name 'desktop.ini' -type f -delete -print | |
| find . -name 'Thumbs.db' -type f -delete -print | |
| } | |
| find_file() { | |
| find . -iname "*$1*" -type d -print | sed 's/^/"/;s/$/"/' | xargs -L1 stat -l -t '%FT %T' | |
| find . -iname "*$1*" -type f -print | sed 's/^/"/;s/$/"/' | xargs -L1 stat -l -t '%FT %T' | |
| } | |
| find_in_file() { | |
| grep -rnwl '.' -e "$1" 2>/dev/null | |
| } | |
| add_ssh_to_remote() { | |
| cat ~/.ssh/id_rsa.pub | ssh $@ "(echo 'no' | ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa || true); cat >> ~/.ssh/authorized_keys" | |
| } | |
| rm_force() { | |
| /bin/rm $@ || true | |
| } | |
| git_commit_all() { | |
| BRANCH="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')" | |
| COMMIT_MSG=${1:-"Autocommit - $(date) on $BRANCH"} | |
| git add --all | |
| git commit -m $COMMIT_MSG | |
| } | |
| git_diff_uncommited() { | |
| git diff HEAD -- "$1" "$1" | |
| } | |
| rename_files() { | |
| capture=$(echo $1) | |
| replace=$(echo $2) | |
| if [ -z "$capture" ] || [ -z "$replace" ]; then | |
| echo "Missing parameter: rename \$capture \$replace" | |
| else | |
| find . -type d -name "*$capture*" | while read file ; do | |
| newfile="$(echo ${file} |sed -e "s/$capture/$replace/")" ; | |
| if [ "$newfile" != "$file" ]; then | |
| echo "mv ${file}" "${newfile} " | |
| mv "${file}" "${newfile}" ; | |
| fi | |
| done | |
| find . -type f -name "*$capture*" | while read file ; do | |
| newfile="$(echo ${file} |sed -e "s/$capture/$replace/")" ; | |
| if [ "$newfile" != "$file" ]; then | |
| echo "mv ${file}" "${newfile} " | |
| mv "${file}" "${newfile}" ; | |
| fi | |
| done | |
| fi | |
| } | |
| if [ -f /usr/local/bin/trash ]; then alias rm="/usr/local/bin/trash"; fi | |
| alias searchall=find_in_file | |
| alias search=find_file | |
| alias whouses=who_use_this_port | |
| alias pkill=kill_process | |
| alias pidof=find_pidof | |
| alias clean=clean_tree | |
| alias cleanlogs=clean_logs | |
| alias untar=uncompress_archive | |
| alias enable-ssh=add_ssh_to_remote | |
| alias rmf=rm_force | |
| alias rename="rename_files" | |
| alias gdif=git_diff_uncommited | |
| alias gca=git_commit_all | |
| alias gpo="git push origin HEAD" | |
| # ----------------------------------------------------- # | |
| # Shortcuts # | |
| # ----------------------------------------------------- # | |
| # alias projects="cd ~/Projects/" | |
| # alias dev="sublime ~/Projects/dev.sublime-project" | |
| # ----------------------------------------------------- # | |
| # Python # | |
| # ----------------------------------------------------- # | |
| if command -v pyenv 1>/dev/null 2>&1; then | |
| eval "$(pyenv init -)" | |
| fi | |
| # ----------------------------------------------------- # | |
| # Clean up # | |
| # ----------------------------------------------------- # | |
| rm "$HOME/.rdbg_history" &> /dev/null | |
| rm "$HOME/.zsh_history" &> /dev/null | |
| rm "$HOME/.irb-history" &> /dev/null | |
| rm "$HOME/.lesshst" &> /dev/null | |
| rm "$HOME/.zcompdump" &> /dev/null | |
| export ZSH="/Users/user/.zsh" | |
| # ----------------------------------------------------- # | |
| # Dynamically set # | |
| # ----------------------------------------------------- # | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment