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.

118 lines
2.7 KiB

4 years ago
5 months ago
4 years ago
5 months ago
4 years ago
4 years ago
4 years ago
4 years ago
5 months ago
5 months ago
5 months ago
1 month ago
5 months ago
5 months ago
5 months ago
5 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. if [[ -f "${ZDOTDIR}/.zcompdump" && "${ZDOTDIR}/.zcompdump" -nt "${ZDOTDIR}/.zshrc" ]]; then
  37. compinit
  38. else
  39. compinit -C
  40. fi
  41. # Auto complete case insensitive
  42. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
  43. # Load colors
  44. autoload -U colors && colors
  45. # Automatically cd into typed directory.
  46. setopt autocd
  47. # Useful support for interacting with Terminal.app or other terminal programs
  48. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  49. # Load Git completion
  50. zstyle ':completion:*:*:git:*' script "${ZDOTDIR}/.zsh/git-completion.bash"
  51. fpath=(~/.zsh $fpath)
  52. # vi mode
  53. bindkey -v
  54. export KEYTIMEOUT=1
  55. # Edit line in vim with ctrl-e:
  56. autoload edit-command-line; zle -N edit-command-line
  57. bindkey '^e' edit-command-line
  58. # Go up directory structures
  59. up () {
  60. cd $(printf "%0.0s../" $(seq 1 $1));
  61. }
  62. # cd with fzf
  63. function cdf () {
  64. cd $(find . -type d -print | fzf)
  65. }
  66. # Android dev config
  67. export ANDROID_HOME="$HOME/Android/Sdk"
  68. if [[ $(uname) == 'Darwin' ]]; then
  69. export ANDROID_HOME="$HOME/Library/Android/sdk"
  70. export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
  71. fi
  72. export PATH="${PATH}:${ANDROID_HOME}/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin"
  73. # Load nvm on load to speed up shell init
  74. function nvm() {
  75. unset -f nvm node npm npx
  76. [ -s "/usr/share/nvm/init-nvm.sh" ] && source "/usr/share/nvm/init-nvm.sh"
  77. nvm "$@"
  78. }
  79. function node { nvm; node "$@" }
  80. function npm { nvm; npm "$@" }
  81. function npx { nvm; npx "$@" }
  82. # Load external aliases
  83. source ~/.config/aliasrc
  84. # Source fzf for Ctrl+r
  85. source <(fzf --zsh)
  86. if [ -f "$HOME/.cargo/env" ]; then
  87. . "$HOME/.cargo/env"
  88. fi
  89. # Speed debugging
  90. # zprof