|  | 
|  | 1 | +# shellcheck disable=SC2148 | 
|  | 2 | + | 
|  | 3 | +BASHRC="$HOME/.bashrc" | 
|  | 4 | +ALIASES="$HOME/.bash_aliases" | 
|  | 5 | +INPUTRC="$HOME/.inputrc" | 
|  | 6 | + | 
|  | 7 | +log "Creating $ALIASES file..." | 
|  | 8 | +cat <<'EOF' >"$ALIASES" | 
|  | 9 | +alias ls="lsd --color auto" | 
|  | 10 | +alias ll="lsd -alF --color auto" | 
|  | 11 | +alias la="lsd -A --color auto" | 
|  | 12 | +alias cat="bat --color auto --style plain" | 
|  | 13 | +alias hx="hx --vsplit" | 
|  | 14 | +alias helix=hx | 
|  | 15 | +alias vim=hx | 
|  | 16 | +EOF | 
|  | 17 | + | 
|  | 18 | +log "Creating $INPUTRC file..." | 
|  | 19 | +cat <<'EOF' >"$INPUTRC" | 
|  | 20 | +$include /etc/inputrc | 
|  | 21 | +
 | 
|  | 22 | +set blink-matching-paren on | 
|  | 23 | +set colored-completion-prefix on | 
|  | 24 | +set completion-ignore-case on | 
|  | 25 | +set completion-map-case on | 
|  | 26 | +set show-all-if-unmodified on | 
|  | 27 | +set show-all-if-ambiguous on | 
|  | 28 | +TAB: menu-complete | 
|  | 29 | +"\e[Z": menu-complete-backward | 
|  | 30 | +EOF | 
|  | 31 | + | 
|  | 32 | +log "Creating $BASHRC..." | 
|  | 33 | +cat <<'EOF' >"$BASHRC" | 
|  | 34 | +case $- in | 
|  | 35 | +    *i*) ;; | 
|  | 36 | +      *) return;; | 
|  | 37 | +esac | 
|  | 38 | +
 | 
|  | 39 | +HISTCONTROL=ignoreboth | 
|  | 40 | +shopt -s histappend | 
|  | 41 | +HISTSIZE=-1 | 
|  | 42 | +HISTFILESIZE=-1 | 
|  | 43 | +HISTDUP="erase" | 
|  | 44 | +HISTTIMEFORMAT="%FT%T " | 
|  | 45 | +
 | 
|  | 46 | +shopt -s checkwinsize | 
|  | 47 | +shopt -s globstar | 
|  | 48 | +
 | 
|  | 49 | +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" | 
|  | 50 | +
 | 
|  | 51 | +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | 
|  | 52 | +  debian_chroot=$(cat /etc/debian_chroot) | 
|  | 53 | +fi | 
|  | 54 | +
 | 
|  | 55 | +case "$TERM" in | 
|  | 56 | +xterm-color | *-256color) color_prompt=yes ;; | 
|  | 57 | +esac | 
|  | 58 | +
 | 
|  | 59 | +if [ -n "$force_color_prompt" ]; then | 
|  | 60 | +  if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | 
|  | 61 | +    color_prompt=yes | 
|  | 62 | +  else | 
|  | 63 | +    color_prompt= | 
|  | 64 | +  fi | 
|  | 65 | +fi | 
|  | 66 | +
 | 
|  | 67 | +if [ "$color_prompt" = yes ]; then | 
|  | 68 | +  PS1='${debian_chroot:+($debian_chroot)}\[$(tput setaf 39)\]\u\[$(tput setaf 81)\]@\[$(tput setaf 77)\]\h \[$(tput setaf 226)\]\w \[$(tput sgr0)\]\n❯ ' | 
|  | 69 | +else | 
|  | 70 | +  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | 
|  | 71 | +fi | 
|  | 72 | +unset color_prompt force_color_prompt | 
|  | 73 | +
 | 
|  | 74 | +case "$TERM" in | 
|  | 75 | +xterm* | rxvt*) | 
|  | 76 | +  PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" | 
|  | 77 | +  ;; | 
|  | 78 | +*) ;; | 
|  | 79 | +esac | 
|  | 80 | +
 | 
