# Via https://tanguy.ortolo.eu/blog/article25/shrc # # At startup, depending on the case: # - run as a login shell (or with the option --login), it executes profile (or # bash_profile instead if it exists (only user-specific version)); # - run as an interactive, non-login shell, it executes bashrc (the system-wide # version is called bash.bashrc). # # At exit, it executes ~/.bash_logout (the system-wide version is called # bash.bash_logout). # Note the funny (read: insane) non-login condition for executing bashrc: it is # often worked around by having the profile execute bashrc anyway. # If not running interactively, don't do anything [ -z "$PS1" ] && return # Source global definitions test -r /etc/bashrc && . /etc/bashrc test -r ~/.shell-env && . ~/.shell-env test -r ~/.shell-aliases && . ~/.shell-aliases test -r ~/.shell-common && . ~/.shell-common # don't put duplicate lines in the history. See bash(1) for more options # ... or force ignoredups and ignorespace HISTCONTROL=ignoreboth export HISTIGNORE="&:ls:[bf]g:pwd:exit:cd .." # append to the history file, don't overwrite it shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" # Store multiline commands as one line. shopt -s cmdhist # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=10000 HISTFILESIZE=20000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize # Spellcheck directories shopt -s dirspell # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). test -f /usr/share/bash-completion/bash_completion && . /usr/share/bash-completion/bash_completion test -f /etc/bash_completion && . /etc/bash_completion test -f $BREW_PREFIX/etc/bash_completion && . $BREW_PREFIX/etc/bash_completion test -r ~/.bashrc.local && . ~/.bashrc.local if command -v fzf-share >/dev/null; then source "$(fzf-share)/key-bindings.bash" source "$(fzf-share)/completion.bash" fi eval "$(direnv hook bash)" function right_prompt(){ RIGHT_PROMPT="$(starship prompt --right)" RIGHT_PROMPT_RENDERED="${RIGHT_PROMPT@P}" # For some reason this one is less accurate, while the other method below # gives better precision, but also throws errors. Curious! #RIGHT_PROMPT_RENDERED_stripped=$(sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" <<<"$RIGHT_PROMPT_RENDERED") RIGHT_PROMPT_RENDERED_stripped="$(sed -r 's:\\\[([^\\]|\\[^]])*\\\]::g' <<<$RIGHT_PROMPT_RENDERED)" RIGHT_PROMPT_RENDERED_stripped="$(eval echo -e $RIGHT_PROMPT_RENDERED_stripped 2>/dev/null)" printf "\033[50D\033[$((${COLUMNS:-$(tput cols)}-${#RIGHT_PROMPT_RENDERED_stripped}))C$RIGHT_PROMPT_RENDERED\n" } starship_precmd_user_func="right_prompt" eval "$(starship init bash)" # Prepare LC_ALL for correct fonts rendering in tmux export LC_ALL=en_US.UTF-8 export LANG=ru_RU.UTF-8 # auto into tmux session if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then tmux attach || tmux fi