From 3adf4c36ef3e6dcc00f71148d4318a8cae2405cc Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 16:34:37 +0100 Subject: [PATCH 01/10] Moved vim git stuff to new file --- git.vim | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ vimrc | 194 +------------------------------------------------------- 2 files changed, 194 insertions(+), 191 deletions(-) create mode 100644 git.vim diff --git a/git.vim b/git.vim new file mode 100644 index 0000000..1de23a2 --- /dev/null +++ b/git.vim @@ -0,0 +1,191 @@ +" ┌─────────────────┐ +" └─┬─┬───┬─┬───┬─┬─┘ +" │ │ │ │ │ │ +" │ │ │ │ │ │ +" ┌─┴─┴───┴─┴───┴─┴─┐ +" ┌┘ Git Stuff └┐ +" └───────────────────┘ + +function! s:gitroot() + let s:ret = substitute(system('git rev-parse --show-toplevel'), '\n\_.*', '', '') + if v:shell_error + throw s:ret + else + return s:ret + end +endf + +function! s:git_history() + if exists("b:git_history") + if b:git_history[0]+10 > localtime() + return b:git_history[1] + end + end + + if exists("b:git_original_file") " Is this already a file@revision buffer? + let l:fname = b:git_original_file + else + let l:fname = substitute(expand("%"), "\\\\", "/", "g") + end + let l:commits = system('git log --format="%h" '.l:fname) + let l:hist = split(l:commits, "\n") + let b:git_history = [localtime(), l:hist] + + return l:hist +endfun + +function! s:git_first() + if &modified + echo "Save your changes first!" + return + end + let l:history = s:git_history() + call s:file_at_revision(get(l:history, -1)) +endfun + +function! s:git_last() + if &modified + echo "Save your changes first!" + return + end + let l:history = s:git_history() + call s:file_at_revision(get(l:history, 1, "HEAD")) +endfun + +function! s:git_info() + if !exists("b:git_revision_hash") || !exists("b:git_original_file") + echo "Not a file@revision buffer!" + return + end + echo system("git show --no-patch ".b:git_revision_hash) +endfun + +function! s:git_next() + if !exists("b:git_revision_hash") || !exists("b:git_original_file") + echo "Error 01: Not a file@revision buffer!" + return + end + let l:history = s:git_history() + let l:idx = index(l:history, b:git_revision_hash) + if l:idx == -1 + echo "Error 02" + return + end + let l:new_revision = get(l:history, l:idx-1, "LAST") + if l:new_revision=="LAST" + echo "Already at latest revision! ".l:new_revision + return + else + call s:file_at_revision(l:new_revision) + end +endfun + +function! s:git_prev() + if !exists("b:git_revision_hash") || !exists("b:git_original_file") + let l:new_revision = s:git_history()[0] + else + let l:history = s:git_history() + let l:idx = index(l:history, b:git_revision_hash) + if l:idx == -1 + echo "Error 03: cannot find revision ".b:git_revision_hash + return + end + let l:new_revision = get(l:history, l:idx+1, "FIRST") + end + if l:new_revision=="FIRST" + echo "Already at earliest revision! ".l:new_revision + return + else + call s:file_at_revision(l:new_revision) + end +endfun + +function! s:file_at_revision(rev) + let l:pos = getpos(".") + if exists("b:git_original_file") " Is this already a file@revision buffer? + let l:fname = b:git_original_file + let l:ftail = fnamemodify(b:git_original_file, ":t") + else + let l:fname = expand("%") + let l:ftail = expand("%:t") + end + let l:fname = substitute(l:fname, "\\\\", "/", "g") + let l:ftype = &filetype + + ene! + set modifiable + silent exec "file ".l:ftail."@".a:rev + exec "r!git show ".a:rev.":".l:fname + 1,1del + let l:pos[0] = bufnr('.') + call setpos('.', l:pos) + setl nomodifiable + setl buftype=nofile + setl bufhidden=delete + let &filetype = l:ftype + + let b:git_original_file = l:fname + let b:git_revision_hash = a:rev +endfun + +function! s:git_diff(...) + if a:0 + vert bot split + call s:file_at_revision(a:1) + diffthis + au BufUnload diffoff! + exec "normal \\" + diffthis + call s:git_info() + else + if exists("b:git_revision_hash") + call s:git_diff(get(s:git_history(), index(s:git_history(), b:git_revision_hash)+1, "NIL")) + else + call s:git_diff(get(s:git_history(), 0, "HEAD")) + end + end +endfun + +function! s:git_blame() + let l:name = expand('%') + let l:line = getpos('.')[1] + let l:char = getpos('.')[2]+59 + let l:type = &filetype + enew + set modifiable + let &filetype = l:type + set buftype=nofile + set bufhidden=delete + set nowrap + silent exec "file Blame: ".l:name + keepjumps exec 'r !git blame '.l:name + keepjumps 0,0del " + set nomodifiable + keepjumps call setpos('.', [0, l:line, l:char, 0]) +endfun + +command! Blame try + \| call s:gitroot() | call git_blame() + \| catch | echo 'Not a git repo!' + \| endtry +command! GitNext try + \| call s:gitroot() | call git_next() | call s:git_info() + \| catch | echo 'Not a git repo!' + \| endtry +command! GitPrev call git_prev() | call s:git_info() +command! GitFirst call git_first() | call s:git_info() +command! GitLast call git_last() | call s:git_info() +command! GitInfo call git_info() +command! -nargs=1 GitCheckout call file_at_revision() +command! -nargs=? GitCompare try + \| call s:gitroot() | call git_diff() + \| catch | echo 'Not a git repo!' + \| endtry +command! Uncommited try + \| call s:gitroot() | call git_diff() + \| catch | echo 'Not a git repo!' + \| endtry +command! GitRoot try + \| echo gitroot() + \| catch | echo 'Not a git repository' + \| endtry diff --git a/vimrc b/vimrc index 2c6a2d2..559ec37 100644 --- a/vimrc +++ b/vimrc @@ -1,6 +1,8 @@ " vim: set bufhidden=delete list noexpandtab :miv " "!!! makes use of marker ' +let s:root = expand(':p:h') + set nocompatible """""""""""""""" @@ -368,197 +370,7 @@ command! -nargs=* Hex call hex() command! -range=% LuaCompile ,w !luac -l -p - -" ┌─────────────────┐ -" └─┬─┬───┬─┬───┬─┬─┘ -" │ │ │ │ │ │ -" │ │ │ │ │ │ -" ┌─┴─┴───┴─┴───┴─┴─┐ -" ┌┘ Git Stuff └┐ -" └───────────────────┘ - -function! s:gitroot() - let s:ret = substitute(system('git rev-parse --show-toplevel'), '\n\_.*', '', '') - if v:shell_error - throw s:ret - else - return s:ret - end -endf - -function! s:git_history() - if exists("b:git_history") - if b:git_history[0]+10 > localtime() - return b:git_history[1] - end - end - - if exists("b:git_original_file") " Is this already a file@revision buffer? - let l:fname = b:git_original_file - else - let l:fname = substitute(expand("%"), "\\\\", "/", "g") - end - let l:commits = system('git log --format="%h" '.l:fname) - let l:hist = split(l:commits, "\n") - let b:git_history = [localtime(), l:hist] - - return l:hist -endfun - -function! s:git_first() - if &modified - echo "Save your changes first!" - return - end - let l:history = s:git_history() - call s:file_at_revision(get(l:history, -1)) -endfun - -function! s:git_last() - if &modified - echo "Save your changes first!" - return - end - let l:history = s:git_history() - call s:file_at_revision(get(l:history, 1, "HEAD")) -endfun - -function! s:git_info() - if !exists("b:git_revision_hash") || !exists("b:git_original_file") - echo "Not a file@revision buffer!" - return - end - echo system("git show --no-patch ".b:git_revision_hash) -endfun - -function! s:git_next() - if !exists("b:git_revision_hash") || !exists("b:git_original_file") - echo "Error 01: Not a file@revision buffer!" - return - end - let l:history = s:git_history() - let l:idx = index(l:history, b:git_revision_hash) - if l:idx == -1 - echo "Error 02" - return - end - let l:new_revision = get(l:history, l:idx-1, "LAST") - if l:new_revision=="LAST" - echo "Already at latest revision! ".l:new_revision - return - else - call s:file_at_revision(l:new_revision) - end -endfun - -function! s:git_prev() - if !exists("b:git_revision_hash") || !exists("b:git_original_file") - let l:new_revision = s:git_history()[0] - else - let l:history = s:git_history() - let l:idx = index(l:history, b:git_revision_hash) - if l:idx == -1 - echo "Error 03: cannot find revision ".b:git_revision_hash - return - end - let l:new_revision = get(l:history, l:idx+1, "FIRST") - end - if l:new_revision=="FIRST" - echo "Already at earliest revision! ".l:new_revision - return - else - call s:file_at_revision(l:new_revision) - end -endfun - -function! s:file_at_revision(rev) - let l:pos = getpos(".") - if exists("b:git_original_file") " Is this already a file@revision buffer? - let l:fname = b:git_original_file - let l:ftail = fnamemodify(b:git_original_file, ":t") - else - let l:fname = expand("%") - let l:ftail = expand("%:t") - end - let l:fname = substitute(l:fname, "\\\\", "/", "g") - let l:ftype = &filetype - - ene! - set modifiable - silent exec "file ".l:ftail."@".a:rev - exec "r!git show ".a:rev.":".l:fname - 1,1del - let l:pos[0] = bufnr('.') - call setpos('.', l:pos) - setl nomodifiable - setl buftype=nofile - setl bufhidden=delete - let &filetype = l:ftype - - let b:git_original_file = l:fname - let b:git_revision_hash = a:rev -endfun - -function! s:git_diff(...) - if a:0 - vert bot split - call s:file_at_revision(a:1) - diffthis - au BufUnload diffoff! - exec "normal \\" - diffthis - call s:git_info() - else - if exists("b:git_revision_hash") - call s:git_diff(get(s:git_history(), index(s:git_history(), b:git_revision_hash)+1, "NIL")) - else - call s:git_diff(get(s:git_history(), 0, "HEAD")) - end - end -endfun - -function! s:git_blame() - let l:name = expand('%') - let l:line = getpos('.')[1] - let l:char = getpos('.')[2]+59 - let l:type = &filetype - enew - set modifiable - let &filetype = l:type - set buftype=nofile - set bufhidden=delete - set nowrap - silent exec "file Blame: ".l:name - keepjumps exec 'r !git blame '.l:name - keepjumps 0,0del " - set nomodifiable - keepjumps call setpos('.', [0, l:line, l:char, 0]) -endfun - -command! Blame try - \| call s:gitroot() | call git_blame() - \| catch | echo 'Not a git repo!' - \| endtry -command! GitNext try - \| call s:gitroot() | call git_next() | call s:git_info() - \| catch | echo 'Not a git repo!' - \| endtry -command! GitPrev call git_prev() | call s:git_info() -command! GitFirst call git_first() | call s:git_info() -command! GitLast call git_last() | call s:git_info() -command! GitInfo call git_info() -command! -nargs=1 GitCheckout call file_at_revision() -command! -nargs=? GitCompare try - \| call s:gitroot() | call git_diff() - \| catch | echo 'Not a git repo!' - \| endtry -command! Uncommited try - \| call s:gitroot() | call git_diff() - \| catch | echo 'Not a git repo!' - \| endtry -command! GitRoot try - \| echo gitroot() - \| catch | echo 'Not a git repository' - \| endtry +exec 'so '.s:root.'/git.vim' " === FILE STUFF === From 8fca4f9ba8358b4453a18f54f29c5a8bf65072ce Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 18:54:42 +0100 Subject: [PATCH 02/10] Add git info to bash prompt --- bashrc | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 66edbca..54910c7 100644 --- a/bashrc +++ b/bashrc @@ -32,5 +32,39 @@ stty -ixon # Enable Vi editing mode set -o vi -PS1='\[\033[00;34m\]┌─╼ \[\033[00;33m\]\$ \[\033[01;35m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h\[\033[01;34m\] `date +%d.%m.%y` \[\033[01;35m\]\w\[\033[00m\] +git__branch () { + git rev-parse --show-toplevel > /dev/null 2>&1 + if [ $? = 0 ] + then + branch=`git branch | grep -Po '(?<=\* )[[:alnum:]]*'` + count=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l` + diff=`git branch -vv | sed '/.*\[[^ ]* .*\].*/!d' | sed 's/.*\[[^ ]* \(.*\)\].*/\1/' | sed 's/\([^ ]\)[^ ]* \(.*\)/\2\\1/'` + g='\033[01;30m' + + if [ $branch = 'master' ] + then + echo -ne " \033[01;34m$branch" + else + echo -ne " \033[01;32m$branch" + fi + + if [ $count = 0 ] + then + echo -ne "$g:\033[01;36m$count" + else + echo -ne "$g:\033[01;33m$count" + fi + if [ ${diff: -1} = "a" ] + then + echo -ne "$g:\033[01;33m${diff}" + elif [ ${diff: -1} = "a" ] + then + echo -ne "$g:\033[01;34m${diff}" + else + echo -ne "$g:\033[01;31m${diff}" + fi + fi +} + +PS1='\[\033[00;34m\]┌─╼ \[\033[00;33m\]\$ \[\033[01;35m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h\[\033[01;34m\] `date +%d.%m.%y` \[\033[01;35m\]\w`git__branch`\[\033[00m\] \[\033[00;34m\]└╼ \[\033[00m\]' From 4453192c57a5c42091c970af562a7cff2392e9c6 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 19:45:13 +0100 Subject: [PATCH 03/10] Some refactoring in vim git stuff --- git.vim | 62 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/git.vim b/git.vim index 1de23a2..9ba8e4e 100644 --- a/git.vim +++ b/git.vim @@ -1,20 +1,44 @@ -" ┌─────────────────┐ -" └─┬─┬───┬─┬───┬─┬─┘ -" │ │ │ │ │ │ -" │ │ │ │ │ │ -" ┌─┴─┴───┴─┴───┴─┴─┐ -" ┌┘ Git Stuff └┐ -" └───────────────────┘ +" ┌─────────────────┐ " +" └─┬─┬───┬─┬───┬─┬─┘ " +" │ │ │ │ │ │ " +" │ │ │ │ │ │ " +" ┌─┴─┴───┴─┴───┴─┴─┐ " +" ┌┘ Git Stuff └┐ " +" └───────────────────┘ " +" Find the root of a git repository function! s:gitroot() - let s:ret = substitute(system('git rev-parse --show-toplevel'), '\n\_.*', '', '') + let l:ret = substitute(system('git rev-parse --show-toplevel'), '\n\_.*', '', '') if v:shell_error - throw s:ret + throw l:ret else - return s:ret + return l:ret end endf +function! s:git_root(path) + let l:path = fnamemodify(a:path, ':p') + let l:wd = getcwd() + if isdirectory(l:path) + exec 'cd '.a:path + elseif filereadable(l:path) + exec 'cd '.fnamemodify(l:path, ':h') + else + return 0 + endif + let l:ret = substitute(system('git rev-parse --show-toplevel'), '\n\_.*', '', '') + if v:shell_error + echom l:ret + exec 'cd '.l:wd + return 0 + else + exec 'cd '.l:wd + return l:ret + end + exec 'cd '.l:wd +endf + +" Returns an array containing chronologically sorted commits function! s:git_history() if exists("b:git_history") if b:git_history[0]+10 > localtime() @@ -36,20 +60,16 @@ endfun function! s:git_first() if &modified - echo "Save your changes first!" - return + throw "File has unsaved modifications!" end - let l:history = s:git_history() - call s:file_at_revision(get(l:history, -1)) + call s:file_at_revision(get(s:git_history(), -1)) endfun function! s:git_last() if &modified - echo "Save your changes first!" - return + throw "File has unsaved modifications!" end - let l:history = s:git_history() - call s:file_at_revision(get(l:history, 1, "HEAD")) + call s:file_at_revision(get(s:git_history(), 1, "HEAD")) endfun function! s:git_info() @@ -73,8 +93,7 @@ function! s:git_next() end let l:new_revision = get(l:history, l:idx-1, "LAST") if l:new_revision=="LAST" - echo "Already at latest revision! ".l:new_revision - return + throw "Already at last revision!" else call s:file_at_revision(l:new_revision) end @@ -93,8 +112,7 @@ function! s:git_prev() let l:new_revision = get(l:history, l:idx+1, "FIRST") end if l:new_revision=="FIRST" - echo "Already at earliest revision! ".l:new_revision - return + throw "Already at earliest revision!" else call s:file_at_revision(l:new_revision) end From 30e037fb98df675349ec7a982e33a58dce605e78 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 19:47:03 +0100 Subject: [PATCH 04/10] Commend and improve bash prompt git stuff --- bashrc | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/bashrc b/bashrc index 54910c7..218621b 100644 --- a/bashrc +++ b/bashrc @@ -32,14 +32,22 @@ stty -ixon # Enable Vi editing mode set -o vi -git__branch () { +git__prompt () { git rev-parse --show-toplevel > /dev/null 2>&1 if [ $? = 0 ] then branch=`git branch | grep -Po '(?<=\* )[[:alnum:]]*'` - count=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l` - diff=`git branch -vv | sed '/.*\[[^ ]* .*\].*/!d' | sed 's/.*\[[^ ]* \(.*\)\].*/\1/' | sed 's/\([^ ]\)[^ ]* \(.*\)/\2\\1/'` - g='\033[01;30m' + modif=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l` + untracked=`git status --short 2>/dev/null | grep -Po '^\?\?' | wc -l` + added=`git status --short 2>/dev/null | grep -Po '^\s*A' | wc -l` + stat=`git branch -vv | grep -P '^\*' | grep -Po '\[.*\]'` + ahead=`echo $stat | grep -Po '(?<=ahead )\d*'` + behind=`echo $stat | grep -Po '(?<=behind )\d*'` + gray='\033[01;30m' + blue='\033[01;34m' + yellow='\033[01;33m' + red='\033[01;31m' + green='\033[01;32m' if [ $branch = 'master' ] then @@ -48,23 +56,35 @@ git__branch () { echo -ne " \033[01;32m$branch" fi - if [ $count = 0 ] + if [ $modif = 0 ] then - echo -ne "$g:\033[01;36m$count" + echo -ne "$gray:\033[01;36m$modif" # No modified files else - echo -ne "$g:\033[01;33m$count" + echo -ne "$gray:\033[01;33m$modif" # Modified files fi - if [ ${diff: -1} = "a" ] + if [ $added -ne 0 ] then - echo -ne "$g:\033[01;33m${diff}" - elif [ ${diff: -1} = "a" ] + echo -ne "${green}S" + fi + if [ $untracked -ne 0 ] then - echo -ne "$g:\033[01;34m${diff}" + echo -ne "${red}*" + fi + + if [ -z $ahead ] && [ -z $behind ] + then + echo -ne "" # Nothing to do here + elif [ -z $ahead ] + then + echo -ne "${gray}:${yellow}↓${behind}" + elif [ -z $behind ] + then + echo -ne "${gray}:${blue}↑${ahead}" else - echo -ne "$g:\033[01;31m${diff}" + echo -ne "${gray}:${red}↓${behind}↑${ahead}" fi fi } -PS1='\[\033[00;34m\]┌─╼ \[\033[00;33m\]\$ \[\033[01;35m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h\[\033[01;34m\] `date +%d.%m.%y` \[\033[01;35m\]\w`git__branch`\[\033[00m\] +PS1='\[\033[00;34m\]┌─╼ \[\033[00;33m\]\$ \[\033[01;35m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h\[\033[01;34m\] `date +%d.%m.%y` \[\033[01;35m\]\w`git__prompt`\[\033[00m\] \[\033[00;34m\]└╼ \[\033[00m\]' From 706f866ab26a9521e457405110dced52da5e58ce Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:04:18 +0100 Subject: [PATCH 05/10] Add conky.conf --- conky.conf | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 conky.conf diff --git a/conky.conf b/conky.conf new file mode 100644 index 0000000..a1f4da2 --- /dev/null +++ b/conky.conf @@ -0,0 +1,75 @@ +-- vim: set filetype=lua :miv -- +conky.config = { + double_buffer = true, + update_interval = 1, + alignment = 'bottom_right', + gap_x = 100 + 320, + gap_y = 100 + 200, + own_window = true, + own_window_title = 'conky', + own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', + own_window_argb_visual = true, + own_window_transparent = true, + border_inner_margin = 8, + background = true, + border_width = 1, + cpu_avg_samples = 2, + draw_borders = false, + draw_graph_borders = true, + draw_outline = false, + draw_shades = false, + use_xft = true, + font = 'Quicksand:size=14', + minimum_height = 5, + minimum_width = 250, + net_avg_samples = 2, + no_buffers = false, + out_to_console = false, + out_to_stderr = false, + extra_newline = false, + stippled_borders = 0, + uppercase = false, + use_spacer = 'none', + show_graph_scale = false, + show_graph_range = false, + default_color = '#666666', + color1 = "#664444", + color2 = "#888888", + color3 = "#663333" +} +conky.text = [[$color3${time %Y-%m-%d} +$color1${voffset -10}${font Quicksand:size=40}${time %H:%M}$font$color +${color2}Uptime:$color $alignr$uptime +# +${color3}Stats $hr$color +${color2}ip:$color $alignr${texeci 3 wget http://darkwiiplayer.com/api/ip --no-check-certificate -qO - } +${color2}vpn:$color $alignr${execi 2 expressvpn status | grep -Po 'Not connected|(?<=Connected to).*$'} +# +#${color3}Location $hr$color +#${color2}ip:$color $alignr${execi 2 ~/.bin/location} +# +${color3}Ping $hr +${color2}Google: $color$alignr${execi 2 ping google.de -c 1 | grep -Po '(?<=time=).*'} +${color2}Server: $color$alignr${execi 2 ping darkwiiplayer.com -c 1 | grep -Po '(?<=time=).*'} +# +${color3}CPU $hr +$color$cpu%$color2 CPU Usage +$color${cpubar 8}$color +${color2}Frequency:$color $alignr$freq_g GHz +# +${color3}Memory $hr$color +$color$memperc%${color2} RAM Usage +$color${membar 8}$color +$mem / $memmax +${color2}Processes:$color $processes ${color2}Running:$color $running_processes +# +${color3}Storage $hr +${color2}root $alignr$color${fs_used /}/${fs_size /} +$color${fs_bar 8 /} +${color2}data $alignr$color${fs_used /data}/${fs_size /data} +$color${fs_bar 8 /data} +# +${color3}Networking $hr +${color2}Up:$color ${upspeed enp3s0} ${color2} - Down:$color ${downspeed enp3s0} +${font Hack:size=10}$color2$alignc${execi 1000 whoami}@${execi 1000 hostname} +]] From 3ed66ecb4e636528563e2b58b98666828a2b7a7b Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:08:46 +0100 Subject: [PATCH 06/10] Remove 0 from git prompt when no modified files --- bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 218621b..4f06f1e 100644 --- a/bashrc +++ b/bashrc @@ -58,13 +58,13 @@ git__prompt () { if [ $modif = 0 ] then - echo -ne "$gray:\033[01;36m$modif" # No modified files + echo -ne # "$gray:\033[01;36m$modif" # No modified files else echo -ne "$gray:\033[01;33m$modif" # Modified files fi if [ $added -ne 0 ] then - echo -ne "${green}S" + echo -ne "${green}+$added" fi if [ $untracked -ne 0 ] then From f7f7d59d091998cea8bee54dbcbdecf484dbb77c Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:20:55 +0100 Subject: [PATCH 07/10] Fix bash git branch for detatched head --- bashrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bashrc b/bashrc index 4f06f1e..cc67b33 100644 --- a/bashrc +++ b/bashrc @@ -49,6 +49,10 @@ git__prompt () { red='\033[01;31m' green='\033[01;32m' + if [ -z $branch ] + then + branch='#'`git rev-parse --short HEAD` + fi if [ $branch = 'master' ] then echo -ne " \033[01;34m$branch" From 90dfa6fc125c17094a016faa5f013f79768302c7 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:22:10 +0100 Subject: [PATCH 08/10] Change bash git up/down arrow color --- bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index cc67b33..3592b45 100644 --- a/bashrc +++ b/bashrc @@ -83,9 +83,9 @@ git__prompt () { echo -ne "${gray}:${yellow}↓${behind}" elif [ -z $behind ] then - echo -ne "${gray}:${blue}↑${ahead}" + echo -ne "${gray}:${green}↑${ahead}" else - echo -ne "${gray}:${red}↓${behind}↑${ahead}" + echo -ne "${gray}:${red}↓${behind}${yellow}↑${ahead}" fi fi } From e5e62e6044d921241ef47c6dd8f6b709e053a2b9 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:30:40 +0100 Subject: [PATCH 09/10] Add counter for removed files to bash git prompt --- bashrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 3592b45..6cc7b7d 100644 --- a/bashrc +++ b/bashrc @@ -1,4 +1,3 @@ - alias hello='echo "Hello :)"' alias rmd='rm --recursive' alias temp='watch -t -d -n 1 sensors -A coretemp-isa-0000' @@ -40,6 +39,7 @@ git__prompt () { modif=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l` untracked=`git status --short 2>/dev/null | grep -Po '^\?\?' | wc -l` added=`git status --short 2>/dev/null | grep -Po '^\s*A' | wc -l` + deleted=`git status --short 2>/dev/null | grep -Po '^\s*D' | wc -l` stat=`git branch -vv | grep -P '^\*' | grep -Po '\[.*\]'` ahead=`echo $stat | grep -Po '(?<=ahead )\d*'` behind=`echo $stat | grep -Po '(?<=behind )\d*'` @@ -70,6 +70,10 @@ git__prompt () { then echo -ne "${green}+$added" fi + if [ $deleted -ne 0 ] + then + echo -ne "${red}-$deleted" + fi if [ $untracked -ne 0 ] then echo -ne "${red}*" From 87a6485177322043d592ff30374adf14c0efa341 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 19 Nov 2018 21:33:37 +0100 Subject: [PATCH 10/10] Improve colors for branch display in bash git prompt --- bashrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 6cc7b7d..cdb330a 100644 --- a/bashrc +++ b/bashrc @@ -55,9 +55,12 @@ git__prompt () { fi if [ $branch = 'master' ] then - echo -ne " \033[01;34m$branch" + echo -ne " $blue$branch" + elif [ ${branch:0:1} = '#' ] + then + echo -ne " $red$branch" else - echo -ne " \033[01;32m$branch" + echo -ne " $yellow$branch" fi if [ $modif = 0 ]