~torresjrjr/.sh

.sh/sh/.init.sh -rw-r--r-- 1.3 KiB
6c65534dByron Torres lf*: more: Use -e flag a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# .init.sh
#
# The common POSIX script for interactive shells


## Env

export FETCH="${FETCH:-fetch}"


## Settings

set -o vi


## Aliases

# bulitins
alias c='clear'
alias rs='clear; . $DOTSHELL/sh/.init.sh'  # overridden
alias l='ls --group-directories-first --color=auto'
alias lc='l -w 80 '
alias la='lc -FAXC'
alias ll='l -FAXlh'
alias lt='ll -t'

# externals
alias tree='tree -C --dirsfirst'
alias diff='diff --color=auto'
alias grep='grep --color=auto'

alias gits='git status -s'
alias gitss='git status'
alias gitd='git diff'
alias gitds='git diff --staged'
alias gitl='git log --oneline --decorate --graph -10'
alias gitll='git log --oneline --decorate --graph --all'


## Functions

info() {
	[ -x ./.bin/info ] && { ./.bin/info ; return ;}
	$FETCH
	[ "$COLUMNS" -lt 80 ] && l || la ; echo
	git log -0 2>&- && {  # if git repo
		git log -1 --abbrev-commit --format=short --color --decorate \
		| sed -n '1p; /^    /p'
		git status -s
		echo
	}
}

dock() {
	tmux a || tmux
}

gitf() {
	git fetch $1 ;echo
	gitlf $1 $2 ;echo
	git status ;echo
}

gitlf() {
	remote=${1:-origin}
	branch=${2:-$(git branch | grep '^\*' | cut -d' ' -f2)}
	git log --oneline --decorate --graph --color \
		"$branch" "$remote/$branch" \
		"$( git merge-base "$branch" "$remote/$branch" )^!"
}

## Local

[ -f "$DOTSHELL/local/.init.sh" ] &&
   . "$DOTSHELL/local/.init.sh"


## Runtime

info