Personal dotfiles for Linux, mostly for Nixpkgs/NixOS-based and Termux setups. Mirrored using GitLab's push mirroring feature. gitlab.com/andreijiroh-dev/dotfiles
linux dotfiles
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(global): add ~vern's bash prompt and stuff

Also in this commit:
* Update shellrc files for bash for compat with this. I might work
on adding checks for oh-my-posh later on.

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@gmail.com>

+298 -13
+1 -10
.bash_login
··· 9 9 export LOCAL_DOTENV_LOADED=true 10 10 fi 11 11 12 - # Stage 1: Load global bashrc 13 - if [[ -f "$HOME/.bashrc" ]]; then 14 - source "$HOME/.bashrc" 15 - fi 16 - 17 - # Stage 2: Machine specifcs 18 - if [[ -f $HOST_SPECIFIC_BASHRC ]]; then 19 - source "$HOST_SPECIFIC_BASHRC_PATH" 20 - export HOST_SPECIFIC_BASHRC_LOADED=true 21 - fi 12 + source "$HOME/.profile"
+4
.bashrc
··· 51 51 export HOMEBREW_HOME=${HOMEBREW_HOME:-"/home/linuxbrew/.linuxbrew"} 52 52 test -d "$HOMEBREW_HOME" && eval "$($HOMEBREW_HOME/bin/brew shellenv)" 53 53 [[ -r "$HOMEBREW_HOME/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_HOME/etc/profile.d/bash_completion.sh" 54 + 55 + for file in "$HOME/.config/bash/${HOSTNAME}.bash" "$HOME/.config/bash/prompt" "${HOME}/.config/bash/bashrc"; do 56 + [ -f $file ] && . "$file" 57 + done
+5
.config/bash/README.md
··· 1 + # bashrc configurations 2 + 3 + Host-specifics (including in `~vern`), maybe bash-specific functions. 4 + Global configs are at [`~/.bashrc`](../../.bashrc), 5 + [`~/.bash_login`](../../.bash_login) and [POSIX-compliant `~/.profile`](../../.profile).
+109
.config/bash/bashrc
··· 1 + # ~/.bashrc: executed by bash(1) for non-login shells. 2 + # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 + # for examples 4 + 5 + # If not running interactively, don't do anything 6 + case $- in 7 + *i*) ;; 8 + *) return;; 9 + esac 10 + 11 + # don't put duplicate lines or lines starting with space in the history. 12 + # See bash(1) for more options 13 + HISTCONTROL=ignoreboth 14 + 15 + # append to the history file, don't overwrite it 16 + shopt -s histappend 17 + 18 + # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 19 + HISTSIZE=1000 20 + HISTFILESIZE=2000 21 + 22 + # check the window size after each command and, if necessary, 23 + # update the values of LINES and COLUMNS. 24 + shopt -s checkwinsize 25 + 26 + # If set, the pattern "**" used in a pathname expansion context will 27 + # match all files and zero or more directories and subdirectories. 28 + #shopt -s globstar 29 + 30 + # make less more friendly for non-text input files, see lesspipe(1) 31 + #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 32 + 33 + # set variable identifying the chroot you work in (used in the prompt below) 34 + if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 35 + debian_chroot=$(cat /etc/debian_chroot) 36 + fi 37 + 38 + # set a fancy prompt (non-color, unless we know we "want" color) 39 + case "$TERM" in 40 + xterm-color|*-256color) color_prompt=yes;; 41 + esac 42 + 43 + # uncomment for a colored prompt, if the terminal has the capability; turned 44 + # off by default to not distract the user: the focus in a terminal window 45 + # should be on the output of commands, not on the prompt 46 + #force_color_prompt=yes 47 + 48 + if [ -n "$force_color_prompt" ]; then 49 + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 50 + # We have color support; assume it's compliant with Ecma-48 51 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 52 + # a case would tend to support setf rather than setaf.) 53 + color_prompt=yes 54 + else 55 + color_prompt= 56 + fi 57 + fi 58 + 59 + if [ "$color_prompt" = yes ]; then 60 + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 61 + else 62 + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 63 + fi 64 + unset color_prompt force_color_prompt 65 + 66 + # If this is an xterm set the title to user@host:dir 67 + case "$TERM" in 68 + xterm*|rxvt*) 69 + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 70 + ;; 71 + *) 72 + ;; 73 + esac 74 + 75 + # enable color support of ls and also add handy aliases 76 + if [ -x /usr/bin/dircolors ]; then 77 + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 78 + alias ls='ls --color=auto' 79 + #alias dir='dir --color=auto' 80 + #alias vdir='vdir --color=auto' 81 + 82 + #alias grep='grep --color=auto' 83 + #alias fgrep='fgrep --color=auto' 84 + #alias egrep='egrep --color=auto' 85 + fi 86 + 87 + # colored GCC warnings and errors 88 + #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 89 + 90 + # some more ls aliases 91 + #alias ll='ls -l' 92 + #alias la='ls -A' 93 + #alias l='ls -CF' 94 + 95 + # Alias definitions. 96 + # You may want to put all your additions into a separate file like 97 + # ~/.bash_aliases, instead of adding them here directly. 98 + # See /usr/share/doc/bash-doc/examples in the bash-doc package. 99 + 100 + # enable programmable completion features (you don't need to enable 101 + # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 102 + # sources /etc/bash.bashrc). 103 + if ! shopt -oq posix; then 104 + if [ -f /usr/share/bash-completion/bash_completion ]; then 105 + . /usr/share/bash-completion/bash_completion 106 + elif [ -f /etc/bash_completion ]; then 107 + . /etc/bash_completion 108 + fi 109 + fi
+171
.config/bash/prompt
··· 1 + #!/bin/bash 2 + # shebang for syntax highlighting purposes 3 + 4 + # Colors 5 + _NON="\[\033[0m\]" 6 + _BLD="\[\033[1m\]" # YEP BALD 7 + _BLK="\[\033[30m\]" 8 + _RED="\[\033[31m\]" 9 + _GRN="\[\033[32m\]" 10 + _YLW="\[\033[33m\]" 11 + _BLU="\[\033[34m\]" 12 + _PRP="\[\033[35m\]" 13 + _CYN="\[\033[36m\]" 14 + _WHT="\[\033[37m\]" 15 + 16 + __debug_trap() { 17 + # Set necessary pre-command variables (PROMPT_COMMAND is a 18 + # command so its excluded here) 19 + if [[ "$BASH_COMMAND" != "$PROMPT_COMMAND" 20 + && "$LAST_BASH_COMMAND" == "$PROMPT_COMMAND" ]]; then 21 + INC_TIME=1 22 + LAST_RT="$EPOCHREALTIME" # This should be the last thing done in this function 23 + fi 24 + LAST_BASH_COMMAND="$BASH_COMMAND" 25 + } 26 + 27 + trap '__debug_trap' DEBUG 28 + 29 + __get_cmd_time() { 30 + # Set hours minutes seconds and remove preceding zeros 31 + local YEAR=$((10#0$(($(TZ=UTC printf '%(%Y)T' $CMD_TIME)))-1970)) 32 + local DAYS=$((10#0$(TZ=UTC printf '%(%j)T' $CMD_TIME))) 33 + local HOUR=$((10#0$(TZ=UTC printf '%(%H)T' $CMD_TIME))) 34 + local MINS=$((10#0$(TZ=UTC printf '%(%M)T' $CMD_TIME))) 35 + local SECS=$((10#0$(TZ=UTC printf '%(%S)T' $CMD_TIME))) 36 + 37 + # Choose whether or not to print hours minutes and seconds 38 + [[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' ${YEAR} 39 + [[ $CMD_TIME -ge 86400 ]] && printf '%sd ' ${DAYS} 40 + [[ $CMD_TIME -ge 3600 ]] && printf '%sh ' ${HOUR} 41 + [[ $CMD_TIME -ge 60 ]] && printf '%sm ' ${MINS} 42 + [[ $CMD_TIME -ge 1 ]] && printf '%ss ' ${SECS} 43 + # If you want to have a limit uncomment the next line and replace somenum with 44 + # the minimum microseconds 45 + # [[ $CMD_US -ge somenum ]] && 46 + printf '%sμs' ${CMD_US:-0} 47 + } 48 + 49 + __sig() { 50 + # Giant switch case for getting the name of the signal (`kill -l`) 51 + j=0 52 + for i in $@; do 53 + if [[ $j != 0 ]]; then 54 + printf '%s|%s' "$_WHT" "$_RED" 55 + fi 56 + j=$((j+1)) 57 + case $i in 58 + 126) printf ACCES ;; 59 + 127) printf NOENT ;; 60 + 129) printf HUP ;; 61 + 130) printf INT ;; 62 + 131) printf QUIT ;; 63 + 132) printf ILL ;; 64 + 133) printf TRAP ;; 65 + 134) printf ABRT ;; 66 + 135) printf BUS ;; 67 + 136) printf FPE ;; 68 + 137) printf KILL ;; 69 + 138) printf USR1 ;; 70 + 139) printf SEGV ;; 71 + 140) printf USR2 ;; 72 + 141) printf PIPE ;; 73 + 142) printf ALRM ;; 74 + 143) printf TERM ;; 75 + 144) printf STKFLT ;; 76 + 145) printf CHLD ;; 77 + 146) printf CONT ;; 78 + 147) printf STOP ;; 79 + 148) printf TSTP ;; 80 + 149) printf TTIN ;; 81 + 150) printf TTOU ;; 82 + 151) printf URG ;; 83 + 152) printf XCPU ;; 84 + 153) printf XFSZ ;; 85 + 154) printf VTALRM ;; 86 + 155) printf PROF ;; 87 + 156) printf WINCH ;; 88 + 157) printf IO ;; 89 + 158) printf PWR ;; 90 + 159) printf SYS ;; 91 + 16[3-9]|1[7-8][0-9]|19[0-2]) printf RT$(($i-128)) ;; # Savagery 92 + *) printf $i ;; # Print exit code if not in list 93 + esac 94 + done 95 + } 96 + 97 + __ssh() { 98 + local CON=($SSH_CONNECTION) 99 + local SRV_IP="${CON[2]}" 100 + [[ -z "$SRV_IP" ]] && return 101 + local SRV_PORT="${CON[3]}" 102 + # 4 chars from startand 4 chars from end 103 + local SRV_IP_CUT="${_CYN}${SRV_IP}" 104 + [[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT="${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}" 105 + 106 + printf '%s' "${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}" 107 + } 108 + 109 + __prompt() { 110 + # Get exit code (must be first) 111 + local PLC=(${PIPESTATUS[@]}) 112 + 113 + # Reset time when prompt was first displayed after command 114 + # this contributes to the 40 microsecond difference in $CMD_US and the actual time it took 115 + if [[ "$INC_TIME" != 0 ]]; then 116 + PROMPT_RT="$EPOCHREALTIME" 117 + INC_TIME=0 118 + fi 119 + 120 + # *_RT may not be set 121 + LAST_RT="${LAST_RT:-$EPOCHREALTIME}" 122 + PROMPT_RT="${PROMPT_RT:-$EPOCHREALTIME}" 123 + 124 + # Get relative times 125 + 126 + # Remove decimal point, simulating multiplying by 1 million 127 + PROMPT_RT1M="${PROMPT_RT/.}" 128 + LAST_RT1M="${LAST_RT/.}" 129 + 130 + CMD_US="$(($PROMPT_RT1M-$LAST_RT1M))" 131 + 132 + CMD_TIME=0 133 + 134 + # Remove last 6 chars, simulating dividing by 1 million to get a more accurate difference 135 + [[ ${#CMD_US} -lt 6 ]] || CMD_TIME="${CMD_US::-6}" 136 + 137 + [[ ${#CMD_US} -lt 6 ]] || CMD_US="${CMD_US: -6}" 138 + CMD_US="$((10#0$CMD_US))" 139 + 140 + # Set prompt sections 141 + 142 + # Text 143 + 144 + # ssh detection and indicator 145 + [[ "$SSH_CONNECTION" ]] && local SSH="$(__ssh) " 146 + 147 + # [INT], [4], etc. 148 + local i 149 + for i in ${PLC[@]}; do 150 + if [[ $i > 0 ]]; then 151 + local SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig ${PLC[@]})" "$_BLU")" 152 + break 153 + fi 154 + done 155 + 156 + # [user@homeserver:~] 157 + local COL="$([[ $UID == 0 ]] && printf '%s' "$_RED" || printf '%s' "$_YLW")" 158 + local UHD="${_BLD}${_BLU}[${COL}\u${_PRP}@${_CYN}\h${_PRP}:${_GRN}\w${_BLU}]" 159 + 160 + # 2y 351d 12m 43s 382969μs 161 + local TIME="${_YLW}$(__get_cmd_time)" 162 + 163 + # Random colored $ or # 164 + _RAND256="\[\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\]" 165 + local IND="${_RAND256}\\$" 166 + 167 + # Set the prompt 168 + PS1="${_NON}${SSH}${SIG}${UHD} ${TIME} ${IND} ${_NON}" 169 + } 170 + 171 + PROMPT_COMMAND=__prompt
+1
.config/gh/config.yml
··· 11 11 co: pr checkout 12 12 clone: repo clone 13 13 mr: pr 14 + fork: repo fork 14 15 # The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport. 15 16 http_unix_socket: 16 17 # What web browser gh should use when opening URLs. If blank, will refer to environment.
+3 -3
.config/htop/htoprc
··· 1 1 # Beware! This file is rewritten by htop when settings are changed in the interface. 2 2 # The parser is also very primitive, and not human-friendly. 3 - htop_version=3.2.1 3 + htop_version=3.2.0 4 4 config_reader_min_version=3 5 5 fields=0 48 17 18 38 39 40 2 46 47 49 1 6 6 hide_kernel_threads=1 ··· 38 38 column_meter_modes_1=2 2 2 39 39 tree_view=1 40 40 sort_key=46 41 - tree_sort_key=0 41 + tree_sort_key=48 42 42 sort_direction=-1 43 43 tree_sort_direction=1 44 44 tree_view_always_by_pid=0 45 45 all_branches_collapsed=0 46 46 screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command 47 47 .sort_key=PERCENT_CPU 48 - .tree_sort_key=PID 48 + .tree_sort_key=USER 49 49 .tree_view=1 50 50 .tree_view_always_by_pid=0 51 51 .sort_direction=-1
+4
.profile
··· 7 7 fi 8 8 fi 9 9 10 + export PATH="/usr/local/bin${PATH:+:}$PATH" # ~vern specifics, might work on this soon. 11 + mesg n 2> /dev/null || true 12 + 13 + # then import the rest 10 14 source "$HOME/.env" 11 15 source "$HOME/.config/aliases"