├── .gitignore ├── LICENSE.txt ├── README.md ├── _init.sh ├── autoloaded ├── cdf ├── colors ├── delete.line.from.file ├── delete.line.from.history ├── dfgrep ├── dgrep ├── empty.file ├── ex ├── image.scale.1024 ├── image.scale.600 ├── image.strip ├── image.thumpnail ├── man ├── mcd ├── path ├── psgrep ├── rm.ds.store ├── sys.clean.old.logs ├── sys.console ├── sys.nicemount ├── sys.open.ip4 ├── sys.open.ip6 ├── sys.open.port ├── sys.pkg.files ├── sys.pkg.forget ├── sys.pkg.rm ├── sys.reset.openwith ├── sys.screenshot.jpeg ├── sys.screenshot.jpeg2k ├── sys.screenshot.pdf ├── sys.screenshot.png ├── sys.screenshot.read ├── sys.screenshot.tiff ├── sys.set.name ├── sys.uti.reset ├── update └── uuid ├── bootstrap.sh ├── inactive ├── prompts-htr3n.sh ├── prompts-powerlevel9k.sh ├── prompts-spaceship.sh └── prompts.zsh ├── lib ├── completion.zsh ├── dircolors-custom ├── history.zsh ├── keybindings.zsh ├── ls_color.zsh ├── macos.zsh ├── ubuntu.zsh └── z-custom.zsh ├── zi-init.zsh ├── zlogin ├── zprofile ├── zsh-performance.md ├── zshenv └── zshrc /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | *.zwc 3 | *.old 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2023 Alex Tran 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # My ZSH Configurations 2 | 3 | The configurations are for my macOS workstation and therefore contain some macOS-specific code and commands. 4 | 5 | ## Quick Start 6 | 7 | ```sh 8 | # get to the home folder 9 | $ cd 10 | # pull the git repos 11 | $ git clone https://github.com/htr3n/zsh-config.git .zsh-config 12 | # then link the startup files 13 | $ zsh ~/.zsh-config/bootstrap.sh 14 | ``` 15 | 16 | Log out and login again!!! 17 | 18 | In case you want to have private setting excluded from public Git repos, just create a file `.private.sh` in the home folder. 19 | 20 | ## Plugin Management 21 | 22 | Instead of manually installing ZSH plugins, I use [Zi](https://wiki.zshell.dev/), which is a continuing work of [zplugin](https://github.com/zdharma/zplugin), with cool Turbo Mode to accelerate the loading and checking of ZSH plugins. Thus, `zi` needs to be installed as well. 23 | 24 | ```sh 25 | sh -c "$(curl -fsSL get.zshell.dev)" -- -i skip -b main 26 | ``` 27 | 28 | Note that `zi` installation script will automatically add some commands into the end of `.zshrc` to initialise / load `zi`. Nonetheless, `_init.sh` has already the initialisation of `zi`, thus, we should remove or comment the parts added by `zi` installation script. 29 | 30 | If `Zi` is set up properly, you can use many handy commands, for instance, updating all or some plugins with `zi update` , removing a plugin `zi delete plugin_name`. 31 | 32 | Some useful ZSH plugins: 33 | 34 | * [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) 35 | * [zsh-completions](https://github.com/zsh-users/zsh-completions) 36 | * [zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search) 37 | * [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) 38 | 39 | ## Credits 40 | 41 | I developed most of the configuration on my own but nevertheless learned a lot from [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and [Prezto](https://github.com/sorin-ionescu/prezto) and many other sources for various settings. 42 | 43 | ## License 44 | 45 | <3 [MIT License](LICENSE.txt). 46 | -------------------------------------------------------------------------------- /_init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | #----------------------------------------------------- 6 | # ensure to only execute on ZSH 7 | # https://stackoverflow.com/a/9911082/339302 8 | [ ! -n "$ZSH_VERSION" ] && return 9 | 10 | # For MacOS 11 | if [[ "x$SYSTEM" = "xDarwin" ]]; then 12 | # system executables 13 | #export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/libexec 14 | # local system binaries 15 | export PATH=/usr/local/sbin:/usr/local/bin:$PATH 16 | fi 17 | 18 | #----------------------------------------------------- 19 | # Load zinit 20 | export ZI_HOME_DIR="${HOME}/.zi" 21 | export ZI_BIN_DIR="${ZI_HOME_DIR}/bin" 22 | 23 | # and the plugins 24 | if [[ -f "${ZI_BIN_DIR}/zi.zsh" ]]; then 25 | source "${ZI_BIN_DIR}/zi.zsh" 26 | else 27 | echo "The Zi init script does not exist at '${ZI_BIN_DIR}/zi.zsh'" 28 | exit 1 29 | fi 30 | #----------------------------------------------------- 31 | 32 | # https://github.com/sindresorhus/pure#options 33 | export PURE_PROMPT_SYMBOL='λ' 34 | 35 | #----------------------------------------------------- 36 | # Setting autoloaded functions 37 | # 38 | my_zsh_fpath=${ZSHCONFIG}/autoloaded 39 | 40 | fpath=($my_zsh_fpath $fpath) 41 | 42 | if [[ -d "$my_zsh_fpath" ]]; then 43 | for func in $my_zsh_fpath/*; do 44 | autoload -Uz ${func:t} 45 | done 46 | fi 47 | unset my_zsh_fpath 48 | 49 | #----------------------------------------------------- 50 | # 51 | # Load all scripts ${ZSHCONFIG}/lib/*.zsh 52 | # 53 | my_zsh_lib=${ZSHCONFIG}/lib 54 | if [[ -d "$my_zsh_lib" ]]; then 55 | for file in $my_zsh_lib/*.zsh; do 56 | source $file 57 | done 58 | fi 59 | unset my_zsh_lib 60 | 61 | 62 | #----------------------------------------------------- 63 | # Development stuffs 64 | # 65 | dev_config_init=${SCRIPTS}/dev-config/_init.sh 66 | 67 | [[ -f "$dev_config_init" ]] && source "$dev_config_init" 68 | 69 | unset dev_config_init 70 | 71 | #----------------------------------------------------- 72 | # after all, set the PATH for macOS 73 | [[ -x /bin/launchctl ]] && /bin/launchctl setenv PATH $PATH 74 | -------------------------------------------------------------------------------- /autoloaded/cdf: -------------------------------------------------------------------------------- 1 | # Change directory to the current Finder directory 2 | target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'` 3 | if [ "$target" != "" ]; then 4 | cd "$target"; pwd 5 | else 6 | echo 'No Finder window found' >&2 7 | fi 8 | -------------------------------------------------------------------------------- /autoloaded/colors: -------------------------------------------------------------------------------- 1 | # Put standard ANSI color codes in shell parameters for easy use. 2 | # Note that some terminals do not support all combinations. 3 | 4 | emulate -L zsh 5 | 6 | typeset -Ag color colour 7 | 8 | color=( 9 | # Codes listed in this array are from ECMA-48, Section 8.3.117, p. 61. 10 | # Those that are commented out are not widely supported or aren't closely 11 | # enough related to color manipulation, but are included for completeness. 12 | 13 | # Attribute codes: 14 | 00 none # 20 gothic 15 | 01 bold # 21 double-underline 16 | 02 faint 22 normal 17 | 03 standout 23 no-standout 18 | 04 underline 24 no-underline 19 | 05 blink 25 no-blink 20 | # 06 fast-blink # 26 proportional 21 | 07 reverse 27 no-reverse 22 | 08 conceal 28 no-conceal 23 | # 09 strikethrough # 29 no-strikethrough 24 | 25 | # Font selection: 26 | # 10 font-default 27 | # 11 font-first 28 | # 12 font-second 29 | # 13 font-third 30 | # 14 font-fourth 31 | # 15 font-fifth 32 | # 16 font-sixth 33 | # 17 font-seventh 34 | # 18 font-eighth 35 | # 19 font-ninth 36 | 37 | # Text color codes: 38 | 30 black 40 bg-black 39 | 31 red 41 bg-red 40 | 32 green 42 bg-green 41 | 33 yellow 43 bg-yellow 42 | 34 blue 44 bg-blue 43 | 35 magenta 45 bg-magenta 44 | 36 cyan 46 bg-cyan 45 | 37 white 47 bg-white 46 | # 38 iso-8316-6 # 48 bg-iso-8316-6 47 | 39 default 49 bg-default 48 | 49 | # Other codes: 50 | # 50 no-proportional 51 | # 51 border-rectangle 52 | # 52 border-circle 53 | # 53 overline 54 | # 54 no-border 55 | # 55 no-overline 56 | # 56 through 59 reserved 57 | 58 | # Ideogram markings: 59 | # 60 underline-or-right 60 | # 61 double-underline-or-right 61 | # 62 overline-or-left 62 | # 63 double-overline-or-left 63 | # 64 stress 64 | # 65 no-ideogram-marking 65 | ) 66 | 67 | # A word about black and white: The "normal" shade of white is really a 68 | # very pale grey on many terminals; to get truly white text, you have to 69 | # use bold white, and to get a truly white background you have to use 70 | # bold reverse white bg-xxx where xxx is your desired foreground color 71 | # (and which means the foreground is also bold). 72 | 73 | # Map in both directions; could do this with e.g. ${(k)colors[(i)normal]}, 74 | # but it's clearer to include them all both ways. 75 | 76 | local k 77 | for k in ${(k)color}; do color[${color[$k]}]=$k; done 78 | 79 | # Add "fg-" keys for all the text colors, for clarity. 80 | 81 | for k in ${color[(I)3?]}; do color[fg-${color[$k]}]=$k; done 82 | 83 | # This is inaccurate, but the prompt theme system needs it. 84 | 85 | color[grey]=${color[black]} 86 | color[fg-grey]=${color[grey]} 87 | color[bg-grey]=${color[bg-black]} 88 | 89 | # Assistance for the color-blind. 90 | 91 | colour=(${(kv)color}) # A case where ksh namerefs would be useful ... 92 | 93 | # The following are terminal escape sequences used by colored prompt themes. 94 | 95 | local lc=$'\e[' rc=m # Standard ANSI terminal escape values 96 | 97 | typeset -Hg reset_color bold_color 98 | reset_color="$lc${color[none]}$rc" 99 | bold_color="$lc${color[bold]}$rc" 100 | 101 | # Foreground 102 | 103 | typeset -AHg fg fg_bold fg_no_bold 104 | for k in ${(k)color[(I)fg-*]}; do 105 | fg[${k#fg-}]="$lc${color[$k]}$rc" 106 | fg_bold[${k#fg-}]="$lc${color[bold]};${color[$k]}$rc" 107 | fg_no_bold[${k#fg-}]="$lc${color[normal]};${color[$k]}$rc" 108 | done 109 | 110 | # Background 111 | 112 | typeset -AHg bg bg_bold bg_no_bold 113 | for k in ${(k)color[(I)bg-*]}; do 114 | bg[${k#bg-}]="$lc${color[$k]}$rc" 115 | bg_bold[${k#bg-}]="$lc${color[bold]};${color[$k]}$rc" 116 | bg_no_bold[${k#bg-}]="$lc${color[normal]};${color[$k]}$rc" 117 | done 118 | -------------------------------------------------------------------------------- /autoloaded/delete.line.from.file: -------------------------------------------------------------------------------- 1 | if [[ $# -ne 2 ]]; then 2 | echo "Usage: $0 pattern file" 3 | exit 1 4 | else 5 | if [[ -f /usr/local/bin/sed ]]; then 6 | LC_ALL=C /usr/local/bin/sed -i "/$1/d" $2 7 | elif [[ -f /usr/local/bin/gsed ]]; then 8 | LC_ALL=C /usr/local/bin/gsed -i "/$1/d" $2 9 | elif [[ -f /usr/bin/sed ]]; then 10 | LC_ALL=C sed -i '' "/$1/d" $2 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /autoloaded/delete.line.from.history: -------------------------------------------------------------------------------- 1 | if [[ $# -ne 1 ]]; then 2 | echo "Usage: $0 pattern" 3 | else 4 | delete.line.from.file $1 $HISTFILE 5 | fi 6 | -------------------------------------------------------------------------------- /autoloaded/dfgrep: -------------------------------------------------------------------------------- 1 | # A recursive, case-insensitive grep that excludes binary files 2 | # and returns only unique filenames 3 | 4 | grep -iR "$@" * | grep -v "Binary" | sed 's/:/ /g' | awk '{ print $1 }' | sort | uniq -------------------------------------------------------------------------------- /autoloaded/dgrep: -------------------------------------------------------------------------------- 1 | # https://justin.abrah.ms/dotfiles/zsh.html 2 | # A recursive, case-insensitive grep that excludes binary files 3 | grep -iR "$@" * | grep -v "Binary" 4 | -------------------------------------------------------------------------------- /autoloaded/empty.file: -------------------------------------------------------------------------------- 1 | if [ ! "$#" -gt 0 ] ; then 2 | echo "Usage: $0 file1 file2 ..." >&2 3 | return -1 4 | fi 5 | for file in $@; do 6 | if [ -f $file ] ; then 7 | echo "Emptying $file ..." 8 | cp /dev/null $file 9 | fi 10 | done 11 | echo 'Done!' 12 | -------------------------------------------------------------------------------- /autoloaded/ex: -------------------------------------------------------------------------------- 1 | # 2 | # http://zanshin.net/2013/02/02/zsh-configuration-from-the-ground-up 3 | # ------------------------------------------------------------------- 4 | # compressed file expander 5 | # (from https://github.com/myfreeweb/zshuery/blob/master/zshuery.sh) 6 | # ------------------------------------------------------------------- 7 | 8 | if [[ -f $1 ]]; then 9 | case $1 in 10 | *.tar.bz2) tar xvjf $1;; 11 | *.tar.gz) tar xvzf $1;; 12 | *.tar.xz) tar xvJf $1;; 13 | *.tar.lzma) tar --lzma xvf $1;; 14 | *.bz2) bunzip $1;; 15 | *.rar) unrar $1;; 16 | *.gz) gunzip $1;; 17 | *.tar) tar xvf $1;; 18 | *.tbz2) tar xvjf $1;; 19 | *.tgz) tar xvzf $1;; 20 | *.zip) unzip $1;; 21 | *.Z) uncompress $1;; 22 | *.7z) 7z x $1;; 23 | *.dmg) hdiutul mount $1;; # mount OS X disk images 24 | *) echo "'$1' cannot be extracted via >ex<";; 25 | esac 26 | else 27 | echo "'$1' is not a valid file" 28 | fi 29 | -------------------------------------------------------------------------------- /autoloaded/image.scale.1024: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $# -eq 0 ]]; then 4 | echo "Usage: $0 file-name.[png|jpg]" 5 | return 1 6 | fi 7 | 8 | if [[ ! -x "/usr/local/bin/convert" ]];then 9 | echo "Could not find ImageMagick 'convert'. Please install it." 10 | return 1 11 | fi 12 | 13 | file=$(basename -- "$1") 14 | ext="${file##*.}" 15 | filename="${file%%.*}" 16 | tn="${filename}.tn.${ext}" 17 | echo "convert $1 -scale 1024x $tn" 18 | convert "$1" -scale 1024x "$tn" 19 | -------------------------------------------------------------------------------- /autoloaded/image.scale.600: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $# -eq 0 ]]; then 4 | echo "Usage: $0 file-name.[png|jpg]" 5 | return 1 6 | fi 7 | 8 | if [[ ! -x "/usr/local/bin/convert" ]];then 9 | echo "Could not find ImageMagick 'convert'. Please install it." 10 | return 1 11 | fi 12 | 13 | file=$(basename -- "$1") 14 | ext="${file##*.}" 15 | filename="${file%%.*}" 16 | tn="${filename}.tn.${ext}" 17 | echo "convert $1 -scale 600x $tn" 18 | convert "$1" -scale 600x "$tn" 19 | -------------------------------------------------------------------------------- /autoloaded/image.strip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $# -eq 0 ]]; then 4 | echo "Usage: $0 file-name.png" 5 | return 1 6 | fi 7 | 8 | if [[ ! -x "/usr/local/bin/convert" ]];then 9 | echo "Could not find ImageMagick 'convert'. Please install it." 10 | return 1 11 | fi 12 | 13 | file=$(basename -- "$1") 14 | ext="${file##*.}" 15 | filename="${file%%.*}" 16 | output="${filename}.stripped.${ext}" 17 | echo "convert $1 -strip $output" 18 | convert "$1" -strip "$output" 19 | -------------------------------------------------------------------------------- /autoloaded/image.thumpnail: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $# -eq 0 ]]; then 4 | echo "Usage: $0 file-name.[png|jpg]" 5 | return 1 6 | fi 7 | 8 | if [[ ! -x "/usr/local/bin/convert" ]];then 9 | echo "Could not find ImageMagick 'convert'. Please install it." 10 | return 1 11 | fi 12 | 13 | file=$(basename -- "$1") 14 | ext="${file##*.}" 15 | filename="${file%%.*}" 16 | tn="${filename}.tn.${ext}" 17 | echo "convert $1 -scale 600x $tn" 18 | convert "$1" -scale 600x "$tn" 19 | -------------------------------------------------------------------------------- /autoloaded/man: -------------------------------------------------------------------------------- 1 | # Get colors in manual pages 2 | env \ 3 | LESS_TERMCAP_mb=$(printf "\e[1;31m") \ 4 | LESS_TERMCAP_md=$(printf "\e[1;31m") \ 5 | LESS_TERMCAP_me=$(printf "\e[0m") \ 6 | LESS_TERMCAP_se=$(printf "\e[0m") \ 7 | LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ 8 | LESS_TERMCAP_ue=$(printf "\e[0m") \ 9 | LESS_TERMCAP_us=$(printf "\e[1;32m") \ 10 | man "$@" 11 | -------------------------------------------------------------------------------- /autoloaded/mcd: -------------------------------------------------------------------------------- 1 | # https://justin.abrah.ms/dotfiles/zsh.html 2 | # make a dir and change to that dir 3 | mkdir -p $1 && cd $1; 4 | -------------------------------------------------------------------------------- /autoloaded/path: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------- 2 | # display a neatly formatted PATH content with colors 3 | # ------------------------------------------------------------------- 4 | 5 | echo "$PATH" | tr ":" "\n" | \ 6 | awk "{ sub(\"/usr\", \"\x1b[0;32m/usr\x1b[0m\"); \ 7 | sub(\"/bin\", \"\x1b[0;34m/bin\x1b[0m\"); \ 8 | sub(\"/opt\", \"\x1b[0;36m/opt\x1b[0m\"); \ 9 | sub(\"/sbin\", \"\x1b[0;35m/sbin\x1b[0m\"); \ 10 | sub(\"/local\", \"\x1b[0;33m/local\x1b[0m\"); \ 11 | print }" 12 | -------------------------------------------------------------------------------- /autoloaded/psgrep: -------------------------------------------------------------------------------- 1 | # https://justin.abrah.ms/dotfiles/zsh.html 2 | if [ ! -z $1 ] ; then 3 | ps aux | grep $1 | grep -v grep 4 | else 5 | echo "!! Need name to grep for" 6 | fi 7 | -------------------------------------------------------------------------------- /autoloaded/rm.ds.store: -------------------------------------------------------------------------------- 1 | find . -name ".DS_Store" -exec rm {} \; -------------------------------------------------------------------------------- /autoloaded/sys.clean.old.logs: -------------------------------------------------------------------------------- 1 | sudo rm -vf /var/log/*.[0-9].* 2 | sudo rm -vf /var/log/*.[0-9] 3 | -------------------------------------------------------------------------------- /autoloaded/sys.console: -------------------------------------------------------------------------------- 1 | if [[ $# > 0 ]]; then 2 | query=$(echo "$*"|tr -s ' ' '|') 3 | tail -f /var/log/system.log|grep -i --color=auto -E "$query" 4 | else 5 | tail -f /var/log/system.log 6 | fi 7 | -------------------------------------------------------------------------------- /autoloaded/sys.nicemount: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------- 2 | # https://goo.gl/9xc1tu 3 | # displays mounted drive information in a nicely formatted manner 4 | # ------------------------------------------------------------------- 5 | (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2="";1') | column -t ; -------------------------------------------------------------------------------- /autoloaded/sys.open.ip4: -------------------------------------------------------------------------------- 1 | # show open IP4 connections 2 | lsof -Pnl +M -i4 -------------------------------------------------------------------------------- /autoloaded/sys.open.ip6: -------------------------------------------------------------------------------- 1 | lsof -Pnl +M -i6 -------------------------------------------------------------------------------- /autoloaded/sys.open.port: -------------------------------------------------------------------------------- 1 | # show listening ports 2 | lsof -i -P | grep -i 'listen' -------------------------------------------------------------------------------- /autoloaded/sys.pkg.files: -------------------------------------------------------------------------------- 1 | if [[ $# > 0 ]]; then 2 | pkgutil --files $1 3 | else 4 | echo "$0 name.pkg" 5 | fi 6 | -------------------------------------------------------------------------------- /autoloaded/sys.pkg.forget: -------------------------------------------------------------------------------- 1 | if [[ $# > 0 ]]; then 2 | sudo pkgutil --forget $1 3 | else 4 | echo "$0 name.pkg" 5 | fi -------------------------------------------------------------------------------- /autoloaded/sys.pkg.rm: -------------------------------------------------------------------------------- 1 | if [[ $# > 0 ]]; then 2 | pkgutil --only-files --files $1 | tr '\n' '\0' | xargs -n 1 -0 sudo rm -i 3 | pkgutil --only-dirs --files $1 | tr '\ n' '\0' | xargs -n 1 -0 sudo rm -ir 4 | sudo pkgutil --forget $1 5 | else 6 | echo "$0 name.pkg" 7 | fi 8 | -------------------------------------------------------------------------------- /autoloaded/sys.reset.openwith: -------------------------------------------------------------------------------- 1 | /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user 2 | -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.jpeg: -------------------------------------------------------------------------------- 1 | defaults write com.apple.screencapture type jpg 2 | killall SystemUIServer -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.jpeg2k: -------------------------------------------------------------------------------- 1 | defaults write com.apple.screencapture type jp2 2 | killall SystemUIServer -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.pdf: -------------------------------------------------------------------------------- 1 | defaults write com.apple.screencapture type pdf 2 | killall SystemUIServer -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.png: -------------------------------------------------------------------------------- 1 | defaults write com.apple.screencapture type png 2 | killall SystemUIServer -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.read: -------------------------------------------------------------------------------- 1 | defaults read com.apple.screencapture -------------------------------------------------------------------------------- /autoloaded/sys.screenshot.tiff: -------------------------------------------------------------------------------- 1 | defaults write com.apple.screencapture type tiff 2 | killall SystemUIServer -------------------------------------------------------------------------------- /autoloaded/sys.set.name: -------------------------------------------------------------------------------- 1 | if [[ $# -eq 0 ]]; then 2 | echo "Usage $0 " 3 | return 4 | else 5 | sudo scutil --set ComputerName "$1" 6 | sudo scutil --set LocalHostName "$1" 7 | sudo scutil --set HostName "$1" 8 | fi 9 | -------------------------------------------------------------------------------- /autoloaded/sys.uti.reset: -------------------------------------------------------------------------------- 1 | /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user 2 | killall Dock -------------------------------------------------------------------------------- /autoloaded/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # 6 | # Helper Functions 7 | # http://apple.stackexchange.com/a/96810/7647 8 | # 9 | #update() { 10 | local brew="echo ; echo 'UPDATING HOMEBREW'; echo ; brew update; brew upgrade; brew cleanup;" 11 | local cask="echo ; echo 'UPDATING CASK'; echo ; brew cask upgrade; " 12 | local fzf="echo ; echo 'UPDATING fzf'; echo ; (cd ~/.fzf; git pull);" 13 | #local zplugin="echo; echo 'UPDATING zplugin'; echo ; zplg update --all; "; 14 | #local zsh_autosuggestions="echo ; echo 'UPDATING zsh-autosuggestions'; echo ; cd ${ZSHCONFIG}/zsh-autosuggestions; git pull;" 15 | #local zsh_history_substring_search="echo ; echo 'UPDATING zsh-history-substring-search'; echo ; cd ${ZSHCONFIG}/zsh-history-substring-search; git pull;" 16 | #local zsh_completions="echo ; echo 'UPDATING zsh-completions'; echo ; cd ${ZSHCONFIG}/zsh-completions; git pull;" 17 | #local prezto="echo ; echo 'UPDATING PREZTO'; echo ; cd ${HOME}/.zprezto; git pull && git submodule update --init --recursive ;" 18 | #local texlive="echo ; echo 'UPDATING TeXLive'; echo ; tlmgr update --all --self" 19 | local gem="gem update;" 20 | local pip3="pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip3 install -U -q" 21 | local zshconfig="echo ; echo 'UPDATING ZSH-CONFIG'; echo ; cd ${HOME}/.zsh-config; git pull && git submodule update --init --recursive ;" 22 | sh -c $brew$cask$zshconfig$gem$pip3 23 | #} 24 | -------------------------------------------------------------------------------- /autoloaded/uuid: -------------------------------------------------------------------------------- 1 | uuidgen | tr -d - | tr -d '\n' | tr '[:upper:]' '[:lower:]' | pbcopy && pbpaste && echo -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | ZSHCONFIG=${HOME}/.zsh-config 6 | 7 | ZI_HOME_DIR="${HOME}/.zi" 8 | ZI_BIN_DIR="${ZI_HOME_DIR}/bin" 9 | 10 | echo "Cloning zi repository" 11 | 12 | mkdir -p "${ZI_HOME_DIR}" 13 | 14 | git clone https://github.com/z-shell/zi.git "${ZI_BIN_DIR}" 15 | 16 | echo "Link ZSH resource files to '${HOME}'" 17 | 18 | ln -srnf "${ZSHCONFIG}/zlogin" "${HOME}/.zlogin" 19 | ln -srnf "${ZSHCONFIG}/zprofile" "${HOME}/.zprofile" 20 | ln -srnf "${ZSHCONFIG}/zshenv" "${HOME}/.zshenv" 21 | ln -srnf "${ZSHCONFIG}/zshrc" "${HOME}/.zshrc" 22 | 23 | echo "Done!" 24 | -------------------------------------------------------------------------------- /inactive/prompts-htr3n.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # http://zshwiki.org/home/config/prompt 6 | # enable colors and predefined variables 7 | autoload -U colors && colors 8 | #reset_color=%{$'\e[00m'%} 9 | 10 | # load the theme system 11 | autoload -U promptinit && promptinit 12 | 13 | # ----------------------------------------------- 14 | # for dynamic named directories 15 | setopt prompt_subst 16 | setopt auto_name_dirs 17 | 18 | # ----------------------------------------------- 19 | # PROMPT COLORS 20 | # 21 | # Color table from: http://www.understudy.net/custom.html 22 | export CLICOLOR=1 23 | 24 | fg_black=%{$'\e[0;30m'%} 25 | fg_red=%{$'\e[0;31m'%} 26 | fg_green=%{$'\e[0;32m'%} 27 | fg_brown=%{$'\e[0;33m'%} 28 | fg_blue=%{$'\e[0;34m'%} 29 | fg_purple=%{$'\e[0;35m'%} 30 | fg_cyan=%{$'\e[0;36m'%} 31 | fg_lgray=%{$'\e[0;37m'%} 32 | fg_dgray=%{$'\e[1;30m'%} 33 | fg_lred=%{$'\e[1;31m'%} 34 | fg_lgreen=%{$'\e[1;32m'%} 35 | fg_yellow=%{$'\e[1;33m'%} 36 | fg_lblue=%{$'\e[1;34m'%} 37 | fg_pink=%{$'\e[1;35m'%} 38 | fg_lcyan=%{$'\e[1;36m'%} 39 | fg_white=%{$'\e[1;37m'%} 40 | 41 | #Text Background Colors 42 | bg_red=%{$'\e[0;41m'%} 43 | bg_green=%{$'\e[0;42m'%} 44 | bg_brown=%{$'\e[0;43m'%} 45 | bg_blue=%{$'\e[0;44m'%} 46 | bg_purple=%{$'\e[0;45m'%} 47 | bg_cyan=%{$'\e[0;46m'%} 48 | bg_gray=%{$'\e[0;47m'%} 49 | 50 | #Attributes 51 | at_normal=%{$'\e[0m'%} 52 | at_bold=%{$'\e[1m'%} 53 | at_italics=%{$'\e[3m'%} 54 | at_underl=%{$'\e[4m'%} 55 | at_blink=%{$'\e[5m'%} 56 | at_outline=%{$'\e[6m'%} 57 | at_reverse=%{$'\e[7m'%} 58 | at_nondisp=%{$'\e[8m'%} 59 | at_strike=%{$'\e[9m'%} 60 | at_boldoff=%{$'\e[22m'%} 61 | at_italicsoff=%{$'\e[23m'%} 62 | at_underloff=%{$'\e[24m'%} 63 | at_blinkoff=%{$'\e[25m'%} 64 | at_reverseoff=%{$'\e[27m'%} 65 | at_strikeoff=%{$'\e[29m'%} 66 | 67 | 68 | local prompt_suffix='%{$reset_color%}' 69 | local current_dir='${fg_purple}%~%f%{$reset_color%}' 70 | local user_host='%B${fg_lgreen}%n%{$reset_color%}${fg_pink}@${fg_lcyan}%M%b%f${prompt_suffix}' 71 | local current_datetime='${fg_blue}%D{%d.%m.%Y} ${fg_red}%T%f${prompt_suffix}' 72 | local the_prompt_sign='%b 73 | $fg[105]»%f${prompt_suffix}' 74 | 75 | export PROMPT=" 76 | ${current_datetime} - ${user_host} [${current_dir}] ${the_prompt_sign} " 77 | 78 | # precmd is called just before the prompt is printed 79 | precmd () { 80 | RPROMPT="" 81 | print -Pn "\e]2; %~/ \a" 82 | } 83 | # preexec is called just before any command line is executed 84 | preexec () { 85 | print -Pn "\e]2; %~/ \a" 86 | } 87 | 88 | # 89 | autoload -Uz vcs_info 90 | 91 | zstyle ':vcs_info:*' actionformats \ 92 | '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' 93 | zstyle ':vcs_info:*' formats \ 94 | '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' 95 | zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' 96 | 97 | zstyle ':vcs_info:*' enable git cvs svn 98 | 99 | # or use pre_cmd, see man zshcontrib 100 | vcs_info_wrapper() { 101 | vcs_info 102 | if [ -n "$vcs_info_msg_0_" ]; then 103 | echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" 104 | fi 105 | } 106 | 107 | # prompt for vi mode 108 | function zle-line-init zle-keymap-select { 109 | RPROMPT="" 110 | VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}" 111 | RPROMPT="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $(vcs_info_wrapper) $EPS1" 112 | zle reset-prompt 113 | } 114 | zle -N zle-line-init 115 | zle -N zle-keymap-select 116 | 117 | unset current_datetime 118 | unset current_dir 119 | unset prompt_suffix 120 | unset the_prompt_sign 121 | unset user_host -------------------------------------------------------------------------------- /inactive/prompts-powerlevel9k.sh: -------------------------------------------------------------------------------- 1 | # vim:syntax=sh 2 | # vim:filetype=sh 3 | 4 | # 5 | source ${ZSHCONFIG}/powerlevel9k/powerlevel9k.zsh-theme 6 | 7 | -------------------------------------------------------------------------------- /inactive/prompts-spaceship.sh: -------------------------------------------------------------------------------- 1 | # vim:syntax=sh 2 | # vim:filetype=sh 3 | 4 | # 5 | # https://github.com/denysdovhan/spaceship-prompt 6 | # related to ${HOME}/.zfunctions 7 | autoload -U promptinit; promptinit 8 | prompt spaceship 9 | 10 | -------------------------------------------------------------------------------- /inactive/prompts.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # pick your prompt of choice 6 | 7 | # my own 8 | # source ${ZSHCONFIG}/lib/prompts-htr3n.sh 9 | 10 | # powerlevel9k 11 | # https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions 12 | # source ${ZSHCONFIG}/lib/prompts-powerlevel9k.sh 13 | 14 | # spaceship 15 | # https://github.com/denysdovhan/spaceship-prompt 16 | #source ${ZSHCONFIG}/lib/prompts-spaceship.sh 17 | -------------------------------------------------------------------------------- /lib/completion.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | ################################################################################ 6 | # https://github.com/sorin-ionescu/prezto/blob/master/modules/completion/init.zsh 7 | # https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/completion.zsh 8 | # https://github.com/zimfw/zimfw/blob/master/modules/completion/init.zsh 9 | # https://grml.org/zsh/zsh-lovers.html 10 | 11 | 12 | # Zsh Options 13 | # 14 | unsetopt menu_complete # do not autoselect the first completion entry 15 | unsetopt flow_control # disable start/stop characters in shell editor 16 | unsetopt case_glob # makes globbing (filename generation) case-sensitive 17 | 18 | setopt always_to_end # move cursor to the end of a completed word 19 | setopt auto_menu # show completion menu on a successive tab press 20 | setopt auto_list # automatically list choices on ambiguous completion 21 | setopt auto_param_slash # if completed parameter is a directory, add a trailing slash 22 | setopt complete_in_word # complete from both ends of a word 23 | setopt extended_glob # needed for file modification glob modifiers with compinit 24 | setopt path_dirs # perform path search even on command names with slashes 25 | setopt globdots # files beginning with a . be matched without explicitly specifying the dot 26 | 27 | ################################################################################ 28 | # Completion Module Options 29 | # 30 | # https://grml.org/zsh/zsh-lovers.html#_completion 31 | # Using zstyle: 32 | 33 | # complete . and .. special directories 34 | zstyle ':completion:*' special-dirs true 35 | 36 | # enable caching to make completion for commands such as dpkg and apt usable 37 | zstyle ':completion::complete:*' use-cache on 38 | zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.zcompcache" 39 | 40 | # group matches and describe 41 | zstyle ':completion:*:*:*:*:*' menu select 42 | zstyle ':completion:*:matches' group yes 43 | zstyle ':completion:*:options' description yes 44 | zstyle ':completion:*:options' auto-description '%d' 45 | zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f' 46 | zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f' 47 | zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' 48 | zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' 49 | zstyle ':completion:*:default' list-prompt '%S%M matches%s' 50 | zstyle ':completion:*' format ' %F{yellow}-- %d --%f' 51 | zstyle ':completion:*' group-name '' 52 | zstyle ':completion:*' verbose yes 53 | # https://goo.gl/wFKHYw 54 | #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**' 55 | # https://goo.gl/zuzuP2 56 | #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 57 | # https://goo.gl/QwQgwN 58 | zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' 59 | 60 | # fuzzy match mistyped completions 61 | zstyle ':completion:*' completer _complete _match _approximate 62 | zstyle ':completion:*:match:*' original only 63 | zstyle ':completion:*:approximate:*' max-errors 1 numeric 64 | 65 | # directories 66 | zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 67 | zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories 68 | zstyle ':completion:*:*:cd:*:directory-stack' menu yes select 69 | zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand' 70 | zstyle ':completion:*' squeeze-slashes true 71 | 72 | # ignores unavailable commands 73 | zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)' 74 | 75 | # completion element sorting 76 | zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters 77 | 78 | # man 79 | zstyle ':completion:*:manuals' separate-sections true 80 | zstyle ':completion:*:manuals.(^1*)' insert-sections true 81 | 82 | # history 83 | zstyle ':completion:*:history-words' stop yes 84 | zstyle ':completion:*:history-words' remove-all-dups yes 85 | zstyle ':completion:*:history-words' list false 86 | zstyle ':completion:*:history-words' menu yes 87 | 88 | # ignore multiple entries 89 | zstyle ':completion:*:(rm|kill|diff):*' ignore-line other 90 | zstyle ':completion:*:rm:*' file-patterns '*:all-files' 91 | 92 | # ssh/scp/rsync 93 | zstyle ':completion:*:(ssh|scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' 94 | zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr 95 | zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr 96 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost 97 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' 98 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' 99 | 100 | # ignores uninteresting users ... 101 | zstyle ':completion:*:*:*:users' ignored-patterns \ 102 | adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ 103 | dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ 104 | hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ 105 | mailman mailnull mldonkey mysql nagios \ 106 | named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ 107 | operator pcap postfix postgres privoxy pulse pvm quagga radvd \ 108 | rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*' 109 | 110 | ################################################################################ 111 | # only for debugging 112 | if false; then 113 | 114 | # Fuzzy match mistyped completions 115 | #zstyle ':completion:*' completer _complete _match _approximate 116 | #zstyle ':completion:*:match:*' original only 117 | #zstyle ':completion:*:approximate:*' max-errors 1 numeric 118 | 119 | # kill 120 | zstyle ':completion:*:*:*:*:processes' command 'ps -u $LOGNAME -o pid,user,command -w' 121 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01' 122 | zstyle ':completion:*:*:kill:*' menu yes select 123 | zstyle ':completion:*:*:kill:*' force-list always 124 | zstyle ':completion:*:*:kill:*' insert-ids single 125 | 126 | fi 127 | -------------------------------------------------------------------------------- /lib/dircolors-custom: -------------------------------------------------------------------------------- 1 | # vim: ft=dircolors:fdm=marker:et:sw=2: 2 | 3 | # 4 | # See: 5 | # https://unix.stackexchange.com/a/94306/27109 6 | # "The format for 256 color escape codes is 38;5;colorN for foreground colors 7 | # and 48;5;colorN for background colors." 8 | # 9 | # https://github.com/trapd00r/LS_COLORS 10 | # http://linux-sxs.org/housekeeping/lscolors.html 11 | # 12 | # Needs dircolors/gdircolors from GNU coreutils 13 | # brew info coreutils 14 | 15 | DIR 01;34 # directory 16 | LINK target 17 | SOCK 01;35 # socket 18 | MISSING 00 19 | SETUID 37;41 20 | SETGID 30;43 21 | CAPABILITY 30;41 22 | 23 | 24 | *README 38;5;220;1 25 | *README.rst 38;5;220;1 26 | *LICENSE 38;5;220;1 27 | *COPYING 38;5;220;1 28 | *INSTALL 38;5;220;1 29 | *COPYRIGHT 38;5;220;1 30 | *AUTHORS 38;5;220;1 31 | *HISTORY 38;5;220;1 32 | *CONTRIBUTORS 38;5;220;1 33 | *PATENTS 38;5;220;1 34 | *VERSION 38;5;220;1 35 | *NOTICE 38;5;220;1 36 | *CHANGES 38;5;220;1 37 | 38 | 39 | .log 38;5;190 40 | .txt 38;5;253 41 | 42 | # markup {{{2 43 | .info 38;5;184 44 | .markdown 38;5;184 45 | .md 38;5;184 46 | .mmd 38;5;184 47 | 48 | # docs, images 49 | 50 | .chm 38;5;151 51 | .djvu 38;5;141 52 | .pdf 38;5;141 53 | .PDF 38;5;141 54 | .epub 38;5;131 55 | .doc 38;5;111 56 | .docx 38;5;111 57 | .eps 38;5;111 58 | .ps 38;5;111 59 | .rtf 38;5;111 60 | .pps 38;5;166 61 | .ppt 38;5;166 62 | .pptx 38;5;166 63 | .xls 38;5;112 64 | .xlsx 38;5;112 65 | .xltx 38;5;73 66 | .jpeg 38;5;87 67 | .JPG 38;5;87 68 | .jpg 38;5;87 69 | 70 | 71 | # version control {{{2 72 | .git 38;5;197 73 | .gitignore 38;5;240 74 | .gitattributes 38;5;240 75 | .gitmodules 38;5;240 76 | 77 | # shell {{{2 78 | .awk 38;5;170 79 | .bash 38;5;171 80 | .sh 38;5;172 81 | .vim 38;5;173 82 | *conf 38;5;174 83 | *rc 38;5;175 84 | .login 38;5;176 85 | .logout 38;5;177 86 | .zsh 38;5;180 87 | 88 | 89 | # python 90 | .py 38;5;41 91 | 92 | # perl 93 | .pl 38;5;208 94 | .PL 38;5;160 95 | 96 | # SQL 97 | .msql 38;5;222 98 | .mysql 38;5;222 99 | .pgsql 38;5;222 100 | .sql 38;5;222 101 | .sqlite 38;5;60 102 | 103 | # Python 104 | .py 38;5;41 105 | .pyc 38;5;240 106 | 107 | # Web 108 | .js 38;5;074 109 | .css 38;5;125 110 | .less 38;5;125 111 | .sass 38;5;125 112 | .scss 38;5;125 113 | .htm 38;5;125 114 | .html 38;5;125 115 | .json 38;5;178 116 | .xml 38;5;178 117 | .yml 38;5;178 118 | .php 38;5;81 119 | .coffee 38;5;074 120 | .htaccess 38;5;230 121 | 122 | # CakePHP view scripts and helpers 123 | .ctp 38;5;81 124 | # Twig template engine 125 | .twig 38;5;81 126 | 127 | 128 | # JAVA 129 | .java 38;5;074 130 | .jsp 38;5;074 131 | 132 | # Build stuff {{{2 133 | *Dockerfile 38;5;155 134 | .dockerignore 38;5;240 135 | *Makefile 38;5;155 136 | *Makefile 38;5;155 137 | *MANIFEST 38;5;243 138 | 139 | # packaged apps {{{2 140 | .apk 38;5;215 141 | .jad 38;5;215 142 | .jar 38;5;215 143 | 144 | # partition images {{{2 145 | .dmg 38;5;124 146 | .sparseimage 38;5;124 147 | .dmg 38;5;215 148 | 149 | 150 | # state files 151 | .pid 38;5;248 152 | .state 38;5;248 153 | *lockfile 38;5;248 154 | .lock 38;5;241 155 | *composer.lock 38;5;96 156 | *lock.json 38;5;96 157 | *components* 38;5;241 158 | 159 | # state dumps 160 | .dump 38;5;241 161 | .stackdump 38;5;241 162 | .zcompdump 38;5;241 163 | .zwc 38;5;241 164 | 165 | # macOS 166 | .DS_Store 38;5;239 167 | .localized 38;5;239 168 | .CFUserTextEncoding 38;5;239 169 | 170 | .md5 38;5;116 171 | .properties 38;5;116 172 | .torrent 38;5;116 173 | 174 | # RStudio project file 175 | .Rproj 38;5;11 176 | 177 | # archives {{{1 178 | .7z 38;5;210 179 | .bz2 38;5;210 180 | .gz 38;5;210 181 | .lzma 38;5;210 182 | .rar 38;5;210 183 | .tar 38;5;210 184 | .tgz 38;5;210 185 | .zip 38;5;210 186 | 187 | 188 | # 0 = default colour 189 | # 1 = bold 190 | # 4 = underlined 191 | # 5 = flashing text 192 | # 6 = no change 193 | # 7 = reverse field 194 | # 8 = black 195 | # 9 = strikethrough (cool!) 196 | # 10 - 29= no change 197 | # 30 = light green 198 | # 31 = red 199 | # 32 = green 200 | # 33 = orange 201 | # 34 = blue 202 | # 35 = purple 203 | # 36 = cyan 204 | # 37 = grey 205 | # 38 = underline 206 | # 39 = no change 207 | # 40 = black background 208 | # 41 = red background 209 | # 42 = green background 210 | # 43 = orange background 211 | # 44 = blue background 212 | # 45 = purple background 213 | # 46 = cyan background 214 | # 47 = grey background 215 | # 90 = dark grey 216 | # 91 = light red 217 | # 92 = light green 218 | # 93 = yellow 219 | # 94 = light blue 220 | # 95 = light purple 221 | # 96 = turquoise 222 | # 100 = dark grey background 223 | # 101 = light red background 224 | # 102 = light green background 225 | # 103 = yellow background 226 | # 104 = light blue background 227 | # 105 = light purple background 228 | # 106 = turquoise background 229 | -------------------------------------------------------------------------------- /lib/history.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | #----------------------------------------------------- 6 | # ZSH HISTORY 7 | # 8 | export HISTFILE=${HOME}/.history 9 | export HISTSIZE=100000 10 | export SAVEHIST=$HISTSIZE 11 | # 12 | setopt EXTENDED_HISTORY # write in the ":start:elapsed;command" format 13 | setopt HIST_EXPIRE_DUPS_FIRST # allow dups, but expire old ones when exceeding HISTSIZE 14 | setopt HIST_FIND_NO_DUPS # do not find duplicates in history 15 | setopt HIST_IGNORE_ALL_DUPS # ignore duplicate commands 16 | setopt HIST_IGNORE_DUPS # ignore duplicate commands 17 | setopt HIST_IGNORE_SPACE # ignore entries starting with a space 18 | setopt HIST_REDUCE_BLANKS # leave blanks out 19 | setopt HIST_SAVE_NO_DUPS # do not save duplicates 20 | setopt INC_APPEND_HISTORY # write after each command 21 | setopt SHARE_HISTORY # share history between sessions 22 | -------------------------------------------------------------------------------- /lib/keybindings.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | #----------------------------------------------------- 6 | # Set VIM mode 7 | # e.g. https://dougblack.io/words/zsh-vi-mode.html 8 | # Key code table: https://www.zsh.org/mla/users/2014/msg00266.html 9 | # 10 | # vim mode keybindings 11 | bindkey -v 12 | # 13 | bindkey '^P' up-history # ctrl-p 14 | bindkey '^N' down-history # ctrl-n 15 | bindkey -M viins '^p' up-line-or-history 16 | bindkey -M viins '^n' down-line-or-history 17 | 18 | # backspace and ^h working even after 19 | # returning from command mode 20 | bindkey '^?' backward-delete-char # backspace 21 | bindkey '^h' backward-delete-char # ctrl-h 22 | bindkey '^w' backward-kill-word # ctrl-w 23 | bindkey -M viins '^h' backward-delete-char 24 | bindkey -M viins '^w' backward-kill-word 25 | bindkey -M viins '^u' backward-kill-line 26 | 27 | # search history 28 | bindkey -M viins '^r' history-incremental-pattern-search-backward 29 | bindkey -M viins '^s' history-incremental-pattern-search-forward 30 | 31 | bindkey "^[[3~" delete-char 32 | bindkey "^K" kill-whole-line # ctrl-k 33 | bindkey "^A" beginning-of-line # ctrl-a 34 | bindkey "^E" end-of-line # ctrl-e 35 | bindkey "^D" delete-char # ctrl-d 36 | #bindkey "^F" forward-char # ctrl-f 37 | bindkey "^F" forward-word # ctrl-f 38 | #bindkey "^B" backward-char # ctrl-b 39 | bindkey "^B" backward-word # ctrl-b 40 | 41 | bindkey -M viins '^a' beginning-of-line 42 | bindkey -M viins '^e' end-of-line 43 | bindkey -M viins '^k' kill-line 44 | 45 | bindkey -M viins '^y' yank 46 | bindkey -M viins '^_' undo 47 | bindkey -M viins '^x^r' redisplay 48 | #bindkey -M viins '\eOH' beginning-of-line # Home 49 | #bindkey -M viins '\eOF' end-of-line # End 50 | #bindkey -M viins '\e[2~' overwrite-mode # Insert 51 | #bindkey -M viins '\ef' forward-word # Alt-f 52 | #bindkey -M viins '\eb' backward-word # Alt-b 53 | #bindkey -M viins '\ed' kill-word # Alt-d 54 | #bindkey -M vicmd '/' vi-history-search-forward 55 | #bindkey -M vicmd '?' vi-history-search-backward 56 | #bindkey -M vicmd '\e[5~' history-beginning-search-backward # PageUp 57 | #bindkey -M vicmd '\e[6~' history-beginning-search-forward # PageDown 58 | 59 | 60 | #----------------------------------------------------- 61 | # https://github.com/zsh-users/zsh-history-substring-search 62 | bindkey '^[[A' history-substring-search-up 63 | bindkey '^[[B' history-substring-search-down 64 | bindkey "^R" history-incremental-search-backward # ctrl-r 65 | bindkey "[B" history-search-forward # down arrow 66 | bindkey "[A" history-search-backward # up arrow 67 | -------------------------------------------------------------------------------- /lib/ls_color.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | #----------------------------------------------------- 6 | # Add colors to ls command 7 | if [ -f "/usr/local/bin/gdircolors" ] || [ -f "/usr/bin/gdircolors" ]; then 8 | eval $( gdircolors -b ${ZSHCONFIG}/lib/dircolors-custom ) 9 | fi 10 | -------------------------------------------------------------------------------- /lib/macos.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | # 6 | # Define common system-wide configurations 7 | 8 | # GNU ls aliases 9 | # 10 | # For macOS where GNU ls is installed via homebrew as `gls` 11 | case $SYSTEM in 12 | Darwin) 13 | alias ls='/usr/local/bin/gls --color=auto' 14 | ;; 15 | Linux) 16 | alias ls='ls --color=auto' 17 | ;; 18 | esac 19 | # 20 | alias ll='ls -lFh' # long (-l), types classify (-F),human readable (-h) 21 | alias l='ll' 22 | alias ls.all='ls -lAFh' # long list, show almost all 23 | alias ls.sort.time='ls -tlFh' 24 | alias ls.sort.size='ls -SlFh' 25 | alias ls.dot='ls -ld .*' # show dot files, list dirs non-recursively (-d) 26 | alias ls.recursive='ls -R' 27 | alias ls.id='ls -nFh' # show numeric FID and GID (-n) 28 | 29 | # diff 30 | alias diff='colordiff' 31 | 32 | # change dir 33 | alias ..='cd ..' 34 | alias ...='cd ../..' 35 | alias ....='cd ../../../..' 36 | 37 | alias df='df -h' 38 | 39 | # 40 | # Pipe Aliases 41 | # 42 | alias grep='egrep --color=auto ' 43 | alias egrep='egrep --color=auto ' 44 | alias L=' | less ' 45 | alias G=' | egrep --color=auto ' 46 | alias T=' | tail ' 47 | alias H=' | head ' 48 | alias W=' | wc -l ' 49 | alias S=' | sort ' 50 | 51 | function handle-multi-arguments(){ 52 | if [ ! "$#" -gt 1 ] ; then 53 | echo "Usage: $0 file1 file2 ..." >&2 54 | return -1 55 | fi 56 | for file in $@; do 57 | if [ -f $file ] ; then 58 | echo -n $file 59 | fi 60 | done 61 | echo 'Done!' 62 | } 63 | 64 | # macOS specific 65 | # 66 | # Check if running on macOS, otherwise stop here 67 | [[ ! "x$SYSTEM" == "xDarwin" ]] && return 68 | 69 | # /etc/zprofile is loaded and invokes 70 | # /usr/libexec/path_helper that might slow down start-up. 71 | # Better enter directly the content of /etc/paths.d here 72 | 73 | # /etc/paths.d/40-XQuartz 74 | export PATH=$PATH:/opt/X11/bin 75 | 76 | # /etc/paths.d/MacGPG2 77 | export PATH=$PATH:/usr/local/MacGPG2/bin 78 | 79 | # 80 | # GNU Core Utils 81 | # brew info coreutils 82 | export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH 83 | 84 | # scutil 85 | # 86 | alias sys.get.computername='scutil --get ComputerName' 87 | alias sys.get.localhostname='scutil --get LocalHostName' 88 | alias sys.get.hostname='scutil --get HostName' 89 | alias sys.get.dns='scutil --dns' 90 | alias sys.get.proxy='scutil --proxy' 91 | alias sys.get.network.interface='scutil --nwi' 92 | 93 | # 94 | alias sys.uti.file='mdls -name kMDItemContentTypeTree ' 95 | 96 | alias lsregister='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' 97 | # 98 | # OS X's launchctl 99 | # 100 | alias launch.list='launchctl list ' 101 | alias launch.load='launchctl load ' 102 | alias launch.unload='launchctl unload ' 103 | alias launch.getenv='launchctl getenv ' 104 | alias launch.start='launchctl start ' 105 | alias launch.stop='launchctl stop ' 106 | 107 | # 108 | # Spotlight / Meta-data indexing (MDS) 109 | # 110 | # https://apple.stackexchange.com/q/87090/7647 111 | # https://apple.stackexchange.com/q/63178/7647 112 | # 113 | alias spotlight.exclusion.show='sudo defaults read /.Spotlight-V100/VolumeConfiguration.plist Exclusions' 114 | alias spotlight.exclusion.add='sudo defaults write /.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add ' 115 | 116 | alias spotlight.indexing.stop='sudo launchctl stop com.apple.metadata.mds' 117 | alias spotlight.indexing.start='sudo launchctl start com.apple.metadata.md' 118 | alias spotlight.indexing.restart='spotlight.indexing.stop && spotlight.indexing.start' 119 | 120 | alias sys.pkg.list='pkgutil --pkgs' 121 | 122 | # show CPU info 123 | alias sys.cpu='sysctl -n machdep.cpu.brand_string' 124 | 125 | -------------------------------------------------------------------------------- /lib/ubuntu.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | [[ ! "x$SYSTEM" = "xLinux" ]] && return 6 | 7 | if [[ -s '/etc/zsh_command_not_found' ]]; then 8 | source '/etc/zsh_command_not_found' 9 | fi 10 | 11 | -------------------------------------------------------------------------------- /lib/z-custom.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | #----------------------------------------------------- 6 | # Disable the built-in command `r` for R to work 7 | # 8 | disable r 9 | 10 | #----------------------------------------------------- 11 | # https://goo.gl/M3zjNU 12 | # activate autocd to allow change to a dir via its name 13 | setopt auto_cd # Auto changes to a directory without typing cd. 14 | setopt auto_pushd # Push the old directory onto the stack on cd. 15 | setopt pushd_ignore_dups # Do not store duplicates in the stack. 16 | setopt pushd_silent # Do not print the directory stack after pushd or popd. 17 | setopt pushd_to_home # Push to home directory when no argument is given. 18 | setopt cdable_vars # Change directory to a path stored in a variable. 19 | setopt auto_name_dirs # Auto add variable-stored paths to ~ list. 20 | setopt multios # Write to multiple descriptors. 21 | setopt extended_glob # Use extended globbing syntax. 22 | #unsetopt clobber # Do not overwrite existing files with > and >> 23 | # Use >! and >>! to bypass. 24 | setopt clobber # turn off warning "file exists" with > and >> 25 | 26 | #----------------------------------------------------- 27 | # Automatically expanding zsh global aliases 28 | # https://goo.gl/fJbtmJ 29 | # 30 | globalias() { 31 | if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then 32 | zle _expand_alias 33 | zle expand-word 34 | fi 35 | zle self-insert 36 | } 37 | 38 | zle -N globalias 39 | bindkey " " globalias 40 | bindkey "^ " magic-space # control-space to bypass completion 41 | bindkey -M isearch " " magic-space # normal space during searches 42 | -------------------------------------------------------------------------------- /zi-init.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=sh 3 | # vim:filetype=sh 4 | 5 | ## 6 | # ZSH plugins managed by Zi 7 | # https://github.com/z-shell/zi 8 | # https://wiki.zshell.dev/ 9 | # https://wiki.zshell.dev/docs/getting_started/overview 10 | ## 11 | 12 | zi ice wait"0" atload"_zsh_autosuggest_start" lucid 13 | zi light zsh-users/zsh-autosuggestions 14 | 15 | zi ice wait"0" lucid 16 | zi light zsh-users/zsh-completions 17 | 18 | zi ice wait"0" atinit"zpcompinit; zpcdreplay" lucid 19 | zi light zdharma-continuum/fast-syntax-highlighting 20 | 21 | zi from"gh-r" as"program" mv"direnv* -> direnv" \ 22 | atclone'./direnv hook zsh > zhook.zsh' atpull'%atclone' \ 23 | pick"direnv" src="zhook.zsh" for \ 24 | direnv/direnv 25 | 26 | zi light zsh-users/zsh-history-substring-search 27 | 28 | zi ice wait"0" lucid 29 | zi load htr3n/history-search-multi-word 30 | 31 | zi ice from"gh-r" as"program" 32 | zi light junegunn/fzf 33 | 34 | # Load the pure theme, with zsh-async library that's bundled with it 35 | zi ice pick"async.zsh" src"pure.zsh" 36 | zi light sindresorhus/pure 37 | 38 | zi ice as"completion" lucid 39 | zi snippet https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker 40 | 41 | # https://github.com/laggardkernel/git-ignore 42 | zi ice pick'init.zsh' blockf 43 | zi light laggardkernel/git-ignore 44 | alias gi="git-ignore" 45 | -------------------------------------------------------------------------------- /zlogin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # Execute code in the background to not affect the current session 6 | ( 7 | # 8 | setopt LOCAL_OPTIONS EXTENDED_GLOB 9 | autoload -U zrecompile 10 | local ZSHCONFIG=~/.zsh-config 11 | 12 | # Compile zcompdump, if modified, to increase startup speed. 13 | zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" 14 | if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then 15 | zrecompile -pq "$zcompdump" 16 | fi 17 | # zcompile .zshrc 18 | zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc 19 | zrecompile -pq ${ZDOTDIR:-${HOME}}/.zprofile 20 | zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshenv 21 | # recompile all zsh or sh 22 | for f in $ZSHCONFIG/**/*.*sh 23 | do 24 | zrecompile -pq $f 25 | done 26 | ) &! 27 | -------------------------------------------------------------------------------- /zprofile: -------------------------------------------------------------------------------- 1 | # vim:syntax=zsh 2 | # vim:filetype=zsh 3 | 4 | # 5 | # Executes commands at login before zshrc. 6 | # 7 | if [[ -z "$LANG" ]]; then 8 | export LANG='en_US.UTF-8' 9 | export LANGUAGE=en_US.UTF-8 10 | fi 11 | 12 | export LC_COLLATE=en_US.UTF-8 13 | export LC_CTYPE=en_US.UTF-8 14 | export LC_MESSAGES=en_US.UTF-8 15 | export LC_MONETARY=en_US.UTF-8 16 | export LC_NUMERIC=en_US.UTF-8 17 | export LC_TIME=en_US.UTF-8 18 | export LC_ALL=en_US.UTF-8 19 | export LESSCHARSET=utf-8 20 | 21 | # eliminates duplicates in *paths 22 | typeset -gU cdpath fpath path 23 | 24 | # Zsh search path for executable 25 | path=( 26 | /usr/local/{bin,sbin} 27 | $path 28 | ) 29 | -------------------------------------------------------------------------------- /zsh-performance.md: -------------------------------------------------------------------------------- 1 | # ZSH Performance References 2 | 3 | * 4 | * 5 | * 6 | * 7 | * 8 | -------------------------------------------------------------------------------- /zshenv: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # https://blog.patshead.com/2011/04/improve-your-oh-my-zsh-startup-time-maybe.html 6 | skip_global_compinit=1 7 | 8 | # http://disq.us/p/f55b78 9 | setopt noglobalrcs 10 | 11 | export SYSTEM=$(uname -s) 12 | 13 | # https://github.com/sorin-ionescu/prezto/blob/master/runcoms/zshenv 14 | # Ensure that a non-login, non-interactive shell has a defined environment. 15 | if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then 16 | source "${ZDOTDIR:-$HOME}/.zprofile" 17 | fi 18 | 19 | # Home-made scripts 20 | export PATH=$PATH:${HOME}/.bin 21 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # vim:syntax=zsh 3 | # vim:filetype=zsh 4 | 5 | # for profiling zsh 6 | # https://unix.stackexchange.com/a/329719/27109 7 | # 8 | #zmodload zsh/zprof 9 | 10 | export SCRIPTS=${HOME}/scripts 11 | 12 | export ZSHCONFIG=${ZDOTDIR:-$HOME}/.zsh-config 13 | 14 | ZSH_INIT=${ZSHCONFIG}/_init.sh 15 | 16 | if [[ -s ${ZSH_INIT} ]]; then 17 | source ${ZSH_INIT} 18 | else 19 | echo "Could not find the init script ${ZSH_INIT}" 20 | fi 21 | 22 | # 23 | # https://gist.github.com/ctechols/ca1035271ad134841284 24 | # https://carlosbecker.com/posts/speeding-up-zsh 25 | # 26 | autoload -Uz compinit 27 | 28 | case $SYSTEM in 29 | Darwin) 30 | if [ $(date +'%j') != $(/usr/bin/stat -f '%Sm' -t '%j' ${ZDOTDIR:-$HOME}/.zcompdump) ]; then 31 | compinit; 32 | else 33 | compinit -C; 34 | fi 35 | ;; 36 | Linux) 37 | # not yet match GNU & BSD stat 38 | ;; 39 | esac 40 | 41 | # see zplugin-init.zsh with Turbo Mode 42 | #[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 43 | 44 | # https://direnv.net/ 45 | # see zplugin-init.zsh 46 | # https://github.com/zdharma/zplugin/wiki/Direnv-explanation 47 | #eval "$(direnv hook zsh)" 48 | 49 | 50 | # Private script here 51 | if [ -d ~/.private ]; then 52 | for f in ~/.private/*sh; do 53 | source "$f" 54 | done 55 | fi 56 | --------------------------------------------------------------------------------