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.

110 lines
2.6 KiB

4 years ago
4 months ago
4 years ago
4 months ago
4 years ago
4 years ago
4 years ago
4 months 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. # Enable substitution in the prompt.
  19. setopt prompt_subst
  20. function git_branch_name() {
  21. branch=$(git symbolic-ref HEAD 2> /dev/null | sed 's/refs\/heads\///g')
  22. if [[ $branch != "" ]]; then
  23. echo "- ${branch} "
  24. fi
  25. }
  26. PROMPT='%{$fg[blue]%}%1~ %{$fg[magenta]%}$(git_branch_name)%{$fg[green]%}>%{$reset_color%} '
  27. # Set some options if running on mac
  28. if [[ $(uname) == 'Darwin' ]]; then
  29. export HOMEBREW_NO_AUTO_UPDATE=1
  30. export PATH="/opt/homebrew/lib/ruby/gems/3.3.0:$PATH"
  31. export PATH="/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0:$PATH"
  32. eval "$(rbenv init - zsh)"
  33. fi
  34. # Auto complete case insensitive
  35. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
  36. # Load colors
  37. autoload -U colors && colors
  38. # Automatically cd into typed directory.
  39. setopt autocd
  40. # Useful support for interacting with Terminal.app or other terminal programs
  41. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  42. # Load Git completion
  43. zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
  44. fpath=(~/.zsh $fpath)
  45. # vi mode
  46. bindkey -v
  47. export KEYTIMEOUT=1
  48. # Edit line in vim with ctrl-e:
  49. autoload edit-command-line; zle -N edit-command-line
  50. bindkey '^e' edit-command-line
  51. # Go up directory structures
  52. up () {
  53. cd $(printf "%0.0s../" $(seq 1 $1));
  54. }
  55. # cd with fzf
  56. function cdf () {
  57. cd $(find . -type d -print | fzf)
  58. }
  59. # Android dev config
  60. export ANDROID_HOME="$HOME/Android/Sdk"
  61. if [[ $(uname) == 'Darwin' ]]; then
  62. export ANDROID_HOME="$HOME/Library/Android/sdk"
  63. export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
  64. fi
  65. export PATH="${PATH}:${ANDROID_HOME}/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin"
  66. # Load nvm on load to speed up shell init
  67. function nvm {
  68. unset -f nvm node npm npx
  69. export NVM_DIR="$HOME/.nvm"
  70. [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
  71. [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
  72. nvm "$@"
  73. }
  74. function node { nvm; node "$@" }
  75. function npm { nvm; npm "$@" }
  76. function npx { nvm; npx "$@" }
  77. # Load external aliases
  78. source ~/.config/aliasrc
  79. # Source fzf for Ctrl+r
  80. source <(fzf --zsh)
  81. . "$HOME/.cargo/env"
  82. # Speed debugging
  83. # zprof
  84. #