|  | 81 | +if [ -x /usr/bin/dircolors ]; then | 
|  | 82 | +    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | 
|  | 83 | +    alias ls='ls --color=auto' | 
|  | 84 | +fi | 
|  | 85 | +
 | 
|  | 86 | +if [ -f ~/.bash_aliases ]; then | 
|  | 87 | +  . ~/.bash_aliases | 
|  | 88 | +fi | 
|  | 89 | +
 | 
|  | 90 | +if [ -f ~/.bash_env ]; then | 
|  | 91 | +  . ~/.bash_env | 
|  | 92 | +fi | 
|  | 93 | +
 | 
|  | 94 | +if ! shopt -oq posix; then | 
|  | 95 | +  if [ -f /usr/share/bash-completion/bash_completion ]; then | 
|  | 96 | +    . /usr/share/bash-completion/bash_completion | 
|  | 97 | +  elif [ -f /etc/bash_completion ]; then | 
|  | 98 | +    . /etc/bash_completion | 
|  | 99 | +  fi | 
|  | 100 | +fi | 
|  | 101 | +# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme | 
|  | 102 | +__bash_prompt() { | 
|  | 103 | +    local userpart='`export XIT=$? \ | 
|  | 104 | +        && [ ! -z "${GITHUB_USER:-}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER:-} " || echo -n "\[\033[0;32m\]\u " \ | 
|  | 105 | +        && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' | 
|  | 106 | +    local gitbranch='`\ | 
|  | 107 | +        if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ | 
|  | 108 | +            export BRANCH="$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null)"; \ | 
|  | 109 | +            if [ "${BRANCH:-}" != "" ]; then \ | 
|  | 110 | +                echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH:-}" \ | 
|  | 111 | +                && if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \ | 
|  | 112 | +                    git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ | 
|  | 113 | +                        echo -n " \[\033[1;33m\]✗"; \ | 
|  | 114 | +                fi \ | 
|  | 115 | +                && echo -n "\[\033[0;36m\]) "; \ | 
|  | 116 | +            fi; \ | 
|  | 117 | +        fi`' | 
|  | 118 | +    local lightblue='\[\033[1;34m\]' | 
|  | 119 | +    local removecolor='\[\033[0m\]' | 
|  | 120 | +    PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\n❯ " | 
|  | 121 | +    unset -f __bash_prompt | 
|  | 122 | +} | 
|  | 123 | +__bash_prompt | 
|  | 124 | +export PROMPT_DIRTRIM=4 | 
|  | 125 | +
 | 
|  | 126 | +# Check if the terminal is xterm | 
|  | 127 | +if [[ "$TERM" == "xterm" ]]; then | 
|  | 128 | +    # Function to set the terminal title to the current command | 
|  | 129 | +    preexec() { | 
|  | 130 | +        local cmd="${BASH_COMMAND}" | 
|  | 131 | +        echo -ne "\033]0;${USER}@${HOSTNAME}: ${cmd}\007" | 
|  | 132 | +    } | 
|  | 133 | +
 | 
|  | 134 | +    # Function to reset the terminal title to the shell type after the command is executed | 
|  | 135 | +    precmd() { | 
|  | 136 | +        echo -ne "\033]0;${USER}@${HOSTNAME}: ${SHELL}\007" | 
|  | 137 | +    } | 
|  | 138 | +
 | 
|  | 139 | +    # Trap DEBUG signal to call preexec before each command | 
|  | 140 | +    trap 'preexec' DEBUG | 
|  | 141 | +
 | 
|  | 142 | +    # Append to PROMPT_COMMAND to call precmd before displaying the prompt | 
|  | 143 | +    PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }precmd" | 
|  | 144 | +fi | 
|  | 145 | +
 | 
|  | 146 | +source <(bat --completion bash) | 
|  | 147 | +source <(fzf --bash) | 
|  | 148 | +
 | 
|  | 149 | +FZF_COMPLETION_AUTO_COMMON_PREFIX=true | 
|  | 150 | +FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true | 
|  | 151 | +EOF | 
0 commit comments