Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 4.0.0 #9

Merged
merged 38 commits into from
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
746359e
(docs) add powershell badge
PrashanthaTP Oct 9, 2021
d3d502c
(feat) add vim settings
PrashanthaTP Oct 11, 2021
7f50b1d
(chore) set scrolloff
PrashanthaTP Oct 12, 2021
f3e1c48
(chore) change shortcuts related to load/open vimrc
PrashanthaTP Oct 12, 2021
a130856
(feat) add tmux configuration
PrashanthaTP Oct 12, 2021
c26d4b2
(docs) add tmux badge
PrashanthaTP Oct 12, 2021
ec80204
(feat) modify tmux statusbar and add pane keybindings
PrashanthaTP Oct 23, 2021
f398482
chore(bash): change default editor/visual to vim
PrashanthaTP Oct 24, 2021
9a8f895
feat(bash,tmux): open tmux session on bash startup
PrashanthaTP Oct 24, 2021
30a44fe
chore(vim): expand tabs with spaces
PrashanthaTP Oct 24, 2021
87bcac5
feat(tmux): add popup session for vimwiki
PrashanthaTP Oct 24, 2021
dda63f7
feat(tmux): improve shortcuts for editing config files
PrashanthaTP Oct 29, 2021
a6598d8
chore(docs): edit warning info
PrashanthaTP Oct 29, 2021
9d7e455
feat(tmux): customize split border colors
PrashanthaTP Oct 29, 2021
8594efd
refactor(bash): cleanup bashrc
PrashanthaTP Oct 30, 2021
fe4c97a
feat(bash): add custom git prompt
PrashanthaTP Oct 31, 2021
3caf4b4
chore(git): add gitignore file
PrashanthaTP Nov 1, 2021
c602c86
refactor(vim): change config dir for vim
PrashanthaTP Nov 1, 2021
7540b0a
feat(bash): add different prompts
PrashanthaTP Nov 1, 2021
348d3a0
feat(pandoc): add utils/script for markdown to pdf conversion
PrashanthaTP Nov 4, 2021
0d34052
feat(nvim): use netrw instead of nerdtree
PrashanthaTP Nov 6, 2021
fbadb1e
chore(git): dont ignore neovim config files
PrashanthaTP Nov 14, 2021
3e72b1d
fix(powershell,vim): support custom vimrc directory
PrashanthaTP Nov 14, 2021
4bf667b
chore(nvim): update fzf keybindings
PrashanthaTP Nov 14, 2021
85d2418
chore(vim): set bg for vim while in git commit msg
PrashanthaTP Nov 14, 2021
43c350e
chore(nvim): update keybindings for telescope
PrashanthaTP Nov 14, 2021
0ce6c0a
chore(nvim): add tmux/nvim related color settings
PrashanthaTP Nov 14, 2021
334969b
chore(nvim): some setting/unsettings
PrashanthaTP Nov 14, 2021
1bd0672
feat(bash): add fzy related bash functions
PrashanthaTP Nov 14, 2021
3496a5d
feat(bash,tmux): create default tmux session
PrashanthaTP Nov 14, 2021
c2a2793
feat(tmux): edit existing popups to use fzy
PrashanthaTP Nov 14, 2021
622bef3
chore(git): ignore tmux plugins folder
PrashanthaTP Nov 14, 2021
87780ef
feat(vim): support custom dir for vimrc
PrashanthaTP Nov 14, 2021
4d5774f
chore(nvim): add netrw related functions
PrashanthaTP Nov 14, 2021
cee0f57
chore(git): ignore vim swap folder
PrashanthaTP Nov 14, 2021
2d0e8ad
chore(bash): source prompt related and tmux startup.sh
PrashanthaTP Nov 14, 2021
6fd8bb5
chore(git): only allow certain dirs inside .config folder
PrashanthaTP Nov 14, 2021
608c181
chore(nvim): add some netrw settings
PrashanthaTP Nov 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
#############################################################################
# ┌────────────────────┐
# │ BASHRC │
# └────────────────────┘
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
#export TERM=xterm-256color
VISUAL=nvim
EDITOR=nvim
export TERM=xterm-256color
VISUAL=vim
EDITOR=vim
HISTSIZE=1000
HISTFILESIZE=2000
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
#############################################################################
# ┌─────────────────────────────┐
# │ ALIASES & FUNCTIONS │
# └─────────────────────────────┘
# must be sourced first
#############################################################################
source "$HOME/.config/bash/.bash_aliases"
source "$HOME/.config/bash/.bash_functions"

