dotfiles

feels like ${HOME}
Log | Files | Refs | README

.zshrc (8960B)


      1 ########################################################################
      2 #                     EXPORTS
      3 ########################################################################
      4 
      5 export EDITOR=nvim
      6 export SHELL=zsh
      7 export LANG=en_US.UTF-8
      8 export TERM=screen-256color
      9 
     10 export PATH=$HOME/bin:/usr/local/bin:$PATH
     11 export PATH="/usr/local/sbin:$PATH"
     12 # export PATH=$HOME/.local/bin:$PATH
     13 
     14 export PATH=$PATH:$HOME/go/bin
     15 export PATH=$PATH:$HOME/.cargo/bin
     16 # export PATH=$PATH:/usr/local/bin
     17 export PATH=/.config/yarn/global/node_modules/.bin:$PATH./node_modules/.bin:$HOME/.yarn/bin:$HOME
     18 export PATH=/usr/local/opt/openssl/bin:$PATH
     19 export PATH=$PATH:$KUMPATH/yowez-cli/bin
     20 export GOPATH=$HOME/go
     21 export PATH=$GOPATH/bin:$PATH
     22 export PATH=$HOME/.nimble/bin:$PATH
     23 export PATH="/Applications/Emacs.app/Contents/MacOS:$PATH"
     24 export PATH="$HOME/.emacs.d/bin:$PATH"
     25 # export INITVIM=$HOME/.config/nvim/init.vim
     26 # export PATH=$HOME/bin:$PATH
     27 
     28 export BAT_THEME="gruvbox-light"
     29 
     30 export ANDROID_HOME=${HOME}/Library/Android/sdk
     31 export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
     32 export PATH=${PATH}:${ANDROID_HOME}/emulator
     33 export PATH=${PATH}:${ANDROID_HOME}/tool
     34 export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
     35 
     36 export SCRIPT=~/Library/Mobile\ Documents/com\~apple\~ScriptEditor2/Documents
     37 
     38 ########################################################################
     39 #                     FUNCTIONS
     40 ########################################################################
     41 
     42 # retry command after n times
     43 function gagal {
     44   echo $1 >&2
     45   exit 1
     46 }
     47 function kantal {
     48   local n=1
     49   local max="$1"; shift
     50   local delay=3
     51   while true; do
     52     "$@" && break || {
     53       if [[ $n -lt $max ]]; then
     54         ((n++))
     55         echo "Gagal nih. OTW percobaan ke $n/$max:"
     56         sleep $delay;
     57       else
     58         gagal "Gagal muluk abis $n kali coba."
     59       fi
     60     }
     61   done
     62 }
     63 
     64 # test
     65 function test_kantal {
     66   echo "your first argument $1"
     67   echo "your @ argument $@"
     68   echo "your 0 argument $0"
     69   local first="$1"; shift
     70   echo "now your first argument $1"
     71   echo "now your @ argument $@"
     72 }
     73 
     74 function tempjson {
     75   nvim ~/tempjson$1.json
     76 }
     77 
     78 function commit {
     79   git add . && git commit -m "$1"
     80 }
     81 
     82 n ()
     83 {
     84     # Block nesting of nnn in subshells
     85     if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
     86         echo "nnn is already running"
     87         return
     88     fi
     89 
     90     # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
     91     # To cd on quit only on ^G, remove the "export" as in:
     92     #     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
     93     # NOTE: NNN_TMPFILE is fixed, should not be modified
     94     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
     95 
     96     # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
     97     # stty start undef
     98     # stty stop undef
     99     # stty lwrap undef
    100     # stty lnext undef
    101 
    102     nnn -deo "$@"
    103 
    104     if [ -f "$NNN_TMPFILE" ]; then
    105             . "$NNN_TMPFILE"
    106             rm -f "$NNN_TMPFILE" > /dev/null
    107     fi
    108 }
    109 
    110 export NNN_USE_EDITOR=1
    111 export NNN_TRASH=1
    112 [ -n "$NNNLVL" ] && PS1="N$NNNLVL $PS1"
    113 
    114 
    115 ########################################################################
    116 #                     ALIASES
    117 ########################################################################
    118 
    119 eval "$(hub alias -s)"
    120 
    121 # projects
    122 alias kapp="cd ${KUMPATH}/app"
    123 alias kweb="cd ${KUMPATH}/web"
    124 alias kmag="cd ${KUMPATH}/dashboard"
    125 alias kwid="cd ${KUMPATH}/widget"
    126 alias kfer="cd ${KUMPATH}/ferdi"
    127 alias uikit="cd ${KUMPATH}/js/packages/kumparan-uikit"
    128 alias slatep="cd ${KUMPATH}/js/packages/slate-plugins"
    129 alias ktrack="cd ${KUMPATH}/js/packages/kumparan-tracker"
    130 alias ybbond="cd ${YBPATH}/ybbond"
    131 alias ybbold="cd ${YBPATH}/old-ybbond"
    132 alias ybreason="cd ${YBPATH}/ybbond-reason"
    133 alias ftex="cd ${YBPATH}/latex"
    134 alias todo="nvim ~/todo.md"
    135 alias tempbin="nvim ~/tempbin.md"
    136 alias personal="nvim ~/personal.md"
    137 alias mine="nvim ~/Library/Mobile\ Documents/27N4MQEA55~pro~writer/Documents"
    138 alias fetchwm="WEBMENTIONS_TOKEN=${WMTOKEN} node ${YBPATH}/ybbond/webmentions.js"
    139 
    140 # settings
    141 alias zshrc="nvim ~/.zshrc"
    142 alias vimrc="vim ~/.vimrc"
    143 alias bashpro="nvim ~/.bash_profile"
    144 alias bashrc="nvim ~/.bashrc"
    145 alias neorc="nvim ~/.config/nvim/init.vim"
    146 
    147 # git
    148 alias wip="git add . && git commit -m 'wip'"
    149 alias rehead="git reset HEAD~"
    150 alias lg="lazygit"
    151 
    152 # misc
    153 alias ld="lazydocker"
    154 alias r="ranger"
    155 alias pixel3a="~/Library/Android/sdk/emulator/emulator -avd Pixel_3a_API_29 -netdelay none -netspeed full"
    156 alias pixelxl="~/Library/Android/sdk/emulator/emulator -avd Pixel_XL_API_30 -netdelay none -netspeed full"
    157 
    158 alias cdb="cd .."
    159 alias konak="kantal 10 yarn add"
    160 
    161 # better cli
    162 alias ls='exa'
    163 alias top='htop'
    164 alias cat='alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"'
    165 alias find='fd'
    166 alias du='ncdu --color dark -rr'
    167 
    168 alias tarex='tar -xzf'
    169 
    170 source ~/Library/Preferences/org.dystroy.broot/launcher/bash/br
    171 
    172 
    173 ########################################################################
    174 #                     SPACESHIP
    175 ########################################################################
    176 
    177 SPACESHIP_PROMPT_ORDER=(
    178     battery
    179     time
    180     user
    181     dir
    182     host
    183     git
    184     exec_time
    185     jobs
    186     exit_code
    187     vi_mode
    188     char
    189   )
    190 SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true
    191 SPACESHIP_PROMPT_SEPARATE_LINE=false
    192 SPACESHIP_BATTERY_SHOW=always
    193 SPACESHIP_BATTERY_PREFIX='['
    194 SPACESHIP_BATTERY_SUFFIX=']'
    195 SPACESHIP_BATTERY_THRESHOLD=100
    196 SPACESHIP_GIT_PREFIX='['
    197 SPACESHIP_GIT_SUFFIX=']'
    198 SPACESHIP_GIT_BRANCH_PREFIX='•'
    199 SPACESHIP_GIT_BRANCH_SUFFIX='•'
    200 SPACESHIP_GIT_STATUS_PREFIX='<'
    201 SPACESHIP_GIT_STATUS_SUFFIX='>'
    202 SPACESHIP_DIR_PREFIX='['
    203 SPACESHIP_DIR_SUFFIX=']'
    204 SPACESHIP_CHAR_SYMBOL='λ'
    205 SPACESHIP_CHAR_PREFIX=' '
    206 SPACESHIP_CHAR_SUFFIX=' '
    207 SPACESHIP_TIME_SHOW=true
    208 SPACESHIP_TIME_PREFIX='['
    209 SPACESHIP_TIME_SUFFIX=']'
    210 SPACESHIP_VI_MODE_PREFIX=''
    211 SPACESHIP_VI_MODE_COLOR='gray'
    212 
    213 ########################################################################
    214 #                     ZINIT
    215 ########################################################################
    216 
    217 ### Added by Zinit's installer
    218 if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
    219     print -P "%F{33}▓▒░ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma/zinit)…%f"
    220     command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
    221     command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
    222         print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
    223         print -P "%F{160}▓▒░ The clone has failed.%f%b"
    224 fi
    225 
    226 source "$HOME/.zinit/bin/zinit.zsh"
    227 autoload -Uz _zinit
    228 (( ${+_comps} )) && _comps[zinit]=_zinit
    229 
    230 # Load a few important annexes, without Turbo
    231 # (this is currently required for annexes)
    232 zinit light-mode for \
    233     zinit-zsh/z-a-patch-dl \
    234     zinit-zsh/z-a-as-monitor \
    235     zinit-zsh/z-a-bin-gem-node
    236 
    237 ### End of Zinit's installer chunk
    238 
    239 # Plugins
    240 
    241 zplugin light zsh-users/zsh-autosuggestions
    242   bindkey -M viins '^F' autosuggest-accept
    243   ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#d6d6d6"
    244 
    245 zplugin light zsh-users/zsh-history-substring-search
    246   bindkey -M viins '^P' history-substring-search-up
    247   bindkey -M viins '^N' history-substring-search-down
    248 
    249 zplugin light zdharma/fast-syntax-highlighting
    250 
    251 zplugin light denysdovhan/spaceship-prompt
    252 
    253 # export NVM_DIR="$HOME/.nvm"
    254 # export NVM_COMPLETION=true
    255 # export NVM_LAZY_LOAD=true
    256 # export NVM_LAZY_LOAD_EXTRA_COMMANDS=('nvim')
    257 zplugin light lukechilds/zsh-nvm
    258 
    259 zplugin load zdharma/history-search-multi-word
    260 
    261 zplugin load zsh-users/zsh-completions
    262   autoload -Uz compinit
    263   if [ $(date +'%j') != $(/usr/bin/stat -f '%Sm' -t '%j' ${ZDOTDIR:-$HOME}/.zcompdump) ]; then
    264     compinit
    265   else
    266     compinit -C
    267   fi
    268 
    269   {
    270     # Compile zcompdump, if modified, to increase startup speed.
    271     zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
    272     if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
    273       zcompile "$zcompdump"
    274     fi
    275   } &!
    276 
    277 zplugin load softmoth/zsh-vim-mode
    278   bindkey -M viins "jk" vi-cmd-mode
    279   export KEYTIMEOUT=10
    280 
    281 precmd () {
    282   echo -n -e "\a"
    283 }
    284 
    285 # # Change cursor shape for different vi modes.
    286 # function zle-keymap-select {
    287 #   if [[ ${KEYMAP} == vicmd ]] ||
    288 #      [[ $1 = 'block' ]]; then
    289 #     echo -ne '\e[1 q'
    290 
    291 #   elif [[ ${KEYMAP} == main ]] ||
    292 #        [[ ${KEYMAP} == viins ]] ||
    293 #        [[ ${KEYMAP} = '' ]] ||
    294 #        [[ $1 = 'beam' ]]; then
    295 #     echo -ne '\e[5 q'
    296 #   fi
    297 # }
    298 # zle -N zle-keymap-select
    299 # _fix_cursor() {
    300 #    echo -ne '\e[5 q'
    301 # }
    302 # precmd_functions+=(_fix_cursor)
    303 
    304 
    305 #   * To start using RVM you need to run `source /Users/yohanesbandung/.rvm/scripts/rvm`
    306 #     in all your open shell windows, in rare cases you need to reopen all shell windows.
    307 #   * To start using rails you need to run `rails new <project_dir>`.
    308 
    309 
    310 
    311 alias config=$CONFTREE
    312 
    313 # Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
    314 export PATH="$PATH:$HOME/.rvm/bin"