├── .antigenrc ├── .gitignore ├── .zshrc ├── README.md ├── alias ├── aliases.sh ├── aliases.work.sh └── git.sh ├── bootstrap.zsh ├── env └── lib └── functions.zsh /.antigenrc: -------------------------------------------------------------------------------- 1 | antigen use oh-my-zsh 2 | 3 | # Bundles 4 | antigen bundles < /dev/null; then 13 | eval "$(dircolors -b)" 14 | zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 15 | else 16 | export CLICOLOR=1 17 | zstyle ':completion:*:default' list-colors '' 18 | fi 19 | 20 | zstyle ':completion:*' auto-description 'specify: %d' 21 | zstyle ':completion:*' completer _expand _complete _correct _approximate 22 | zstyle ':completion:*' group-name '' 23 | 24 | zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s 25 | zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' 26 | zstyle ':completion:*' select-prompt '' 27 | zstyle ':completion:*' use-compctl false 28 | zstyle ':completion:*' verbose true 29 | 30 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' 31 | zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' 32 | 33 | # Fix default zstyle for tab completion 34 | zstyle ':completion:*' format '' 35 | zstyle ':completion:*:*' menu select long 36 | 37 | zstyle ':completion:*' accept-exact '*(N)' 38 | zstyle ':completion:*' use-cache on 39 | zstyle ':completion:*' cache-path $HOME/.zshrc.d/ 40 | 41 | ZSH_CUSTOM=${ZSH_CUSTOM:-$HOME/.zshrc.d} 42 | source $ZSH_CUSTOM/bootstrap.zsh 43 | 44 | # Ctrl+E edit commmand line vim 45 | export GPG_TTY=`tty` 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .zshrc 2 | 3 | Repository to save my custom Zsh settings and themes. 4 | 5 | ## Install 6 | 7 | * Install [Antigen](https://github.com/zsh-users/antigen) in `$HOME/.antigen`: 8 | 9 | git clone https://github.com/zsh-users/antigen.git $HOME/.antigen 10 | 11 | * Clone this repo in `$HOME/.zshrc.d`: 12 | 13 | git clone https://github.com/desyncr/zshrc.git $HOME/.zshrc.d 14 | 15 | * Configure it into your `$HOME/.zshrc`: 16 | 17 | echo "export ZSH_CUSTOM=$HOME/.zshrc.d" >> $HOME/.zshrc 18 | echo "source \$ZSH_CUSTOM/bootstrap.zsh" >> $HOME/.zshrc # load configuration 19 | 20 | # Or you could use my own .zshrc at $HOME/.zshrc.d/.zshrc 21 | 22 | * Restart Zsh and done! 23 | 24 | 25 | ## Configure 26 | 27 | Check ``bootstrap.zsh`` for examples and default configuration. 28 | 29 | 30 | ## Customize 31 | 32 | ``bootstrap.zsh`` is responsible for loading any custom script such as ``functions.sh``, 33 | ``aliases.sh`` and any custom library. 34 | 35 | The files ``functions.sh`` and ``aliases.sh`` holds any custom function and aliases 36 | respectably. 37 | 38 | Custom themes are located at ``themes`` directory . Custom libraries are located at ``lib`` 39 | directory. 40 | 41 | 42 | ## Feedback 43 | 44 | If you'd like to contribute to the project or file a bug or feature request, please visit 45 | [the project page][1]. 46 | 47 | 48 | ## License 49 | 50 | The project is licensed under the [GNU GPL v3][2] license. 51 | 52 | [1]: https://github.com/desyncr/zshrc/ 53 | [2]: http://www.gnu.org/licenses/gpl.html 54 | -------------------------------------------------------------------------------- /alias/aliases.sh: -------------------------------------------------------------------------------- 1 | # shortcuts 2 | alias c=clear 3 | alias df="df -h " 4 | #alias pwgen="< /dev/urandom tr -dc 'A-Za-z0-9\\?!=-_' | head -c13" 5 | alias du='du -hd1|sort -h' 6 | 7 | alias pingo="while [[ $? ]]; do ping 8.8.8.8; sleep 1; done" 8 | #alias p="ping 8.8.8.8" 9 | 10 | # safe-rm if available 11 | if (( $+commands[safe-rm] )); then 12 | alias rm='safe-rm' 13 | else 14 | alias rm='rm -i' 15 | fi 16 | 17 | # if pbcopy is not available 18 | if ! which pbcopy &>/dev/null && which xsel &>/dev/null; then 19 | alias pbcopy='xsel --clipboard --input' 20 | alias pbpaste='xsel --clipboard --output' 21 | fi 22 | 23 | case $(uname) in 24 | Linux) 25 | alias open=nautilus 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /alias/aliases.work.sh: -------------------------------------------------------------------------------- 1 | alias phpstorm-reset='bash ~/sys-vagrant/code/phpstorm-reset.sh' 2 | 3 | alias vp='vagrant up' 4 | alias down='vagrant halt' 5 | alias restart='vagrant halt && vagrant up' 6 | alias web='vagrant ssh web' 7 | alias vagrant-restart='vagrant halt && vagrant up' 8 | 9 | alias exads-tail='vagrant ssh web -c "sudo -i tail -f /var/log/php/error.log"' 10 | alias exads-memcache-restart='vagrant ssh web -c "sudo /bin/systemctl restart memcached.service"' 11 | alias exads-cc='vagrant ssh web -c "sudo -u exads -i php /var/www/jobs/campaigns-caching-v3.php --network=exads.rocks --debug"' 12 | alias exads-ccp='vagrant ssh web -c "sudo -u exads -i php /var/www/jobs/campaigns-caching-v3-push.php --XXX --network=exads.rocks --network-hash=e738bad9 --debug"' 13 | 14 | alias exads-my='vagrant ssh dbm -c "sudo mysql exads -pexads"' 15 | 16 | alias vim='/usr/local/bin/vim' 17 | -------------------------------------------------------------------------------- /alias/git.sh: -------------------------------------------------------------------------------- 1 | alias gs="git status" 2 | alias gc="git commit" 3 | alias gd="git icdiff" 4 | alias up="git pull" 5 | -------------------------------------------------------------------------------- /bootstrap.zsh: -------------------------------------------------------------------------------- 1 | # Load zsh custom sources 2 | source $ZSH_CUSTOM/lib/functions.zsh 3 | 4 | # Load all environment variables 5 | source "$ZSH_CUSTOM/env" 6 | 7 | # Load antigen and bootstrap the configuration 8 | source $ANTIGEN/antigen.zsh 9 | antigen init $ZSH_CUSTOM/.antigenrc 10 | 11 | # Finally set up aliases and key bindings 12 | load "$ZSH_CUSTOM/alias/.*.sh" 13 | -------------------------------------------------------------------------------- /env: -------------------------------------------------------------------------------- 1 | export LC_ALL=en_US.UTF-8 2 | export LANG=en_US.UTF-8 3 | 4 | # Configure vim as default editor 5 | export GIT_EDITOR=vim 6 | export VISUAL=vim 7 | export EDITOR=vim 8 | 9 | # Set up antigen path 10 | ANTIGEN=${ANTIGEN:-"$HOME/.antigen"} 11 | 12 | # Custom configuration 13 | export HISTORY_BASE=~/.config/directory_history 14 | #export IFS=$'\n' 15 | 16 | # Remove this annoyance 17 | setopt NO_BEEP 18 | 19 | # Use fzf where available, otherwise fallback to zsh-select, selecta, etc 20 | CTRLP_FUZZER_COMMAND='fzf' 21 | zstyle ':completion:*' format $'Completing %d\n' 22 | 23 | export TERM="xterm-256color" 24 | export PATH=$PATH:/usr/local/bin 25 | 26 | # https://github.com/bhilburn/powerlevel9k/issues/420 27 | export ZLE_RPROMPT_INDENT=0 28 | 29 | export PATH="/usr/local/opt/php@7.4/bin:$PATH" 30 | export PATH="/usr/local/opt/php@7.4/sbin:$PATH" 31 | 32 | export GOPATH=$HOME/go 33 | export GOROOT="/usr/local/opt/go/libexec" 34 | export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin" 35 | 36 | export HISTCONTROL=erasedups:ignorespace 37 | export ZSH_FZF_HISTORY_SEARCH_REMOVE_DUPLICATES='true' 38 | -------------------------------------------------------------------------------- /lib/functions.zsh: -------------------------------------------------------------------------------- 1 | # displays command history sorted by usage 2 | tophistory() { 3 | history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head -n 30 4 | } 5 | 6 | # search keyword [path] 7 | search() { 8 | arg=() 9 | if [ ! -z "$2" ]; then 10 | arg+=(-name $1) 11 | pattern=$2 12 | else 13 | pattern=$1 14 | fi 15 | 16 | /usr/bin/find ${arg[@]} -type f -exec grep -Hin1 "$pattern" {} \; 17 | } 18 | 19 | # upto user@example.com example.zip ['~'] 20 | # upto staging example.zip ['~'] 21 | # rsync -v example.zip user@example.com:~ 22 | upto() { 23 | ssh=$1 24 | local_file=$2 25 | remote_path='~' 26 | if [ ! -z "$3" ]; then 27 | remote_path="$3" 28 | fi 29 | rsync -v $local_file $ssh:$remote_path 30 | } 31 | 32 | # dlfrom user@example.com /tmp/files.tar ['.'] 33 | # rsync -v user@example.com:/tmp/files.tar . 34 | dlfrom () { 35 | ssh=$1 36 | remote_file=$2 37 | local_path='.' 38 | if [ ! -z "$3" ]; then 39 | local_path="$3" 40 | fi 41 | rsync -v $ssh:$remote_file $local_path 42 | } 43 | 44 | # sources a given set of files 45 | # usage: 46 | # load file|regexp 47 | # example: 48 | # load "$HOME/.zshrc.d/*.zsh-plugin" 49 | # load "$HOME/.env*.sh" "$HOME/.zshrc.d/*.alias.zsh" 50 | load() { 51 | local root 52 | for regexp in $*; do 53 | root=$(dirname "$regexp") 54 | for f in $(find "$root" -print | grep "$regexp" | sort); do 55 | source "$f" 56 | done 57 | done 58 | } 59 | 60 | # list and filter processes 61 | # usage: 62 | # psg regexp [--kill] 63 | # example: 64 | # psg 65 | # psg vim --kill 66 | # use --kill to kill listed processes 67 | psg() { 68 | regexp="$@" 69 | kill=0 70 | for p in $@; do 71 | case $p in 72 | '--kill') 73 | kill=1 74 | regexp=$(echo $regexp | sed 's/--kill//g') 75 | ;; 76 | esac 77 | done 78 | 79 | psargs='%p %a' 80 | if [ $(uname) = "Darwin" ]; then 81 | psargs='pid args' 82 | fi 83 | if [ $kill -eq 0 ]; then 84 | ps axo $psargs | grep -v grep | grep "$regexp" 85 | else 86 | for pid in $(ps axo $psargs | grep -v grep | grep "$regexp" | sed 's/^ //g' | cut -d' ' -f1); do 87 | kill $pid 88 | done 89 | fi 90 | } 91 | 92 | ctrlf () { 93 | local tmp 94 | vared -p 'What would you like to find?: ' tmp 95 | find . -type file -print | xargs grep -i --color=auto $tmp 96 | } 97 | 98 | if [[ "$_ENABLE_MARK" == true ]]; then 99 | zmodload zsh/datetime 100 | _ZSH_TIME_MARK=$EPOCHREALTIME 101 | mark() { 102 | (( res=$EPOCHREALTIME-$_ZSH_TIME_MARK )) 103 | _ZSH_TIME_MARK=$EPOCHREALTIME 104 | echo $res $* 105 | } 106 | else 107 | mark() {} 108 | fi 109 | --------------------------------------------------------------------------------