#############################################################################
# ┌────────────────────┐
# │ ZSH │
# └────────────────────┘
# https://gist.github.com/fworks/af4c896c9de47d827d4caa6fd7154b6b
#############################################################################
# Launch Zsh
#if [ -t 1 ]; then
#exec zsh-5.8
#fi

# export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
#export PS1="\[\033[35m\]\u@\[\033[32m\]\h \[\033[33m\]\w \[\033[91m\]\$(parse_git_branch)\[\033[00m\]$ "
# PROMPT_COMMAND='echo -e "\e[?16;0;200c"'
alias configfiles='git --git-dir="D:\dotfiles\dotfiles" --work-tree="$HOME"'
################################################################################################################
# export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[0;32m\]$(if git rev-parse --git-dir > /dev/null 2>&1; then echo " - ["; fi)$(git branch 2>/dev/null | grep "^*" )\[\033[0;32m\]$(if git rev-parse --git-dir > /dev/null 2>&1; then echo "]"; fi)\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
# export PS1="\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]\u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)\n\[\033[0;32m\]└─\[\033[0m\]\[\033[0;32m\] \$\[\033[0m\]\[\033[0;32m\] ▶\[\033[0m\] "
#############################################################################
#https://gist.github.com/justintv/168835#gistcomment-2711710
#############################################################################
# ┌────────────────────┐
# │ PROMPT │
# └────────────────────┘
# ref : https://gist.github.com/justintv/168835#gistcomment-2711710
#############################################################################
#source_if_exists "$HOME/.config/git/minimal.sh"
source_if_exists "$HOME/.config/git/git-prompt1.sh"
#source_if_exists "$HOME/.config/git/minimal_fast_prompt.sh"
#source_if_exists "$HOME/.config/git/powerlevel10k.sh"
#source_if_exists "$HOME/.config/git/custom.sh"
#source_if_exists "$HOME/.config/git/custom2.sh"

#GIT_PS1_SHOWDIRTYSTATE=true
#GIT_PS1_SHOWSTASHSTATE=true
#GIT_PS1_SHOWUPSTREAM="auto"
#PS1='\t:\[\033[32m\]$(__git_ps1 " (%s)")\[\033[00m\] \W$ '
#############################################################################
# ┌────────────────────┐
# │ TMUX │
# └────────────────────┘
#############################################################################
# Not so sure : putting it in seperate script makes detaching from tmux
# session, results normal bash prompt
source_if_exists "$HOME/.config/tmux/scripts/startup.sh"
3 changes: 3 additions & 0 deletions .config/bash/.bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alias configfiles='git --git-dir="D:\dotfiles\dotfiles" --work-tree="$HOME"'
alias wikifiles='git --git-dir="D:\dotfiles\wiki\vimwiki\.git"\
--work-tree="D:\dotfiles\wiki\vimwiki"'
15 changes: 15 additions & 0 deletions .config/bash/.bash_functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source_if_exists(){
[ -f "$1" ] && source "$1"
}
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
gb() {
is_in_git_repo &&
git branch -a -vv --color=always | grep -v '/HEAD\s' |
fzy | sed 's/^..//' | awk '{print $1}' |
sed 's#^remotes/[^/]*/##'
}

bind '"\er": redraw-current-line'
bind '"\C-g\C-b": "$(gb)\e\C-e\er"'
24 changes: 24 additions & 0 deletions .config/git/custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
git_stats() {
local STATUS=$(git status -s 2> /dev/null)
local ADDED=$(echo "$STATUS" | grep '??' | wc -l)
local DELETED=$(echo "$STATUS" | grep ' D' | wc -l)
local MODIFIED=$(echo "$STATUS" | grep ' M' | wc -l)
local STATS=''
if [ $ADDED != 0 ]; then
STATS="\e[42m $ADDED "
fi
if [ $DELETED != 0 ]; then
STATS="$STATS\e[101m $DELETED "
fi
if [ $MODIFIED != 0 ]; then
STATS="$STATS\e[30;103m $MODIFIED "
fi
echo -e "\e[0m $STATS\e[0m"
}
__PS1_BEFORE='\n\n'
__PS1_USER='\[\e[97;104m\] \u '
__PS1_LOCATION='\[\e[30;43m\] \w '
__PS1_GIT_BRANCH='\[\e[97;45m\] `__git_ps1` ' __PS1_GIT_STATS='`git_stats` '
__PS1_AFTER='\[\e[0m\]\n\n'

