Created
January 14, 2026 23:52
-
-
Save xeioex/9c66da92b7885fab911caedf3f7de950 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # Generic routines | |
| __source-if-exist() { | |
| if [ -f $1 ]; then | |
| . $1 | |
| fi | |
| } | |
| __create-if-not-exist() { | |
| if [ ! -d $1 ]; then | |
| mkdir -p $1 2>/dev/null | |
| fi | |
| } | |
| __is-exist() { | |
| which $1 2>/dev/null | |
| } | |
| __path_prepend() { | |
| if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then | |
| export PATH="$1:$PATH" | |
| fi | |
| } | |
| __path_append() { | |
| if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then | |
| export PATH="$PATH:$1" | |
| fi | |
| } | |
| # Customization | |
| USERPROFILERC=~/.bashrc_user_profile | |
| __source-if-exist $USERPROFILERC | |
| __source-if-exist ~/.bashrc_private | |
| export PROJECT=$PROJECT | |
| export HOSTIP=$(ip addr|egrep 'inet.*eth0'|egrep -m 1 -o 'inet [0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed 's/inet //') | |
| export ESSENTIALCONFIGS="$USERPROFILERC $ESSENTIALCONFIGS" | |
| #Colors aliases | |
| # Reset | |
| Color_Off="\[\e[0m\]" | |
| Color_OffE="\e[0m" | |
| # Bold Regular Colors | |
| Red="\[\033[1;31m\]" | |
| RedE="\033[1;31m" | |
| Green="\[\033[1;32m\]" | |
| GreenE="\033[1;32m" | |
| Yellow="\[\033[1;33m\]" | |
| YellowE="\033[1;33m" | |
| Blue="\[\033[1;34m\]" | |
| BlueE="\033[1;34m" | |
| Purple="\[\033[1;35m\]" | |
| PurpleE="\033[1;35m" | |
| Cyan="\[\033[1;36m\]" | |
| CyanE="\033[1;36m" | |
| White="\[\033[1;37m\]" | |
| WhiteE="\033[1;37m" | |
| info-message () { | |
| echo -e "${GreenE}$1${Color_OffE}" | |
| } | |
| important-message () { | |
| echo -e "${YellowE}$1${Color_OffE}" | |
| } | |
| warning-message () { | |
| echo -e "${RedE}$1${Color_OffE}" | |
| } | |
| export PS1HOST="$Red $HOSTIP $Color_Off" | |
| if [[ $HOSTIP == $BASEHOSTIP ]]; then | |
| export HOSTIP='HOME' | |
| export PS1HOST="$Green $HOSTIP $Color_Off" | |
| fi | |
| export SHELLRC="~/.bashrc_$USER" | |
| export SHELLCMD="bash --rcfile $SHELLRC -i" | |
| export PS1="$Yellow[\@] $Red\#$Red$PS1HOST$Blue\u@\h$Yellow \w\n$Color_Off\$ " | |
| if [ -n "$(type __git_ps1 2>/dev/null)" ]; then | |
| export PS1="\$(__git_ps1) $PS1" | |
| fi | |
| __create-if-not-exist $WORKSPACE | |
| __create-if-not-exist ~/.gdb | |
| # Sources | |
| __source-if-exist /etc/bashrc | |
| __source-if-exist ~/.cargo/env | |
| __source-if-exist /usr/share/doc/cdargs/examples/cdargs-bash.sh | |
| __source-if-exist /etc/bash_completion | |
| __path_append "$HOME/bin" | |
| __path_append "$HOME/bin/depot_tools" | |
| export GOROOT=/usr/local/go | |
| export GOPATH=$HOME/go | |
| __path_prepend "$GOPATH/bin" | |
| __path_prepend "$GOROOT/bin" | |
| __path_prepend "$HOME/bin/node-v25.2.1-linux-arm64/bin" | |
| # Aliases | |
| if [[ $TMUX || $EXPALIAS ]]; then | |
| shopt -s expand_aliases #expand aliases in non-interactive shell | |
| fi | |
| alias ss="source $SHELLRC" | |
| # Generic | |
| alias ainstall='sudo apt-get install' | |
| alias asearch='sudo apt-cache search' | |
| alias vim="env --unset=DISPLAY nvim -u ~/.vimrc" | |
| alias ldd='bash ldd' | |
| alias cursor-invisible='tput cinvis' | |
| alias cursor-visible='tput cnorm' | |
| alias reload-ssh-agent='eval `ssh-agent -s`; ssh-add ~/.ssh/nginx_id_rsa' | |
| alias ssh-copy-id='ssh-copy-id -i ~/.ssh/id_rsa.pub' | |
| if [[ -n $PROJECT ]]; then | |
| PROJECTPREFIX="${PROJECT}-" | |
| else | |
| PROJECTPREFIX="" | |
| fi | |
| alias tmux-enter-dev="~/.tmux/${PROJECTPREFIX}dev" | |
| alias tmux-enter-aux="~/.tmux/${PROJECTPREFIX}aux" | |
| alias tmux-kill-dev='tmux kill-session -t dev' | |
| alias tmux-kill-aux='tmux kill-session -t aux' | |
| vim-enter-session() { | |
| info-message "Running vim..." | |
| vim -S ~/.vimrc | |
| } | |
| vim-enter-clean-session() { | |
| rm -fr ~/.vim/backups/*; rm -fr ~/.vim/sessions/$USER-$1.vim; vim-enter-session $1 | |
| } | |
| . "$HOME/.cargo/env" | |
| . "$HOME/.local/bin/env" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment