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.

113 lines
2.6 KiB

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