You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.8 KiB

4 years ago
4 months ago
4 years ago
4 months ago
4 years ago
4 years ago
4 years ago
4 years ago
4 months ago
4 months ago
4 months ago
1 month ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. #!/bin/zsh
  2. # Speed debugging
  3. # zmodload zsh/zprof
  4. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
  5. setopt COMBINING_CHARS
  6. fi
  7. # Disable the log builtin, so we don't conflict with /usr/bin/log
  8. disable log
  9. # Save command history
  10. HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
  11. HISTSIZE=99999999
  12. SAVEHIST=$HISTSIZE
  13. # Variables
  14. export CASE_SENSITIVE="true"
  15. export EDITOR=nvim
  16. export GIT_EDITOR=nvim
  17. export PATH="${HOME}/.local/bin/:${HOME}/go/bin:${HOME}/.cargo/bin:${PATH}"
  18. # export DOCKER_DEFAULT_PLATFORM=linux/amd64
  19. # Enable substitution in the prompt.
  20. setopt prompt_subst
  21. function git_branch_name() {
  22. branch=$(git symbolic-ref HEAD 2> /dev/null | sed 's/refs\/heads\///g')
  23. if [[ $branch != "" ]]; then
  24. echo "- ${branch} "
  25. fi
  26. }
  27. PROMPT='%{$fg[blue]%}%1~ %{$fg[magenta]%}$(git_branch_name)%{$fg[green]%}>%{$reset_color%} '
  28. # Set some options if running on mac
  29. if [[ $(uname) == 'Darwin' ]]; then
  30. export HOMEBREW_NO_AUTO_UPDATE=1
  31. export PATH="/opt/homebrew/lib/ruby/gems/3.3.0:$PATH"
  32. export PATH="/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0:$PATH"
  33. eval "$(rbenv init - zsh)"
  34. fi
  35. autoload -Uz compinit
  36. compinit
  37. # Auto complete case insensitive
  38. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
  39. # Load colors
  40. autoload -U colors && colors
  41. # Automatically cd into typed directory.
  42. setopt autocd
  43. # Useful support for interacting with Terminal.app or other terminal programs
  44. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  45. # Load Git completion
  46. zstyle ':completion:*:*:git:*' script "${ZDOTDIR}/.zsh/git-completion.bash"
  47. fpath=(~/.zsh $fpath)
  48. # vi mode
  49. bindkey -v
  50. export KEYTIMEOUT=1
  51. # Edit line in vim with ctrl-e:
  52. autoload edit-command-line; zle -N edit-command-line
  53. bindkey '^e' edit-command-line
  54. # Go up directory structures
  55. up () {
  56. cd $(printf "%0.0s../" $(seq 1 $1));
  57. }
  58. # cd with fzf
  59. function cdf () {
  60. cd $(find . -type d -print | fzf)
  61. }
  62. # Android dev config
  63. export ANDROID_HOME="$HOME/Android/Sdk"
  64. if [[ $(uname) == 'Darwin' ]]; then
  65. export ANDROID_HOME="$HOME/Library/Android/sdk"
  66. export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
  67. fi
  68. export PATH="${PATH}:${ANDROID_HOME}/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin"
  69. # Load nvm on load to speed up shell init
  70. function nvm() {
  71. unset -f nvm node npm npx
  72. [ -s "/usr/share/nvm/init-nvm.sh" ] && source "/usr/share/nvm/init-nvm.sh"
  73. nvm "$@"
  74. }
  75. function node { nvm; node "$@" }
  76. function npm { nvm; npm "$@" }
  77. function npx { nvm; npx "$@" }
  78. # Load external aliases
  79. source ~/.config/aliasrc
  80. # Source fzf for Ctrl+r
  81. source <(fzf --zsh)
  82. if [ -f "$HOME/.cargo/env" ]; then
  83. . "$HOME/.cargo/env"
  84. fi
  85. if type "pyenv" > /dev/null; then
  86. export PYENV_ROOT="$HOME/.pyenv"
  87. [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
  88. eval "$(pyenv init -)"
  89. fi
  90. # Speed debugging
  91. # zprof