export PS1="${__PS1_BEFORE}${__PS1_USER}${__PS1_LOCATION}${__PS1_GIT_BRANCH}${__PS1_GIT_STATS}${__PS1_AFTER}"
154 changes: 154 additions & 0 deletions .config/git/custom2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# ANSI color escape sequences. Useful else, not just the prompt.
C_Red='\e[2;31m'; C_BRed='\e[1;31m'; C_Green='\e[2;32m';
C_BGreen='\e[1;32m'; C_Yellow='\e[2;33m'; C_BYellow='\e[1;33m';
C_Grey='\e[2;37m'; C_Reset='\e[0m'; C_BPink='\e[1;35m';
C_Italic='\e[3m'; C_Blue='\e[2;34m'; C_BBlue='\e[1;34m';
C_Pink='\e[2;35m'; C_Cyan='\e[2;36m'; C_BCyan='\e[1;36m'

# Values '1' or '2' are valid, for new and old versions, respectively.
PROMPT_STYLE=2

PROMPT_PARSER(){
if [ $PROMPT_STYLE -eq 1 ]; then
if git rev-parse --is-inside-work-tree &> /dev/null; then
local Status=`git status -s`
if [ -n "$Status" ]; then
local StatusColor=$C_BRed
else
local StatusColor=$C_BGreen
fi

local Top=`git rev-parse --show-toplevel`
read Line < "$Top"/.git/HEAD
local Branch="$C_Italic$StatusColor${Line##*/}$C_Reset "
fi

if [ $1 -gt 0 ]; then
local Exit="$C_BRed🗴$C_Reset"
else
local Exit="$C_BGreen🗸$C_Reset"
fi

local Basename=${PWD##*/}
local Dirname=${PWD%/*}

if [ "$Dirname/$Basename" == '/' ]; then
CWD="$C_Italic$C_BGreen/$C_Reset"
else
CWD="$C_Grey$Dirname/$C_Italic$Basename$C_Reset"

# If the CWD is too long, just show basename with '.../' prepended, if
# it's valid to do so. I think ANSI escape sequences are being counted
# in its length, causing it not work as it should, but I like the
# result, none-the-less.
local Slashes=${CWD//[!\/]/}
TempColumns=$((COLUMNS + 20)) # <-- Seems to work around sequences.
if ((${#CWD} > (TempColumns - ${#Branch}) - 2)); then
if [ ${#Slashes} -ge 2 ]; then
CWD="$C_Grey.../$C_Reset$C_BGreen$Basename$C_Reset"
else
CWD=$C_BGreen$Basename$C_Reset
fi
fi
fi

PS1="$Exit $Branch$CWD\n: "

unset Line
elif [ $PROMPT_STYLE -eq 2 ]; then
X=$1
(( $X == 0 )) && X=

if git rev-parse --is-inside-work-tree &> /dev/null; then
GI=(
'≎' # Clean
'≍' # Uncommitted changes
'≭' # Unstaged changes
'≺' # New file(s)
'⊀' # Removed file(s)
'≔' # Initial commit
'∾' # Branch is ahead
'⮂' # Fix conflicts
'!' # Unknown (ERROR)
'-' # Removed file(s)
)

Status=`git status 2> /dev/null`
Top=`git rev-parse --show-toplevel`

local GitDir=`git rev-parse --git-dir`
if [ "$GitDir" == '.' ] || [ "$GitDir" == "${PWD%%/.git/*}/.git" ]; then
Desc="${C_BRed}∷ ${C_Grey}Looking under the hood..."
else
if [ -n "$Top" ]; then
# Get the current branch name.
IFS='/' read -a A < "$Top/.git/HEAD"
local GB=${A[${#A[@]}-1]}
fi

# The following is in a very specific order of priority.
if [ -z "$(git rev-parse --branches)" ]; then
Desc="${C_BCyan}${GI[5]} ${C_Grey}Branch '${GB:-?}' awaits its initial commit."
else
while read -ra Line; do
if [ "${Line[0]}${Line[1]}${Line[2]}" == '(fixconflictsand' ]; then
Desc="${C_BCyan}${GI[7]} ${C_Grey}Branch '${GB:-?}' has conflict(s)."
break
elif [ "${Line[0]}${Line[1]}" == 'Untrackedfiles:' ]; then
NFTTL=0
while read -a Line; do
[ "${Line[0]}" == '??' ] && let NFTTL++
done <<< "$(git status --short)"
printf -v NFTTL "%'d" $NFTTL

Desc="${C_BCyan}${GI[3]} ${C_Grey}Branch '${GB:-?}' has $NFTTL new file(s)."
break
elif [ "${Line[0]}" == 'deleted:' ]; then
Desc="${C_BCyan}${GI[9]} ${C_Grey}Branch '${GB:-?}' detects removed file(s)."
break
elif [ "${Line[0]}" == 'modified:' ]; then
readarray Buffer <<< "$(git --no-pager diff --name-only)"
printf -v ModifiedFiles "%'d" ${#Buffer[@]}
Desc="${C_BCyan}${GI[2]} ${C_Grey}Branch '${GB:-?}' has $ModifiedFiles modified file(s)."
break
elif [ "${Line[0]}${Line[1]}${Line[2]}${Line[3]}" == 'Changestobecommitted:' ]; then
Desc="${C_BCyan}${GI[1]} ${C_Grey}Branch '${GB:-?}' has changes to commit."
break
elif [ "${Line[0]}${Line[1]}${Line[3]}" == 'Yourbranchahead' ]; then
printf -v TTLCommits "%'d" "${Line[7]}"
Desc="${C_BCyan}${GI[6]} ${C_Grey}Branch '${GB:-?}' leads by $TTLCommits commit(s)."
break
elif [ "${Line[0]}${Line[1]}${Line[2]}" == 'nothingtocommit,' ]; then
printf -v TTLCommits "%'d" "$(git rev-list --count HEAD)"

Desc="${C_BCyan}${GI[0]} ${C_Grey}Branch '${GB:-?}' is $TTLCommits commit(s) clean."
break
fi
done <<< "$Status"
fi
fi
fi

#PS1="\[${C_Reset}\]╭──╼${X}╾──☉ ${Desc}\[${C_Reset}\]\n╰─☉ "

# 2021-06-13: Temporary block — just experimenting.
if [ -n "$Desc" ]; then
if [ -n "$X" ]; then
PS1="\[${C_Reset}\]${Desc}\[${C_Reset}\]\n\[\e[91m\]${X} \[\e[0m\]\[\e[3;2;37m\]➙ \[\e[0m\] "
else
PS1="\[${C_Reset}\]${Desc}\[${C_Reset}\]\n\[\e[3;2;37m\]➙ \[\e[0m\] "
fi
else
if [ -n "$X" ]; then
PS1="\[${C_Reset}\]\[\e[91m\]${X} \[\e[0m\]\[\e[3;2;37m\]➙ \[\e[0m\] "
else
PS1="\[${C_Reset}\]\[\e[2;37m\]➙ \[\e[0m\] "
fi
fi

unset Z Line Desc GI Status Top X GB CWD\
Buffer ModifiedFiles TTLCommits NFTTL
fi
}

PROMPT_COMMAND='PROMPT_PARSER $?'
29 changes: 29 additions & 0 deletions .config/git/git-prompt1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/sh
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

#export PS1='\n\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]\u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)'$'\n\[\033[0;32m\]└─\[\033[0m\]\[\033[0;32m\] \$\[\033[0m\]\[\033[0;32m\] ▶\[\033[0m\] '
#┌─╭─

#export PS1='\n\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]╭─ \u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)'$'\n\[\033[0;32m\]╰─▶\[\033[0m\]\[\033[0;32m\] » $ \[\033[0m\]\[\033[0;32m\] \[\033[0m\] \[$(tput setaf 118)\]'
#
function __git_ps1_fast() {
# ref : https://gist.github.com/urbanautomaton/5206496
local dir="$PWD"
local git_dir

until [[ -z "$dir" ]]; do
git_dir="$dir/.git"
if [[ -d "$git_dir" ]]; then
echo " (`git rev-parse --abbrev-ref HEAD`)"
return
fi

dir="${dir%/*}"
done
}
export GIT_PS1_SHOWDIRTYSTATE=
export GIT_PS1_SHOWUNTRACKEDFILES=
export PS1='\n\[\e[0;36m\]╭─ \u @\h ::\w `__git_ps1_fast`'$'\n''\[\e[0;36m\]╰─▶$ \[\033[0m\]\[\e[0;32m\]'
#export PS1='\u @\h\n╰─▶ » $ \[$(tput setaf 118)\]'
Loading