From 9de44888ba1319b40c13e8037246676c17717c34 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 27 Jan 2026 15:41:57 +0200 Subject: [PATCH] Move all aliases to bash aliases. Make a bash_prompt file for prompt styling. Update README --- .bash_aliases | 43 ++++++++++++++++++++++++++++++------------- .bash_prompt | 28 ++++++++++++++++++++++++++++ README.md | 2 ++ 3 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 .bash_prompt diff --git a/.bash_aliases b/.bash_aliases index 55464f2..39891a1 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,21 +1,38 @@ -alias gm="git checkout master && git pull" +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 + +# ls aliases alias count="ls -l | wc -l" +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + alias c="clear" -function gcam() { git commit -a -m "$1"; } - -function dt() { - nohup "$@" /dev/null 2>&1 & - disown -} - function csa(){ cd $1 && ls -a; } function cs(){ cd $1 && ls; } -function mkcdir () -{ - mkdir "$1" && - cd "$1" -} +# Git aliases +function gcam() { git commit -a -m "$1"; } + +function dt() { nohup "$@" /dev/null 2>&1 & disown; } + +alias gm="git checkout main && git pull" + + +function mkcdir () { mkdir "$1" && cd "$1"; } alias scripts="jq .scripts package.json" + +# 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$//'\'')"' + +alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' \ No newline at end of file diff --git a/.bash_prompt b/.bash_prompt new file mode 100644 index 0000000..ca7c75d --- /dev/null +++ b/.bash_prompt @@ -0,0 +1,28 @@ +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +function parse_git_branch() { + # git branch --show-current 2>/dev/null | sed 's/^/ (/' | sed 's/$/)/' + + local branch + branch=$(git branch --show-current 2>/dev/null) + #[[ -n "$branch" ]] && printf ' \033[44;30m %s \033[0;34m\ue0b0\033[0m' "$branch" + + if [[ -n "$branch" ]]; then + printf '\033[44;33m'$'\ue0b0''\033[44;30m %s \033[0;34m'$'\ue0b0''\033[0m' "$branch" + else + printf '\033[0;33m'$'\ue0b0''\033[0m' + fi + } + +if [ "$color_prompt" = yes ]; then + PS1='\[\033[43;30m\] \w \[$(parse_git_branch)\] ' +else + PS1='\w\$ ' +fi + +unset color_prompt + +printf '\033[3 q' \ No newline at end of file diff --git a/README.md b/README.md index 554c673..80c267b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi +Also a .bash_prompt file is included that can be included in the same way as the bash_aliases. It provides styling for the prompt + ## Tmux uses the tpm for plugins https://github.com/tmux-plugins/tpm