147 lines
3.8 KiB
Bash
147 lines
3.8 KiB
Bash
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||
# for examples
|
||
|
||
# If not running interactively, don't do anything
|
||
case $- in
|
||
*i*) ;;
|
||
*) return;;
|
||
esac
|
||
|
||
# don't put duplicate lines or lines starting with space in the history.
|
||
# See bash(1) for more options
|
||
HISTCONTROL=ignoreboth
|
||
|
||
# append to the history file, don't overwrite it
|
||
shopt -s histappend
|
||
|
||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||
HISTSIZE=1000
|
||
HISTFILESIZE=2000
|
||
|
||
# check the window size after each command and, if necessary,
|
||
# update the values of LINES and COLUMNS.
|
||
shopt -s checkwinsize
|
||
|
||
# enable color support of ls and also add handy aliases
|
||
if [ -x /usr/bin/dircolors ]; then
|
||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||
alias ls='ls --color=auto'
|
||
#alias dir='dir --color=auto'
|
||
#alias vdir='vdir --color=auto'
|
||
|
||
#alias grep='grep --color=auto'
|
||
#alias fgrep='fgrep --color=auto'
|
||
#alias egrep='egrep --color=auto'
|
||
fi
|
||
|
||
# colored GCC warnings and errors
|
||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||
|
||
# some more ls aliases
|
||
#alias ll='ls -l'
|
||
#alias la='ls -A'
|
||
#alias l='ls -CF'
|
||
|
||
# Alias definitions.
|
||
# You may want to put all your additions into a separate file like
|
||
# ~/.bash_aliases, instead of adding them here directly.
|
||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||
|
||
if [ -f ~/.bash_aliases ]; then
|
||
. ~/.bash_aliases
|
||
fi
|
||
|
||
# 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).
|
||
if ! shopt -oq posix; then
|
||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||
. /usr/share/bash-completion/bash_completion
|
||
elif [ -f /etc/bash_completion ]; then
|
||
. /etc/bash_completion
|
||
fi
|
||
fi
|
||
|
||
# ============================================================
|
||
# Tokyo Night Bash prompt
|
||
# ============================================================
|
||
|
||
# Raw colors for command substitutions and shell functions
|
||
TN_BLUE=$'\e[38;2;122;162;247m'
|
||
TN_CYAN=$'\e[38;2;125;207;255m'
|
||
TN_GREEN=$'\e[38;2;158;206;106m'
|
||
TN_YELLOW=$'\e[38;2;224;175;104m'
|
||
TN_RED=$'\e[38;2;247;118;142m'
|
||
TN_PURPLE=$'\e[38;2;187;154;247m'
|
||
TN_MUTED=$'\e[38;2;86;95;137m'
|
||
TN_FG=$'\e[38;2;169;177;214m'
|
||
TN_RESET=$'\e[0m'
|
||
|
||
__tokyo_git_prompt() {
|
||
local branch
|
||
local changes
|
||
|
||
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) ||
|
||
branch=$(git rev-parse --short HEAD 2>/dev/null) ||
|
||
return 0
|
||
|
||
changes=$(git status --porcelain 2>/dev/null)
|
||
|
||
if [[ -n "$changes" ]]; then
|
||
printf '%s %s %s●%s' \
|
||
"$TN_PURPLE" "$branch" "$TN_YELLOW" "$TN_RESET"
|
||
else
|
||
printf '%s %s %s✓%s' \
|
||
"$TN_PURPLE" "$branch" "$TN_GREEN" "$TN_RESET"
|
||
fi
|
||
}
|
||
|
||
__tokyo_exit_status() {
|
||
local status=$1
|
||
|
||
if (( status != 0 )); then
|
||
printf '%s ✘ %d%s' "$TN_RED" "$status" "$TN_RESET"
|
||
fi
|
||
}
|
||
|
||
__tokyo_prompt() {
|
||
local exit_code=$?
|
||
|
||
PS1=""
|
||
|
||
# First line
|
||
PS1+="${TN_MUTED}╭─${TN_BLUE}["
|
||
PS1+="${TN_CYAN}\u${TN_MUTED}@${TN_CYAN}\h"
|
||
PS1+="${TN_BLUE}]${TN_MUTED}─"
|
||
if [[ -n ${IN_NIX_SHELL:-} ]]; then
|
||
PS1+="${TN_YELLOW}[nix:${IN_NIX_SHELL}]${TN_MUTED}─"
|
||
fi
|
||
PS1+="${TN_GREEN}[\w]"
|
||
|
||
# The \[...\] markers tell Bash that the command substitution
|
||
# contains non-printing terminal color sequences.
|
||
PS1+="\[\$(__tokyo_git_prompt)\]"
|
||
|
||
if (( exit_code != 0 )); then
|
||
PS1+="\[\$(__tokyo_exit_status ${exit_code})\]"
|
||
fi
|
||
|
||
# Second line
|
||
PS1+="${TN_MUTED}\n╰─"
|
||
|
||
if (( EUID == 0 )); then
|
||
PS1+="${TN_RED}#${TN_RESET} "
|
||
else
|
||
PS1+="${TN_BLUE}❯${TN_RESET} "
|
||
fi
|
||
}
|
||
|
||
PROMPT_COMMAND=__tokyo_prompt
|
||
|
||
export PATH=$PATH:$HOME/containers/bin
|
||
|
||
clear
|
||
ofetch
|
||
|