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.

90 lines
3.3 KiB

  1. # Via https://tanguy.ortolo.eu/blog/article25/shrc
  2. #
  3. # At startup, depending on the case:
  4. # - run as a login shell (or with the option --login), it executes profile (or
  5. # bash_profile instead if it exists (only user-specific version));
  6. # - run as an interactive, non-login shell, it executes bashrc (the system-wide
  7. # version is called bash.bashrc).
  8. #
  9. # At exit, it executes ~/.bash_logout (the system-wide version is called
  10. # bash.bash_logout).
  11. # Note the funny (read: insane) non-login condition for executing bashrc: it is
  12. # often worked around by having the profile execute bashrc anyway.
  13. # If not running interactively, don't do anything
  14. [ -z "$PS1" ] && return
  15. # Source global definitions
  16. test -r /etc/bashrc && . /etc/bashrc
  17. test -r ~/.shell-env && . ~/.shell-env
  18. test -r ~/.shell-aliases && . ~/.shell-aliases
  19. test -r ~/.shell-common && . ~/.shell-common
  20. test -r ~/.shell-history && . ~/.shell-history
  21. # don't put duplicate lines in the history. See bash(1) for more options
  22. # ... or force ignoredups and ignorespace
  23. HISTCONTROL=ignoreboth
  24. export HISTIGNORE="&:ls:[bf]g:pwd:exit:cd .."
  25. # append to the history file, don't overwrite it
  26. shopt -s histappend
  27. PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
  28. # Store multiline commands as one line.
  29. shopt -s cmdhist
  30. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  31. HISTSIZE=10000
  32. HISTFILESIZE=20000
  33. # check the window size after each command and, if necessary,
  34. # update the values of LINES and COLUMNS.
  35. shopt -s checkwinsize
  36. # Spellcheck directories
  37. shopt -s dirspell
  38. # enable programmable completion features (you don't need to enable
  39. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  40. # sources /etc/bash.bashrc).
  41. test -f /usr/share/bash-completion/bash_completion && . /usr/share/bash-completion/bash_completion
  42. test -f /etc/bash_completion && . /etc/bash_completion
  43. test -f $BREW_PREFIX/etc/bash_completion && . $BREW_PREFIX/etc/bash_completion
  44. test -r ~/.bashrc.local && . ~/.bashrc.local
  45. if command -v fzf-share >/dev/null; then
  46. source "$(fzf-share)/key-bindings.bash"
  47. source "$(fzf-share)/completion.bash"
  48. fi
  49. eval "$(direnv hook bash)"
  50. function right_prompt(){
  51. RIGHT_PROMPT="$(starship prompt --right)"
  52. RIGHT_PROMPT_RENDERED="${RIGHT_PROMPT@P}"
  53. # For some reason this one is less accurate, while the other method below
  54. # gives better precision, but also throws errors. Curious!
  55. #RIGHT_PROMPT_RENDERED_stripped=$(sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" <<<"$RIGHT_PROMPT_RENDERED")
  56. RIGHT_PROMPT_RENDERED_stripped="$(sed -r 's:\\\[([^\\]|\\[^]])*\\\]::g' <<<$RIGHT_PROMPT_RENDERED)"
  57. RIGHT_PROMPT_RENDERED_stripped="$(eval echo -e $RIGHT_PROMPT_RENDERED_stripped 2>/dev/null)"
  58. printf "\033[50D\033[$((${COLUMNS:-$(tput cols)}-${#RIGHT_PROMPT_RENDERED_stripped}))C$RIGHT_PROMPT_RENDERED\n"
  59. }
  60. starship_precmd_user_func="right_prompt"
  61. eval "$(starship init bash)"
  62. # Prepare LC_ALL for correct fonts rendering in tmux
  63. export LC_ALL=en_US.UTF-8
  64. export LANG=ru_RU.UTF-8
  65. [ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
  66. test -d $NVM_DIR && source /usr/share/nvm/nvm.sh
  67. test -d $NVM_DIR && source /usr/share/nvm/bash_completion
  68. test -d $NVM_DIR && source /usr/share/nvm/install-nvm-exec
  69. # auto into tmux session
  70. if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
  71. tmux attach || tmux
  72. fi