Skip to content

Instantly share code, notes, and snippets.

@mrevjd
Last active February 25, 2026 02:56
Show Gist options
  • Select an option

  • Save mrevjd/267c40413244fabc811bd1a227732b67 to your computer and use it in GitHub Desktop.

Select an option

Save mrevjd/267c40413244fabc811bd1a227732b67 to your computer and use it in GitHub Desktop.
Starship or Powerline Prompt with .bashrc
# =========================
# ~/.bash_aliases
# =========================
# ----- General -----
alias cls='clear'
alias ll='ls -la'
alias lls='ls -la --sort=size'
alias llt='ls -la --sort=time'
alias df='df -h'
alias du='du -h'
# Smart lt: tree if installed, else ls -la
if command -v tree >/dev/null 2>&1; then
alias lt='tree'
else
alias lt='ls -la'
fi
# ----- Package mgmt -----
alias apt='sudo apt'
alias aptup='apt update && apt dist-upgrade -y && apt autoremove -y && apt autoclean -y'
# ----- Session / shell -----
alias su='su -w SSH_CLIENT,SSH_CONNECTION,SSH_TTY'
alias tmux='tmux -2'
alias tx='tmux a || tmux new -s Default'
alias dmesg='dmesg -T'
# ----- Docker / K8s (k alias harmless if kubectl missing) -----
alias dps='docker ps'
alias dimg='docker images'
alias dprune='docker system prune -af'
alias k='kubectl'
# ----- Bun / Node helpers -----
alias bunu='bun upgrade'
alias npmi='npm install'
alias npmr='npm run'
alias y='yarn'
alias p='pnpm'
# ----- AWS quick check -----
alias awsme='aws sts get-caller-identity --output table 2>/dev/null || echo "AWS CLI not configured"'
# ----- Safer file ops -----
#alias mv='/usr/bin/mv'
#alias cp='/usr/bin/cp'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -I --preserve-root'
# ----- Networking -----
alias myip='{ r=$(curl -4s ifconfig.me) && [ -n "$r" ] && echo "$r"; r=$(curl -6s ifconfig.me) && [ -n "$r" ] && echo "$r"; }'
alias ipta='iptables -vnL --line-numbers'
alias iptn='iptables -t nat -vnL --line-numbers'
alias iptm='iptables -t mangle -vnL --line-numbers'
# ----- eza (modern ls) -----
if command -v eza >/dev/null 2>&1; then
alias ls='eza --group-directories-first --icons=always'
alias ll='eza -l --icons -b --header --git -g --color=always --group-directories-first --time-style=long-iso'
alias la='eza -la --icons -b --header --git -g --color=always --group-directories-first --time-style=long-iso'
alias llt='eza -l --sort newest --group-directories-first --icons=always --time-style=long-iso'
alias lls='eza -l --sort size --group-directories-first --icons=always --time-style=long-iso'
fi
# ----- bat / batcat -----
if command -v batcat >/dev/null 2>&1; then
alias cat='batcat --style=plain --paging=never'
alias pcat='batcat --pager=auto'
export BAT_PAGER='less -R'
elif command -v bat >/dev/null 2>&1; then
alias cat='bat --style=plain --paging=never'
alias pcat='bat'
export BAT_PAGER='less -R'
fi
# =========================
# Git helpers (function syntax to avoid () parser issues)
# =========================
function gstat { git status -sb "$@"; }
function gco { git checkout "$@"; }
function gcm { git checkout main; }
function gcmd { git checkout master; }
function gadd { git add "$@"; }
function gaddall { git add --all; }
function gcommit { git commit "$@"; } # usage: gcommit -m "msg"
function gp { git push "$@"; }
function gpo { git push origin "$@"; }
function gpull { git pull "$@"; }
function gclone { git clone "$@"; }
function gstash { git stash "$@"; }
function gpop { git stash pop "$@"; }
function gbr { git branch "$@"; }
function glog { git log --graph --decorate --oneline --all "$@"; }
function gmerge { git merge "$@"; }
# Extras
function gfp { git fetch --all --prune --tags "$@"; }
function grh { ref="${1:-HEAD}"; git reset --hard --recurse-submodules "$ref"; }
function gpr {
if [ -z "$1" ]; then echo "Usage: gpr <number> [remote] [branch]" >&2; return 2; fi
num="$1"; remote="${2:-origin}"; branch="${3:-pr-$num}"
git fetch "$remote" "pull/$num/head:$branch" && git checkout "$branch"
}
function gclean {
if [ "$1" = "-f" ]; then git clean -fdx; else git clean -ndx; echo "Add -f to actually remove (includes ignored files)."; fi
}
function gsh {
if [ $# -gt 0 ]; then msg="$*"; else br="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo HEAD)"; ts="$(date +%F_%H%M%S)"; msg="${br}-${ts}"; fi
git stash push -u -m "$msg"
}
function greup {
up="$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)"
if [ -z "$up" ]; then echo "No upstream configured for current branch." >&2; return 1; fi
git fetch --prune && git rebase "$up"
}
# Completions (git completion is already loaded by .bashrc)
if declare -F __git_complete >/dev/null 2>&1; then
__git_complete gco _git_checkout
__git_complete gcm _git_checkout
__git_complete gcmd _git_checkout
__git_complete gadd _git_add
__git_complete gbr _git_branch
__git_complete gp _git_push
__git_complete gpo _git_push
__git_complete gpull _git_pull
__git_complete glog _git_log
__git_complete gmerge _git_merge
__git_complete gfp _git_fetch
__git_complete grh _git_reset
__git_complete gclean _git_clean
__git_complete gsh _git_stash
__git_complete greup _git_rebase
fi
# =========================
# ~/.bashrc (interactive)
# =========================
# Only run for interactive shells
[[ $- != *i* ]] && return
# ----- History & shell behavior -----
shopt -s autocd cdspell checkwinsize cmdhist histappend histverify globstar
HISTCONTROL=ignoreboth:erasedups
HISTSIZE=200000
HISTFILESIZE=200000
HISTIGNORE='?:??'
_add_hist_pc() { history -a; }
case ":$PROMPT_COMMAND:" in
*:_add_hist_pc:*) ;;
*) PROMPT_COMMAND="_add_hist_pc${PROMPT_COMMAND:+; $PROMPT_COMMAND}";;
esac
# ----- Colors / lesspipe -----
if command -v dircolors >/dev/null 2>&1; then
eval "$(dircolors -b 2>/dev/null || true)"
fi
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# ----- Bash completion (incl. Git) -----
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
[ -f /usr/share/bash-completion/completions/git ] && . /usr/share/bash-completion/completions/git
[ -f /usr/share/git/completion/git-completion.bash ] && . /usr/share/git/completion/git-completion.bash
# ----- PATH bits: Go, ~/.local/bin, ~/bin -----
export GOPATH="${GOPATH:-$HOME/go}"
export PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"
[ -d "$HOME/.local/bin" ] && PATH="$PATH:$HOME/.local/bin"
[ -d "$HOME/bin" ] && PATH="$PATH:$HOME/bin"
# ----- bun -----
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# ----- Node managers: nvm preferred; fallback to fnm -----
if [ -s "$HOME/.nvm/nvm.sh" ]; then
. "$HOME/.nvm/nvm.sh"
[ -s "$HOME/.nvm/bash_completion" ] && . "$HOME/.nvm/bash_completion"
elif command -v fnm >/dev/null 2>&1; then
eval "$(fnm env --use-on-cd)"
fi
command -v corepack >/dev/null 2>&1 && corepack enable >/dev/null 2>&1
# ----- AWS defaults & completer -----
# export AWS_REGION="${AWS_REGION:-ap-southeast-2}"
# export AWS_DEFAULT_REGION="$AWS_REGION"
if command -v aws_completer >/dev/null 2>&1; then
complete -C "$(command -v aws_completer)" aws
fi
# ----- WSL niceties (only if running under WSL) -----
if grep -qi microsoft /proc/version 2>/dev/null; then
export BROWSER="/mnt/c/Windows/explorer.exe"
alias open='/mnt/c/Windows/explorer.exe'
alias clip='clip.exe'
alias pbcopy='clip.exe'
alias pbpaste='powershell.exe -NoProfile -Command Get-Clipboard'
[ -z "$DISPLAY" ] && export DISPLAY="$(grep -m1 nameserver /etc/resolv.conf | awk '{print $2}'):0"
fi
# ----- powerline-go prompt (unchanged) -----
_update_ps1() {
local exit_code=$?
if command -v powerline-go >/dev/null 2>&1; then
PS1="$(/usr/local/bin/powerline-go -modules aws,dotenv,shenv,direnv,venv,goenv,host,user,cwd,direnv,git,root -colorize-hostname -error $? -jobs $(jobs -p | wc -l))"
else
PS1='\u@\h:\w\$ '
fi
}
case ":$PROMPT_COMMAND:" in
*:_update_ps1:*) ;;
*) PROMPT_COMMAND="_update_ps1${PROMPT_COMMAND:+; $PROMPT_COMMAND}";;
esac
# ----- AWS completion & awsp alias -----
if [ -f "/usr/local/bin/aws_completer" ]; then
complete -C '/usr/local/bin/aws_completer' aws
# AWS Profilers
# https://github.com/jprice-da15252/aws-profile-select
if [ -f /usr/local/bin/aws-profile-select.sh ]; then
alias aps='source /usr/local/bin/aws-profile-select.sh'
fi
# https://github.com/johnnyopao/awsp
if [ -f /usr/bin/_awsp ]; then
alias awsp="source _awsp"
fi
fi
# Fuzzy search for bash history
if [ -f /usr/bin/fzf ]; then
FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border --color=dark'
if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
source /usr/share/doc/fzf/examples/key-bindings.bash
fi
fi
# ----- Load per-user aliases last -----
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
# Default permissions
umask 022
# Default configuration file for tmux-powerline.
# Modeline {
# vi: foldmarker={,} foldmethod=marker foldlevel=0 tabstop=4 filetype=sh
# }
# General {
# Show which segment fails and its exit code.
export TMUX_POWERLINE_DEBUG_MODE_ENABLED="false"
# Use patched font symbols.
export TMUX_POWERLINE_PATCHED_FONT_IN_USE="true"
# The theme to use.
export TMUX_POWERLINE_THEME="default"
# Overlay directory to look for themes. There you can put your own themes outside the repo. Fallback will still be the "themes" directory in the repo.
export TMUX_POWERLINE_DIR_USER_THEMES="${XDG_CONFIG_HOME:-$HOME/.config}/tmux-powerline/themes"
# Overlay directory to look for segments. There you can put your own segments outside the repo. Fallback will still be the "segments" directory in the repo.
export TMUX_POWERLINE_DIR_USER_SEGMENTS="${XDG_CONFIG_HOME:-$HOME/.config}/tmux-powerline/segments"
# The initial visibility of the status bar. Can be {"on, off"}.
export TMUX_POWERLINE_STATUS_VISIBILITY="on"
# The status bar refresh interval in seconds.
# Note that events that force-refresh the status bar (such as window renaming) will ignore this.
export TMUX_POWERLINE_STATUS_INTERVAL="1"
# The location of the window list. Can be {"absolute-centre, centre, left, right"}.
export TMUX_POWERLINE_STATUS_JUSTIFICATION="left"
# The maximum length of the left status bar.
export TMUX_POWERLINE_STATUS_LEFT_LENGTH="80"
# The maximum length of the right status bar.
export TMUX_POWERLINE_STATUS_RIGHT_LENGTH="90"
# Uncomment these if you want to enable tmux bindings for muting (hiding) one of the status bars.
# E.g. this example binding would mute the left status bar when pressing <prefix> followed by Ctrl-[
#export TMUX_POWERLINE_MUTE_LEFT_KEYBINDING="C-["
#export TMUX_POWERLINE_MUTE_RIGHT_KEYBINDING="C-]"
# }
# battery.sh {
# How to display battery remaining. Can be {percentage, cute}.
export TMUX_POWERLINE_SEG_BATTERY_TYPE="percentage"
# How may hearts to show if cute indicators are used.
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="5"
# }
# date.sh {
# date(1) format for the date. If you don't, for some reason, like ISO 8601 format you might want to have "%D" or "%m/%d/%Y".
export TMUX_POWERLINE_SEG_DATE_FORMAT="%F"
# }
# disk_usage.sh {
# Filesystem to retrieve disk space information. Any from the filesystems available (run "df | awk '{print }'" to check them).
export TMUX_POWERLINE_SEG_DISK_USAGE_FILESYSTEM="/"
# }
# earthquake.sh {
# The data provider to use. Currently only "goo" is supported.
export TMUX_POWERLINE_SEG_EARTHQUAKE_DATA_PROVIDER="goo"
# How often to update the earthquake data in seconds.
# Note: This is not an early warning detector, use this
# to be informed about recent earthquake magnitudes in your
# area. If this is too often, goo may decide to ban you form
# their server
export TMUX_POWERLINE_SEG_EARTHQUAKE_UPDATE_PERIOD="600"
# Only display information when earthquakes are within this many minutes
export TMUX_POWERLINE_SEG_EARTHQUAKE_ALERT_TIME_WINDOW="60"
# Display time with this format
export TMUX_POWERLINE_SEG_EARTHQUAKE_TIME_FORMAT='(%H:%M)'
# Display only if magnitude is greater or equal to this number
export TMUX_POWERLINE_SEG_EARTHQUAKE_MIN_MAGNITUDE="3"
# }
# hostname.sh {
# Use short or long format for the hostname. Can be {"short, long"}.
export TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="short"
# }
# macos_notification_count.sh {
# App ids to query in notification center, separated by space
# To get the app id that is associated with a specific app run:
# sqlite3 -list "/com.apple.notificationcenter/db/db" 'select * from app_info'
# The first column contains the app ids
# "5" is the app id of Messages.app
# Only "banner" notifications are supported (see settings in the notification center)
export TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS="5"
# Notification symbol
export TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_CHAR="💬"
# }
# mailcount.sh {
# Mailbox type to use. Can be any of {apple_mail, gmail, maildir, mbox, mailcheck}
export TMUX_POWERLINE_SEG_MAILCOUNT_MAILBOX_TYPE=""
## Gmail
# Enter your Gmail username here WITH OUT @gmail.com.( OR @domain)
export TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_USERNAME=""
# Google password. Recomenned to use application specific password (https://accounts.google.com/b/0/IssuedAuthSubTokens) Leave this empty to get password from OS X keychain.
# For OSX users : MAKE SURE that you add a key to the keychain in the format as follows
# Keychain Item name : http://<value-you-fill-in-server-variable-below>
# Account name : <username-below>@<server-below>
# Password : Your password ( Once again, try to use 2 step-verification and application-specific password)
# See http://support.google.com/accounts/bin/answer.py?hl=en&answer=185833 for more info.
export TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_PASSWORD=""
# Domain name that will complete your email. For normal GMail users it probably is "gmail.com but can be "foo.tld" for Google Apps users.
export TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER="gmail.com"
# How often in minutes to check for new mails.
export TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_INTERVAL="5"
## Maildir
# Path to the maildir to check.
export TMUX_POWERLINE_SEG_MAILCOUNT_MAILDIR_INBOX="$HOME/.mail/inbox/new"
## mbox
# Path to the mbox to check.
export TMUX_POWERLINE_SEG_MAILCOUNT_MBOX_INBOX=""
## mailcheck
# Optional path to mailcheckrc
export TMUX_POWERLINE_SEG_MAILCOUNT_MAILCHECKRC="$HOME/.mailcheckrc"
# }
# now_playing.sh {
# Music player to use. Can be any of {audacious, banshee, cmus, itunes, lastfm, mocp, mpd, mpd_simple, pithos, playerctl, rdio, rhythmbox, spotify, spotify_wine, file}.
export TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER="spotify"
# File to be read in case the song is being read from a file
export TMUX_POWERLINE_SEG_NOW_PLAYING_FILE_NAME=""
# Maximum output length.
export TMUX_POWERLINE_SEG_NOW_PLAYING_MAX_LEN="40"
# How to handle too long strings. Can be {trim, roll}.
export TMUX_POWERLINE_SEG_NOW_PLAYING_TRIM_METHOD="trim"
# Charcters per second to roll if rolling trim method is used.
export TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_SPEED="2"
# Hostname for MPD server in the format "[password@]host"
export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_HOST="localhost"
# Port the MPD server is running on.
export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_PORT="6600"
# Song display format for mpd_simple. See mpc(1) for delimiters.
export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_SIMPLE_FORMAT="%artist% - %title%"
# Song display format for playerctl. see "Format Strings" in playerctl(1).
export TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT="{{ artist }} - {{ title }}"
# Song display format for rhythmbox. see "FORMATS" in rhythmbox-client(1).
export TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT="%aa - %tt"
# Last.fm
# Set up steps for Last.fm
# 1. Make sure jq(1) is installed on the system.
# 2. Create a new API application at https://www.last.fm/api/account/create (name it tmux-powerline) and copy the API key and insert it below in the setting TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_API_KEY
# 3. Make sure the API can access your recently played song by going to you user privacy settings https://www.last.fm/settings/privacy and make sure "Hide recent listening information" is UNCHECKED.
# Username for Last.fm if that music player is used.
export TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_USERNAME=""
# API Key for the API.
export TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_API_KEY=""
# How often in seconds to update the data from last.fm.
export TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_UPDATE_PERIOD="30"
# Fancy char to display before now playing track
export TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR="♫"
# }
# pwd.sh {
# Maximum length of output.
export TMUX_POWERLINE_SEG_PWD_MAX_LEN="40"
# }
# time.sh {
# date(1) format for the time. Americans might want to have "%I:%M %p".
export TMUX_POWERLINE_SEG_TIME_FORMAT="%H:%M"
# }
# tmux_session_info.sh {
# Session info format to feed into the command: tmux display-message -p
# For example, if FORMAT is '[ #S ]', the command is: tmux display-message -p '[ #S ]'
export TMUX_POWERLINE_SEG_TMUX_SESSION_INFO_FORMAT="#S:#I.#P"
# }
# utc_time.sh {
# date(1) format for the UTC time.
export TMUX_POWERLINE_SEG_UTC_TIME_FORMAT="%H:%M %Z"
# }
# vcs_branch.sh {
# Max length of the branch name.
export TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN="24"
# }
# weather.sh {
# The data provider to use. Currently only "yahoo" is supported.
export TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER="yrno"
# What unit to use. Can be any of {c,f,k}.
export TMUX_POWERLINE_SEG_WEATHER_UNIT="c"
# How often to update the weather in seconds.
export TMUX_POWERLINE_SEG_WEATHER_UPDATE_PERIOD="600"
# Name of GNU grep binary if in PATH, or path to it.
export TMUX_POWERLINE_SEG_WEATHER_GREP="grep"
# Location of the JSON parser, jq
export TMUX_POWERLINE_SEG_WEATHER_JSON="jq"
# Your location
# Latitude and Longtitude for use with yr.no
TMUX_POWERLINE_SEG_WEATHER_LAT=""
TMUX_POWERLINE_SEG_WEATHER_LON=""
# }
set -sg escape-time 10
# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# run-shell "powerline-daemon -q"
# source "/usr/share/powerline/bindings/tmux/powerline.conf"
# DON'T paste this line in, if you DON'T want vim keybindings
# Set tmux mode to vi (default is emac)
set-window-option -g mode-keys vi
# Set Window Title Dynamically
set-option -g set-titles on
set -g set-titles-string "#T"
# Set History
set -g history-limit 30000
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'erikw/tmux-powerline'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# ~/.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
# Bash shell settings
# Typing a directory name just by itself will automatically change into that directory.
shopt -s autocd
# Automatically fix directory name typos when changing directory.
shopt -s cdspell
# Automatically expand directory globs and fix directory name typos whilst completing.
# Note, this works in conjuction with the cdspell option listed above.
shopt -s direxpand dirspell
# Enable the ** globstar recursive pattern in file and directory expansions.
# For example, ls **/*.txt will list all text files in the current directory hierarchy.
shopt -s globstar
# Ignore lines which begin with a <space> and match previous entries.
# Erase duplicate entries in history file.
HISTCONTROL=ignoreboth:erasedups
# Ignore saving short- and other listed commands to the history file.
HISTIGNORE='?:??'
# The maximum number of lines in the history file.
HISTFILESIZE=99999
# The number of entries to save in the history file.
HISTSIZE=99999
# Set Bash to save each command to history, right after it has been executed.
# PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
PROMPT_COMMAND='history -a'
# Save multi-line commands in one history entry.
shopt -s cmdhist
# Append commands to the history file, instead of overwriting it.
# History substitution are not immediately passed to the shell parser.
shopt -s histappend histverify
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
if [ "$UID" = 0 ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='\[\e[0;31m\]\h \[\e[1;34m\](\[\e[0;31m\]\u\[\e[1;34m\])\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$\[\e[m\]\[\e[0;37m\] '
# PS1="\${debian_chroot:+($debian_chroot)}\[\e[0;31m\]\h \[\e[1;34m\](\[\e[0;31m\]\u\[\e[1;34m\])\[\e[m\]:\[\e[1;34m\]\w\[\e[m\]\[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\[\e[0;31m\]\\$\[\e[m\]\[\e[0;37m\] "
else
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='\[\e[0;32m\]\h \[\e[1;34m\](\[\e[0;32m\]\u\[\e[1;34m\])\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\]\[\e[0;37m\] '
# PS1="\${debian_chroot:+($debian_chroot)}\[\e[0;32m\]\h \[\e[1;34m\](\[\e[0;32m\]\u\[\e[1;34m\])\[\e[m\]:\[\e[1;34m\]\w\[\e[m\]\[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\[\e[1;32m\]\\$\[\e[m\]\[\e[0;37m\] "
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# 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 -h'
#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'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# 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
if [ "$UID" = 0 ]; then
if [ -f /root/.acme.sh/acme.sh.env ]; then
. "/root/.acme.sh/acme.sh.env"
fi
fi
if [[ -z "$XDG_RUNTIME_DIR" ]]; then
export XDG_RUNTIME_DIR=/run/user/$UID
if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
export XDG_RUNTIME_DIR=/tmp/$USER-runtime
if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
mkdir -m 0700 "$XDG_RUNTIME_DIR"
fi
fi
fi
# cat <<< "host *
# AddKeysToAgent yes
#
# $(cat ~/.ssh/config)" > ~/.ssh/config
#
# Start ssh-agent daemon automatically when logging in if not running.
if [ -f "/usr/bin/ssh-agent" ]; then
SSH_AGENT_TYPE="ssh"
SSH_AGENT_INFO="${HOME}/.ssh-agent"
source_agent_info() {
export SSH_AUTH_SOCK=''
export SSH_AGENT_PID=''
if [[ -f ${SSH_AGENT_INFO} ]]; then
source "${SSH_AGENT_INFO}"
fi
}
agent_running() {
source_agent_info
proc_file="/proc/${SSH_AGENT_PID}/cmdline"
if [[ "${SSH_AGENT_PID}" =~ ^[0-9]+$ ]] && \
stat "${proc_file}" &> /dev/null && \
grep ssh-agent "${proc_file}" &> /dev/null; then
return 0
else
return 1
fi
}
run_ssh_agent() {
ssh-agent 2>&1 | grep -v echo > "${SSH_AGENT_INFO}"
source_agent_info
}
if ! agent_running; then
run_ssh_agent
fi
fi
# Start of WSL tweaks
# Docker setup
# https://dev.to/mrstardom/how-to-run-podman-on-windows-subsystem-for-linux-wsl2-ubuntu-20-04-4l02
# https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9
# https://medium.com/geekculture/run-docker-in-windows-10-11-wsl-without-docker-desktop-a2a7eb90556d
# sudo usermod -aG docker $USER
# Docker daemon specification
# %docker ALL=(ALL) NOPASSWD: /usr/bin/dockerd
# Start Docker daemon automatically when logging in if not running.
# make sure user is in sudoers file
# if [ -f "/usr/bin/dockerd" ]; then
# if ! pidof dockerd >/dev/null; then
# sudo service docker restart > /dev/null 2>&1
# fi
# fi
# Podman - alternative to docker
# https://www.redhat.com/sysadmin/podman-windows-wsl2
# End of WSL tweaks
if [ -f "/usr/local/go/bin/go" ]; then
export PATH=$PATH:/usr/local/go/bin/go
if [ -f "/usr/local/bin/gocomplete" ]; then
complete -C /usr/local/bin/gocomplete go
fi
fi
if [ -f "$HOME/bin/" ]; then
export PATH=$PATH:$HOME/bin/
fi
if [ -f "/usr/local/bin/aws_completer" ]; then
complete -C '/usr/local/bin/aws_completer' aws
#AWS Profilers
# https://github.com/jprice-da15252/aws-profile-select
if [ -f /usr/local/bin/aws-profile-select.sh ]; then
alias aps='source /usr/local/bin/aws-profile-select.sh'
fi
# https://github.com/johnnyopao/awsp
if [ -f /usr/bin/_awsp ]; then
alias awsp="source _awsp"
fi
fi
# sudo mkdir -p /etc/apt/keyrings
# wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
# echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
# sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
# sudo apt update
# sudo apt install -y eza
if eza --version >/dev/null 2>&1; then
# exa - updated version of ls. To use icons, install fonts from Nerd Fonts on to local system and select font in font options for your terminal program
alias eza='eza --icons -b --header --git -g --color=always --group-directories-first'
alias ls='eza'
fi
if [ -f "/usr/local/bin/bat" ]; then
alias cat="bat --pager=never -p"
alias pcat="bat+ --pager=auto"
fi
if [ -f "$HOME/.local/bin/thefuck" ] || [ -f "/usr/local/bin/thefuck" ]; then
# sudo apt update
# sudo apt install python3-dev python3-pip python3-setuptools
# pip3 install thefuck --user
eval "$(thefuck --alias WTF)"
fi
# Set Dynamic Window Title
source /etc/os-release
PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}: ${PWD}\007"'
# 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
if [ -f "/usr/local/bin/starship" ]; then
eval "$(starship init bash)"
fi
if [ -f "/usr/share/powerline/bash/powerline.sh" ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bash/powerline.sh
fi
if [ -f "/usr/local/bin/powerline-go" ]; then
function _update_ps1() {
PS1="$(/usr/local/bin/powerline-go -modules aws,dotenv,shenv,direnv,venv,goenv,user,host,cwd,direnv,git,root -colorize-hostname -error $? -jobs $(jobs -p | wc -l))"
# Uncomment the following line to automatically clear errors after showing
# them once. This not only clears the error for powerline-go, but also for
# everything else you run in that shell. Don't enable this if you're not
# sure this is what you want.
#set "?"
}
if [ "$TERM" != "linux" ] && [ -f "/usr/local/bin/powerline-go" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
fi
set -sg escape-time 10
# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# run-shell "powerline-daemon -q"
# source "/usr/share/tmux/powerline.conf"
# DON'T paste this line in, if you DON'T want vim keybindings
# Set tmux mode to vi (default is emac)
set-window-option -g mode-keys vi
# Set Window Title Dynamically
set-option -g set-titles on
set -g set-titles-string "#T"
# Set History
set -g history-limit 30000
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'erikw/tmux-powerline'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
#!/bin/bash
[[ "$@" =~ 'starship' ]] && STARSHIP=true
[[ "$@" =~ 'thefuck' ]] && THEFUCK=true
[[ "$@" =~ 'pwrlinelegacy' ]] && PWRLEGACY=true
[[ "$@" =~ 'tmux' ]] && TMUX=true
PWLINE=''
# OS=$(</etc/issue.net)
source /etc/os-release
OS=$NAME
if [[ "$OS" =~ Ubuntu ]]; then
echo "Ubuntu found"
DISTRO=UB
elif [[ "$OS" =~ Debian ]]; then
echo "Debian found"
DISTRO=DEB
elif [[ "$OS" =~ AlmaLinux ]]; then
echo "AlmaLinux found"
DISTRO=ALMA
else
echo "FATAL: Unknown OS found: $OS"
exit 1;
fi
if [[ $DISTRO == "UB" ]] || [[ $DISTRO == "DEB" ]]; then
if [[ $PWRLEGACY ]]; then
$PWLINE='powerline powerline-gitstatus'
fi
sudo apt update
sudo apt -y install unzip curl zip wget bash-completion vim-nox fonts-powerline bat tmux byobu fzf git gpg $PWLINE
sudo sed -i 's/^#precedence ::ffff:0:0\/96 100/precedence ::ffff:0:0\/96 100/' /etc/gai.conf
echo "Using eza as ls replacement"
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update
sudo apt install -y eza
sudo wget "https://raw.githubusercontent.com/eza-community/eza/main/completions/bash/eza" -O /etc/bash_completion.d/eza
fi
if [[ $DISTRO == "ALMA" ]]; then
if [[ $PWRLEGACY ]]; then
$PWLINE='powerline tmux-powerline'
fi
sudo dnf update
sudo dnf -y install unzip curl zip wget gpg bash-completion vim powerline-fonts bat $PWLINE
echo "Using eza as ls replacement"
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update
sudo apt install -y eza
fi
if [[ $STARSHIP ]]; then
echo "Installing Starship Prompt"
curl -sS https://starship.rs/install.sh | sh
mkdir -p ~/.config
wget -O ~/.config/starship.toml "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/starship.toml"
fi
if [[ ! $PWRLEGACY ]]; then
sudo wget -O /usr/local/bin/powerline-go "https://github.com/justjanne/powerline-go/releases/download/v1.26/powerline-go-linux-amd64"
sudo chmod +x /usr/local/bin/powerline-go
fi
wget -O ~/.bashrc "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/.bashrc"
wget -O ~/.bash_aliases "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/.bash_aliases"
wget -O ~/.tmux.conf "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/.tmux.conf"
if [[ $DISTRO == "ALMA" ]]; then
wget -O ~/.tmux.conf "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/alma_tmux.conf"
wget -O ~/.bashrc "https://gist.github.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/alma_bashrc"
fi
source ~/.bashrc
echo "For AWS profile selector see https://github.com/johnnyopao/awsp"
# npm install -g awsp
# Add the following to your .bashrc or .bash_aliases or .zshrc config
# alias awsp="source _awsp"
if [[ $THEFUCK ]]; then
echo "Installing thef$#k"
sudo apt update
sudo apt -y install python3-dev python3-pip python3-setuptools
pip3 install thefuck
fi
# Plugins for tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Basic tmux plugins config
wget -O ~/.tmux-powerlinerc https://gist.githubusercontent.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/.tmux-powerlinerc
source ~/.bashrc
# VIM Fix in Debian
if [[ $DISTRO == "UB" ]] || [[ $DISTRO == "DEB" ]]; then
sudo sed -i 's/set mouse=.*/set mouse=/g' $(find /usr -name defaults.vim)
fi
# Snap Clean Up
if [[ $DISTRO == "UB" ]] || [[ $DISTRO == "DEB" ]]; then
sudo wget -O /usr/local/bin/snap_cleanup.sh "https://gist.githubusercontent.com/mrevjd/267c40413244fabc811bd1a227732b67/raw/a24cef6d9488244141632cd498ac24c78e69482f/snap_cleanup.sh"
sudo chmod 0755 /usr/local/bin/snap_cleanup.sh
sudo ln -sf /usr/local/bin/snap_cleanup.sh /etc/cron.daily/
fi
# Fix cursor size for X11 apps
wget -O ~/set-cursor.sh https://gist.githubusercontent.com/mrevjd/b034c3afaba3f2627fb1c47291885f3b/raw/set-cursor.sh
chmod +x ~/set-cursor.sh
./set-cursor.sh
# Sudoers custom file
echo 'Defaults env_keep += "SSH_CLIENT"' | sudo tee /etc/sudoers.d/custom
sudo chmod 0440 /etc/sudoers.d/custom
# WSL config
if [[ $(uname -a | grep -ic wsl) -gt 0 ]]; then
echo '[network]' | sudo tee /etc/wsl.conf
echo 'generateresolvconf = true' | sudo tee -a /etc/wsl.conf
echo '[automount]' | sudo tee -a /etc/wsl.conf
echo 'enabled=true' | sudo tee -a /etc/wsl.conf
echo '[boot]' | sudo tee -a /etc/wsl.conf
echo 'systemd=true' | sudo tee -a /etc/wsl.conf
fi
echo ""
echo ""
#!/bin/bash
#Removes old revisions of snaps
#CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
# Install from https://starship.rs/guide/
format = """
[┌](fg:#ffffff)\
[](fg:#ffffff)\
$username\
$hostname\
[](bg:#DA627D fg:#ffffff)\
$directory\
[](fg:#DA627D bg:#FCA17D)\
$git_branch\
$git_status\
[ ](bg:#FCA17D)\
[](fg:#FCA17D bg:#000000)\
$nodejs\
$python\
$perl\
$php\
$golang\
[](fg:#000000 bg:#33658A)\
[](bg:#000000 fg:#33658A)\
$aws\
[](bg:#FE9800 fg:#000000)\
[](fg:#FE9800 bg:#000000)\
[](fg:#ffffff)
[└❯$cmd_duration](fg:#ffffff)\
$character"""
# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'
# Disable the blank line at the start of the prompt
add_newline = false
# A continuation prompt that displays two filled in arrows
continuation_prompt = "▶▶ "
# Wait 10 milliseconds for starship to check files under the current directory.
scan_timeout = 1000
# Wait 1000 milliseconds for starship commands to executed.
command_timeout = 1000
# You can also replace your username with a neat symbol like  to save some space
[username]
show_always = true
style_user = "bg:#ffffff fg:#00aa00"
style_root = "bg:#ffffff fg:#aa0000"
format = '($style)[ $user ]($style)'
[hostname]
ssh_only = true
format = "[@$ssh_symbol](bold blue bg:#ffffff)[$hostname ](bold blue bg:#ffffff)"
disabled = false
[directory]
style = "bg:#DA627D"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
# Here is how you can shorten some long paths by text replacement
# similar to mapped_locations in Oh My Posh:
[directory.substitutions]
"Documents" = " "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
# Keep in mind that the order matters. For example:
# "Important Documents" = "  "
# will not be replaced, because "Documents" was already substituted before.
# So either put "Important Documents" before "Documents" or use the substituted version:
"Important  " = "  "
[cmd_duration]
min_time = 4
show_milliseconds = false
disabled = false
format = " 🕙 $duration($style) "
style = "bold italic #87A752"
[aws.region_aliases]
ap-southeast-2 = "au"
us-east-1 = "va"
[aws]
style = "#FE9800 bg:#000000"
format = "[$symbol $profile on $region]($style)"
symbol = "☁️ "
[git_branch]
symbol = ""
style = "bold bg:#FCA17D fg:#000000"
format = '[$symbol $branch]($style)'
[git_status]
style = "bold bg:#FCA17D fg:#000000"
conflicted = "${count}💀 "
up_to_date = "✅"
untracked = " ${count}🤷 "
stashed = " ${count}📦 "
modified = " ${count}📝 "
staged = " ${count}🚀 "
renamed = " ${count}👅 "
deleted = " ${count}🗑 "
ahead = " ${count}⬆️ "
behind = " ${count}⬇️ "
diverged = " ${ahead_count}⬆️ ${behind_count}⬇️"
# format = " ${all_status} ${ahead_behind}"
format = "[$all_status$ahead_behind](bg:#FCA17D fg:#000000)"
[golang]
format = "[ $symbol$version](bold #79D4FD) "
[nodejs]
format = "[ $symbol$version](bold #77B063)"
[perl]
format = "[ $symbol$version](bold #550000)"
[php]
format = "[ $symbol$version](bold #7175aa)"
[python]
format = "[ $symbol$version](bold #3476AB)"
[time]
disabled = true
time_format = "%R" # Hour:Minute Format
style = "bg:#33658A"
format = '[[ ♥ $time ]](bg:#33658A)'
[character]
# success_symbol = "[λ](green)"
# error_symbol = "[λ](bold red)"
success_symbol = "[✓](bold green)"
error_symbol = "[×](bold red)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment