-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash-helpers
65 lines (53 loc) · 2.21 KB
/
bash-helpers
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
# vim: syntax=sh tabstop=2 shiftwidth=2
mypath="$(dirname ${BASH_SOURCE[0]})"
[ -f "$mypath/bash-functions" ] && source "$mypath/bash-functions"
################## Aliases ###################
alias nocomm="egrep -v '^[[:space:]]*(#|$)'"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ls='ls -alh --color=always'
hash metaflac 2> /dev/null && alias flacinfo='metaflac --list --except-block-type=PADDING,PICTURE,SEEKTABLE'
hash bundle 2> /dev/null && alias be='bundle exec'
if ! hash ack 2> /dev/null && hash ack-grep 2> /dev/null; then
alias ack="`which ack-grep`"
fi
if cp --version &>/dev/null; then
alias cp='cp --reflink=auto'
else
# Probably OSX
alias cp='cp -c'
fi
if hash findmnt 2> /dev/null; then
alias realmount='findmnt -it sysfs,cgroup,cgroup2,proc,devtmpfs,devpts,pstore,debugfs,hugetlbfs,mqueue,configfs,tmpfs,autofs,fusectl,securityfs,rpc_pipefs,binfmt_misc,tracefs,squashfs'
else
alias realmount='mount | grep --color=never "^/"'
fi
if hash gpg-connect-agent 2> /dev/null; then
alias gpg-update-yubikey='gpg-connect-agent "scd serialno" "learn --force" /bye'
fi
if ! hash hd 2> /dev/null; then
if hash hexdump 2> /dev/null; then
alias hd='hexdump -C'
elif od --version &> /dev/null; then
# BSD od doesn't do long opts, so assume GNU
alias hd='od -A x -t x1z -v'
elif hash xxd 2> /dev/null; then
# fall back to xxd approximation
alias hd='xxd -g 1'
fi
fi
############## Enable Homebrew ###############
hash brew 2> /dev/null ||
{ [ -x /home/linuxbrew/.linuxbrew/bin/brew ] && hash -p /home/linuxbrew/.linuxbrew/bin/brew brew; } ||
{ [ -x /opt/homebrew/bin/brew ] && hash -p /opt/homebrew/bin/brew brew; }
hash -t brew &> /dev/null && eval $(brew shellenv) && etc_prefix=$(brew --prefix)
########## Additional Configuration ##########
hash hub 2> /dev/null && eval "$(hub alias -s)";
hash rbenv 2> /dev/null && eval "$(rbenv init -)"
hash lesspipe 2> /dev/null && eval "$(SHELL=/bin/sh lesspipe)"
if [ -r "$etc_prefix/etc/profile.d/bash_completion.sh" ]; then
source "$etc_prefix/etc/profile.d/bash_completion.sh"
fi
# Enable git branch prompt if available
type __git_ps1 &> /dev/null && PS1=${PS1/?( )\\\$/\$(__git_ps1 \" (%s)\")\\\$}