From ea3990e2983d70b675225ad6fd0a1a985d28ede7 Mon Sep 17 00:00:00 2001 From: pankunull Date: Sun, 24 Aug 2025 00:13:20 +0200 Subject: Added bashrc_ps1 and re-styled PS1. Vim now can toggle on/off the line number with F2 and activate relativenumber with F4. --- .bashrc | 19 +++++++++++++++++++ .bashrc_ps1 | 45 +++++++++++++++++++++++++++++++++++++++++++++ .tmux.conf | 9 +++++++++ .vimrc | 6 ++++++ 4 files changed, 79 insertions(+) create mode 100644 .bashrc create mode 100644 .bashrc_ps1 diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..2451338 --- /dev/null +++ b/.bashrc @@ -0,0 +1,19 @@ +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Source dotfiles +source ~/.bashrc_ps1 +source ~/.bashrc_alias + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# PATH +export PATH=~/bin:$PATH + +# Title bar +#echo -ne "\033]0;$(lsb_release -ds) $(hostname) $(uname -r)\007" diff --git a/.bashrc_ps1 b/.bashrc_ps1 new file mode 100644 index 0000000..33daa0d --- /dev/null +++ b/.bashrc_ps1 @@ -0,0 +1,45 @@ +# Dynamic PS1: exit code, time, user, current directory, git, colorized +function update_ps1 { + local exit_code=$? + + # Color exit code: green if 0, red otherwise + if [[ $exit_code -eq 0 ]]; then + local exit_display="\[\033[1;32m\]$exit_code\[\033[0m\]" # green + else + local exit_display="\[\033[1;31m\]$exit_code\[\033[0m\]" # red + fi + + # Symbol always white + local symbol="\[\033[1;37m\]\$\[\033[0m\]" + + # White brackets + local open_bracket="\[\033[1;37m\][\[\033[0m\]" + local close_bracket="\[\033[1;37m\]]\[\033[0m\]" + + # Time in HH:MM:SS + #local time="\[\033[1;37m\]\t\[\033[0m\]" + + # User + #local user="\[\033[1;37m\]\u\[\033[0m\]" + local user="\[\033[1;36m\]\u\[\033[0m\]" + + # Current folder only, ~ for home + local folder="\[\033[1;33m\]\W\[\033[0m\]" + + # Git status + local git_status="" + if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == true ]]; then + if [[ -z $(git log origin/master..HEAD 2>/dev/null) ]]; then + git_status="\[\033[1;38;5;10m\](git)\[\033[0m\]" # green if up to date + else + git_status="\[\033[1;38;5;9m\](git)\[\033[0m\]" # red if ahead + fi + fi + + # Build the prompt + export PS1="${open_bracket} ${exit_display} ${user} ${folder} ${git_status}${close_bracket} ${symbol} " +} + + +# Update PS1 after every command +PROMPT_COMMAND='update_ps1' diff --git a/.tmux.conf b/.tmux.conf index c1a7e01..7b66371 100755 --- a/.tmux.conf +++ b/.tmux.conf @@ -10,6 +10,15 @@ set -g terminal-overrides ',*:Tc' # Pass through bracketed paste bind-key ] run-shell "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer" +# Swap window +bind-key -n M-a swap-window -t -1\; previous-window +bind-key -n M-s swap-window -t +1\; next-window + +# Move +bind-key -n M-q previous-window +bind-key -n M-w next-window + + # Explicitly enable bracketed paste in terminals that support it set-option -ga terminal-features ',xterm*:clipboard,bpaste' diff --git a/.vimrc b/.vimrc index 27e132c..1448eef 100755 --- a/.vimrc +++ b/.vimrc @@ -13,6 +13,12 @@ set smartindent set scrolloff=999 set mouse=a +" F2: absolute numbers only +nnoremap :set number! + +" F4: absolute numbers only +nnoremap :set relativenumber! + if &term =~ 'tmux\|xterm\|konsole' " Map HOME key to move to beginning of line in normal mode noremap [1~ 0 -- cgit v1.2.3