forked from L-P/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.commonshrc
140 lines (120 loc) · 3.02 KB
/
.commonshrc
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Start SSH agent.
if [ "root" != "$(whoami)" ]; then
/usr/bin/keychain $HOME/.ssh/* &> /dev/null
source $HOME/.keychain/$HOST-sh
fi
export PATH=~/.bin:$PATH
export EDITOR=vim # Scarcely used (see `update-alternatives --config editor`)
export LC_ALL=C.UTF-8
# Nicer less by default
export LESS='-RFXS -x4'
export PAGER='less'
export MANPAGER='less'
# 256 colors, except on TTY.
if [ "$TERM" = "screen" ]; then
export TERM='screen-256color'
elif [ "$TERM" != "linux" ]; then
export TERM='xterm-256color'
fi
# Color aliases
alias grep='grep --color=auto'
alias tree='tree -C'
# Aliases
alias ls='ls --group-directories-first --color -v'
alias ll='ls -vlh'
alias la='ll -va'
alias mkdir='mkdir -pv'
alias rm='rm --preserve-root'
alias gd='git diff -M -C'
alias gds='git diff -M -C --staged'
alias gs='git status --short'
alias py='python3'
alias ripit='ripit -o /dev/shm/ripit -c 2 -q 8' # FLAC @ max comp.
alias json='json_reformat | pygmentize -l json'
alias cdr='cd $(git rev-parse --show-toplevel)'
# Typos
alias cim='vim'
alias vp='cp'
alias cd..='cd ..'
alias :q='exit'
alias :e='vim'
alias :tabe='vim'
# tmux for the lazy.
function t () {
tmux a -t $1 || tmux new -s $1
}
# Nicer du (ncdu is nice too).
function duf() {
du -csh -- "$@" | sort -rh
}
# Handy grep aliases, since ack sucks.
function g() {
grep --color=always -EHnr --exclude-dir='.svn' --exclude-dir='.git' $@ . | $PAGER ;
}
function gi() {
grep --color=always -EHnri --exclude-dir='.svn' --exclude-dir='.git' $@ . | $PAGER ;
}
# Same aliases for the faster git grep.
function gg() {
git grep --color=always -En $@
}
function ggi() {
git grep --color=always -Eni $@
}
# Find aliases
function f() {
find . -iname "*$@*"
}
function ff() {
find . -type f -iname "*$@*"
}
function fd() {
find . -type d -iname "*$@*"
}
# Make a git repo with an empty commit
function mkrepo() {
(
mkdir $1
pushd $1
git init
git ci --allow-empty -m "Initial commit."
popd ..
) > /dev/null
}
# Record terminal input/output to file.
function record() {
local date="$(date --rfc-3339=seconds | sed 's/ /_/g')"
local dir="$HOME/.terminal_recordings"
mkdir -p "$dir" &> /dev/null
script -t "$dir/script_$date" 2> "$dir/timing_$date"
}
# Echo a ready-to-copy scp command to get a file.
function getscp() {
local ip="$(ip addr show eth0 | grep 'inet[^6]' | cut -d' ' -f6 | cut -d'/' -f1)"
echo "scp $(whoami)@$ip:$(pwd)/$1 ."
}
# List all git repositories.
function repos() {
find . -type d -name .git | sed -r 's/(\/\.git)$//'
}
# Update (fetch-only) all repositories in current dir and subsdirs.
function update_repos() {
for repo in $(repos); do
pushd "$repo" > /dev/null
echo "-------------------- $repo"
git remote update --prune
popd > /dev/null
done
}
# Unmount a SSHFS.
function ufs() {
fusermount -u "$1"
}
# Mount a SSHFS.
function fs() {
local src="$1"
local dest="$2"
[ -d "$dest" ] || mkdir "$dest"
ufs "$dest" > /dev/null
sshfs "$src" "$dest"
}