Last active
November 11, 2025 08:50
-
-
Save carlosvillademor/946ace44d83b6a05068d4a62245fc73f to your computer and use it in GitHub Desktop.
ZSH config
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
| # Uses oh-my-zsh, see https://ohmyz.sh/ | |
| # | |
| # Sections: | |
| # 1. Environment Configuration | |
| # 2. Make Terminal Better (remapping defaults and adding functionality) | |
| # 3. File and Folder Management | |
| # 4. Searching | |
| # 5. Process Management | |
| # 6. Networking | |
| # 7. System Operations & Information | |
| # 8. Web Development | |
| # 9. Git | |
| # 11. MailOnline | |
| # 12. Brew | |
| # 13. NodeJS | |
| # 14. jEnv | |
| # 15. Ruby | |
| # 16. Specific Paths | |
| # 17. Docker | |
| # 18. thefuck | |
| # 19. LD_LIBRARY_PATH | |
| # 20. pyenv | |
| # ---------------------------------- | |
| # 1. ENVIRONMENT CONFIGURATION | |
| # ---------------------------------- | |
| # Source Prezto. | |
| #if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then | |
| # source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" | |
| #fi | |
| # Customize to your needs... | |
| #autoload -Uz promptinit | |
| #promptinit | |
| #prompt steeef | |
| # If you come from bash you might have to change your $PATH. | |
| # export PATH=$HOME/bin:/usr/local/bin:$PATH | |
| # Path to your oh-my-zsh installation. | |
| export ZSH="/Users/carlos.garcia/.oh-my-zsh" | |
| # Set name of the theme to load --- if set to "random", it will | |
| # load a random theme each time oh-my-zsh is loaded, in which case, | |
| # to know which specific one was loaded, run: echo $RANDOM_THEME | |
| # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
| ZSH_THEME="steeef" | |
| # Set list of themes to pick from when loading at random | |
| # Setting this variable when ZSH_THEME=random will cause zsh to load | |
| # a theme from this variable instead of looking in $ZSH/themes/ | |
| # If set to an empty array, this variable will have no effect. | |
| # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
| # Uncomment the following line to use case-sensitive completion. | |
| # CASE_SENSITIVE="true" | |
| # Uncomment the following line to use hyphen-insensitive completion. | |
| # Case-sensitive completion must be off. _ and - will be interchangeable. | |
| # HYPHEN_INSENSITIVE="true" | |
| # Uncomment the following line to disable bi-weekly auto-update checks. | |
| # DISABLE_AUTO_UPDATE="true" | |
| # Uncomment the following line to automatically update without prompting. | |
| # DISABLE_UPDATE_PROMPT="true" | |
| # Uncomment the following line to change how often to auto-update (in days). | |
| # export UPDATE_ZSH_DAYS=13 | |
| # Uncomment the following line if pasting URLs and other text is messed up. | |
| # DISABLE_MAGIC_FUNCTIONS=true | |
| # Uncomment the following line to disable colors in ls. | |
| # DISABLE_LS_COLORS="true" | |
| # Uncomment the following line to disable auto-setting terminal title. | |
| # DISABLE_AUTO_TITLE="true" | |
| # Uncomment the following line to enable command auto-correction. | |
| # ENABLE_CORRECTION="true" | |
| # Uncomment the following line to display red dots whilst waiting for completion. | |
| # COMPLETION_WAITING_DOTS="true" | |
| # Uncomment the following line if you want to disable marking untracked files | |
| # under VCS as dirty. This makes repository status check for large repositories | |
| # much, much faster. | |
| # DISABLE_UNTRACKED_FILES_DIRTY="true" | |
| # Uncomment the following line if you want to change the command execution time | |
| # stamp shown in the history command output. | |
| # You can set one of the optional three formats: | |
| # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
| # or set a custom format using the strftime function format specifications, | |
| # see 'man strftime' for details. | |
| # HIST_STAMPS="mm/dd/yyyy" | |
| # Would you like to use another custom folder than $ZSH/custom? | |
| # ZSH_CUSTOM=/path/to/new-custom-folder | |
| # Which plugins would you like to load? | |
| # Standard plugins can be found in $ZSH/plugins/ | |
| # Custom plugins may be added to $ZSH_CUSTOM/plugins/ | |
| # Example format: plugins=(rails git textmate ruby lighthouse) | |
| # Add wisely, as too many plugins slow down shell startup. | |
| plugins=(git yarn) | |
| source $ZSH/oh-my-zsh.sh | |
| # User configuration | |
| # export MANPATH="/usr/local/man:$MANPATH" | |
| # You may need to manually set your language environment | |
| export LANG=en_GB.UTF-8 | |
| # Preferred editor for local and remote sessions | |
| # if [[ -n $SSH_CONNECTION ]]; then | |
| # export EDITOR='vim' | |
| # else | |
| # export EDITOR='mvim' | |
| # fi | |
| # Compilation flags | |
| # export ARCHFLAGS="-arch x86_64" | |
| # Set personal aliases, overriding those provided by oh-my-zsh libs, | |
| # plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
| # users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
| # For a full list of active aliases, run `alias`. | |
| # | |
| # Example aliases | |
| # alias zshconfig="mate ~/.zshrc" | |
| # alias ohmyzsh="mate ~/.oh-my-zsh" | |
| # gulp autocompletion | |
| #source /Users/carlos.garcia/.gulp-autocompletion-zsh/gulp-autocompletion.zsh | |
| # ----------------------------- | |
| # 2. MAKE TERMINAL BETTER | |
| # ----------------------------- | |
| alias cp='cp -iv' # Preferred 'cp' implementation | |
| alias mv='mv -iv' # Preferred 'mv' implementation | |
| alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation | |
| alias ll='ls -FGlAhp' # Preferred 'ls' implementation | |
| alias less='less -FSRXc' # Preferred 'less' implementation | |
| cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd' | |
| alias cd..='cd ../' # Go back 1 directory level (for fast typers) | |
| alias ..='cd ../' # Go back 1 directory level | |
| alias ...='cd ../../' # Go back 2 directory levels | |
| alias .3='cd ../../../' # Go back 3 directory levels | |
| alias .4='cd ../../../../' # Go back 4 directory levels | |
| alias .5='cd ../../../../../' # Go back 5 directory levels | |
| alias .6='cd ../../../../../../' # Go back 6 directory levels | |
| alias edit='vscode' # edit: Opens any file in Visual Studio Code editor | |
| alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder | |
| alias ~="cd ~" # ~: Go Home | |
| alias c='clear' # c: Clear terminal display | |
| # alias which='type -all' # which: Find executables | |
| alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths | |
| alias show_options='shopt' # Show_options: display bash options settings | |
| alias fix_stty='stty sane' # fix_stty: Restore terminal settings when screwed up | |
| alias cic='set completion-ignore-case On' # cic: Make tab-completion case-insensitive | |
| mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
| mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
| mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
| trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash | |
| ql () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview | |
| alias DT='tee ~/Desktop/terminalOut.txt' # DT: Pipe content to file on MacOS Desktop | |
| alias editProfile='sudo edit ~/.zshrc' # editProfile: Edits ~/.zshrc file | |
| # lr: Full Recursive Directory Listing | |
| # ------------------------------------------ | |
| alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' | |
| # mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive) | |
| # displays paginated result with colored search terms and two lines surrounding each hit. Example: mans mplayer codec | |
| # -------------------------------------------------------------------- | |
| mans () { | |
| man $1 | grep -iC2 --color=always $2 | less | |
| } | |
| # showa: to remind yourself of an alias (given some part of it) | |
| # ------------------------------------------------------------ | |
| showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; } | |
| # ------------------------------- | |
| # 3. FILE AND FOLDER MANAGEMENT | |
| # ------------------------------- | |
| #ulimit -Sn 65536 65536 //limit on the maximum number of open files | |
| # --------------------------- | |
| # 4. SEARCHING | |
| # --------------------------- | |
| alias qfind="find . -name " # qfind: Quickly search for file | |
| ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory | |
| ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string | |
| ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string | |
| # spotlight: Search for a file using MacOS Spotlight's metadata | |
| # ----------------------------------------------------------- | |
| spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; } | |
| # --------------------------- | |
| # 5. PROCESS MANAGEMENT | |
| # --------------------------- | |
| # findPid: find out the pid of a specified process | |
| # ----------------------------------------------------- | |
| # Note that the command name can be specified via a regex | |
| # E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' | |
| # Without the 'sudo' it will only find processes of the current user | |
| # ----------------------------------------------------- | |
| findPid () { lsof -t -c "$@" ; } | |
| # memHogsTop, memHogsPs: Find memory hogs | |
| # ----------------------------------------------------- | |
| alias memHogsTop='top -l 1 -o rsize | head -20' | |
| alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10' | |
| # cpuHogs: Find CPU hogs | |
| # ----------------------------------------------------- | |
| alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' | |
| # topForever: Continual 'top' listing (every 10 seconds) | |
| # ----------------------------------------------------- | |
| alias topForever='top -l 9999999 -s 10 -o cpu' | |
| # ttop: Recommended 'top' invocation to minimize resources | |
| # ------------------------------------------------------------ | |
| # Taken from this macosxhints article | |
| # http://www.macosxhints.com/article.php?story=20060816123853639 | |
| # ------------------------------------------------------------ | |
| alias ttop="top -R -F -s 10 -o rsize" | |
| # my_ps: List processes owned by my user: | |
| # ------------------------------------------------------------ | |
| my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; } | |
| # --------------------------- | |
| # 6. NETWORKING | |
| # --------------------------- | |
| alias myip='curl ip.appspot.com' # myip: Public facing IP Address | |
| alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets | |
| alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache | |
| alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets | |
| alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets | |
| alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets | |
| alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0 | |
| alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1 | |
| alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections | |
| alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs | |
| alias tcpSettings='sysctl net.inet.tcp' # tcpSettings: Displays current TCP settings | |
| # ii: display useful host related informaton | |
| # ------------------------------------------------------------------- | |
| ii() { | |
| echo -e "\nYou are logged on ${RED}$HOST" | |
| echo -e "\nAdditionnal information:$NC " ; uname -a | |
| echo -e "\n${RED}Users logged on:$NC " ; w -h | |
| echo -e "\n${RED}Current date :$NC " ; date | |
| echo -e "\n${RED}Machine stats :$NC " ; uptime | |
| echo -e "\n${RED}Current network location :$NC " ; scselect | |
| echo -e "\n${RED}Public facing IP Address :$NC " ;myip | |
| #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns | |
| echo | |
| } | |
| # --------------------------------------- | |
| # 7. SYSTEMS OPERATIONS & INFORMATION | |
| # --------------------------------------- | |
| alias mountReadWrite='/sbin/mount -uw /' # mountReadWrite: For use when booted into single-user | |
| # ------------------------------------------------------------------- | |
| alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete" | |
| # finderShowHidden: Show hidden files in Finder | |
| # finderHideHidden: Hide hidden files in Finder | |
| # ------------------------------------------------------------------- | |
| alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE' | |
| alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE' | |
| # cleanupLS: Clean up LaunchServices to remove duplicates in the "Open With" menu | |
| # ----------------------------------------------------------------------------------- | |
| alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder" | |
| # screensaverDesktop: Run a screensaver on the Desktop | |
| # ----------------------------------------------------------------------------------- | |
| alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background' | |
| # --------------------------------------- | |
| # 8. WEB DEVELOPMENT | |
| # --------------------------------------- | |
| alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf | |
| alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache | |
| alias listHosts='cat /etc/hosts' # listHosts: Cats /etc/hosts file | |
| alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file | |
| alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs | |
| alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs | |
| httpHeaders () { /usr/bin/curl -I -L $@ ; } # httpHeaders: Grabs headers from web page | |
| # httpDebug: Download a web page and show info on what took time | |
| # ------------------------------------------------------------------- | |
| httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } | |
| # --------------------------------------- | |
| # 9. Git | |
| # --------------------------------------- | |
| # | |
| # Removes local branches that are no longer on the remote | |
| alias gitpurge="git fetch -p && git branch -vv | grep ': gone]' | grep -v '\[origin/master' | grep -v '\[origin/next-release' | awk '{print \$1;}' | xargs -n 1 git branch -D && git gc --aggressive" | |
| find_github_url () { | |
| echo `git remote -v | grep fetch | awk '{print $2}' | sed 's/git@/https:\/\//' | sed 's/com:/com\//' | sed 's/\.git//'` | |
| } | |
| find_git_branch() { | |
| local branch | |
| if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
| local status=$(git status --porcelain 2> /dev/null) | |
| if [[ "$branch" == "HEAD" ]]; then | |
| branch='detached*' | |
| fi | |
| if [[ "$status" != "" ]]; then | |
| git_branch="$txtred($branch)$txtrst " | |
| else | |
| git_branch="$txtgrn($branch)$txtrst " | |
| fi | |
| else | |
| git_branch="" | |
| fi | |
| } | |
| find_git_dirty() { | |
| local status=$(git status --porcelain 2> /dev/null) | |
| if [[ "$status" != "" ]]; then | |
| git_dirty='($branch)' | |
| else | |
| git_dirty='' | |
| fi | |
| } | |
| PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND" | |
| gitrepo () { | |
| open -a /Applications/Google\ Chrome.app "$(find_github_url)"; | |
| } | |
| gitpr () { | |
| local branch | |
| if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
| open -a /Applications/Google\ Chrome.app "$(find_github_url)/compare/next-release...$branch?expand=1"; | |
| fi | |
| } | |
| export GPG_TTY=$(tty) | |
| # --------------------------------------- | |
| # 11. MailOnline | |
| # --------------------------------------- | |
| # MailOnline development specific setup | |
| export MOL_DEV_HOME='/Users/carlos.garcia/Documents/mailonline/development' | |
| alias mailonlinedev='cd $MOL_DEV_HOME' | |
| export NODE_ENV="development" | |
| #export VIDEO_PROCESSING_HOME=$MOL_DEV_HOME/video-processing | |
| # Content Creator | |
| #export CC_ROOT="$HOME/Documents/mailonline/development/cc/content-creator" | |
| #export PATH="$PATH:$CC_HOME" | |
| # deploy_tools | |
| #source $HOME/Documents/mailonline/development/tools/deploy_tools/profile | |
| # WPS | |
| #export PATH="$PATH:/usr/local/Cellar/tomcat6/6.0.44/bin" | |
| # Scripts | |
| export PATH="$PATH:/Users/carlos.garcia/Documents/mailonline/development/scripts" | |
| # Oracle | |
| export OCI_LIB_DIR=/Users/carlos.garcia/Documents/mailonline/development/oracle/instantclient | |
| export OCI_INC_DIR=/Users/carlos.garcia/Documents/mailonline/development/oracle/instantclient/sdk/include | |
| # --------------------------------------- | |
| # 12. Brew | |
| # --------------------------------------- | |
| # Brew related configuration | |
| export PATH="$PATH:/opt/homebrew/bin" | |
| export BREW_INSTALLED_HOME="/opt/homebrew/Cellar" | |
| # --------------------------------------- | |
| # 13. NodeJS | |
| # --------------------------------------- | |
| # NodeJS configuration | |
| # Auto change the nvm version based on a .nvmrc file based on the current directory. See https://github.com/creationix/nvm/issues/110#issuecomment-190125863 | |
| autoload -U add-zsh-hook | |
| load-nvmrc() { | |
| if [[ -f .nvmrc && -r .nvmrc ]]; then | |
| nvm use | |
| fi | |
| } | |
| add-zsh-hook chpwd load-nvmrc | |
| export NVM_DIR="$HOME/.nvm" | |
| . "$(brew --prefix nvm)/nvm.sh" | |
| # --------------------------------------- | |
| # 14. jEnv | |
| # --------------------------------------- | |
| # Tool to manage your Java environment, including different versions of Java | |
| #export PATH="$HOME/.jenv/bin:$PATH" | |
| eval "$(jenv init -)" | |
| # --------------------------------------- | |
| # 15. Ruby | |
| # --------------------------------------- | |
| # Ruby configuration | |
| #export RBENV_ROOT=/usr/local/var/rbenv | |
| #if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi | |
| # --------------------------------------- | |
| # 16. Specfic Paths | |
| # --------------------------------------- | |
| # Aliases to specific paths | |
| alias personaldev='cd ~/Documents/personal/development' | |
| # --------------------------------------- | |
| # 17. Docker | |
| # --------------------------------------- | |
| # Docker related configuration | |
| # Set environment variables for Docker to run | |
| #if [[ "$("$(which gtimeout || which timeout)" 3 docker-machine status default 2>/dev/null)" == 'Running' ]]; then | |
| # echo 'carlos yes' | |
| # eval $(docker-machine env default) | |
| #fi | |
| # --------------------------------------- | |
| # 18. thefuck | |
| # --------------------------------------- | |
| # https://github.com/nvbn/thefuck | |
| eval $(thefuck --alias fuck) | |
| alias fuck-it='export THEFUCK_REQUIRE_CONFIRMATION=False; fuck; export THEFUCK_REQUIRE_CONFIRMATION=True' | |
| # --------------------------------------- | |
| # 19. LD_LIBRARY_PATH | |
| # --------------------------------------- | |
| # | |
| export LD_LIBRARY_PATH=$OCI_LIB_DIR | |
| test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" | |
| # --------------------------------------- | |
| # 20. pyenv | |
| # --------------------------------------- | |
| # | |
| export PYENV_ROOT="$HOME/.pyenv" | |
| export PATH="$PYENV_ROOT/bin:$PATH" | |
| eval "$(pyenv init --path)" | |
| eval "$(pyenv init -)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment