-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_aliases
159 lines (138 loc) · 3.27 KB
/
.bash_aliases
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
function exists {
#Check if function exists.
hash ${1} 2>/dev/null || { return 1 ; }
return 0
}
function isgitted {
[[ -d "$1"/.git ]]
return $?
}
function suspend {
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
}
exists tmux && {
function _tmux () {
if [[ `tmux list-sessions 2>&1` == "failed to connect to server" ]] || [[ `tmux list-sessions 2>&1` == "no server running on "* ]] ;
then
tmux $@
else
tmux attach $@
fi
}
alias tm='_tmux'
}
alias ll='ls -alF'
alias lr='ls -alR'
alias la='ls -A'
alias l='ls -alF'
alias sl='l'
alias SL='l'
alias LS='l'
alias vis='vim --servername VIM --remote-silent'
exists xclip && {
function clipboard {
if [ ! -t 0 ] ;
then
xclip -i
else
xclip -o
fi
}
function cdc {
cd "$(xclip -o)"
}
alias cb="clipboard"
alias pwdc="pwd | tee >(xclip -i)"
}
exists google-chrome && alias chrome="google-chrome --enable-plugins &";
exists bc && alias bc="bc --mathlib";
exists git && {
#Git
alias gb='/usr/bin/git branch -va'
alias gco='/usr/bin/git commit'
alias gd='/usr/bin/git diff --word-diff'
alias gdc='/usr/bin/git diff --cached'
alias gs='/usr/bin/git status'
alias gr='/usr/bin/git remote -v'
alias ga='/usr/bin/git add'
alias gl='/usr/bin/git log --format=format:"%ai %h %aE %s"'
alias gt='/usr/bin/git tag'
alias ggr='/usr/bin/git log --all --decorate --oneline --graph'
alias g='gitty'
alias gcd='cd $(/usr/bin/git rev-parse --show-toplevel)'
alias gp='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative'
function gitty () {
if [[ $# == 0 ]];
then
/usr/bin/git status -sb
else
/usr/bin/git "$@"
fi
}
}
exists wstool && {
alias ws="wstool"
function cdws {
cd $(wstool info --root)
}
}
function cdd_ {
set -x
if exists wstool
then
cd $(wstool info --root)
elif exists git
then
cd $(git rev-parse --show-toplevel)
else
cd $@
fi
set +x
}
alias cdd='cdd_'
[[ -f "$HOME/.bash/bin/todo-txt-cli/todo.sh" ]] && {
export TODOTXT_DEFAULT_ACTION=ls
TODOTXT_REPO="$HOME/todo"
TODOTXT_CONFIG="$TODOTXT_REPO/todo.cfg"
[[ -f $TODOTXT_CONFIG ]] && \
alias t='$HOME/.bash/bin/todo-txt-cli/todo.sh -d $HOME/todo/todo.cfg' || \
alias t='$HOME/.bash/bin/todo-txt-cli/todo.sh'
isgitted "$TODOTXT_REPO" && {
function todo-commit () {
(
cd "$TODOTXT_REPO"
if [[ $# == 0 ]];
then
git commit -a -m "Automated commit from $(hostname)."
git push home master
else
git commit -a -m "$@"
git push home master
fi
)
}
alias tdc='todo-commit'
}
}
#latexmk
exists latexmk && alias ltmk='latexmk -pvc'
#tvnamer
if exists tvnamer && [[ -f "$HOME/.config/.tvnamer.json" ]];
then
alias tvn="tvnamer --config=$HOME/.config/.tvnamer.json"
alias tvmv="tvnamer --config=$HOME/.config/.tvnamer.json -m -b"
fi
exists matlab && exists wmname && alias matlab='wmname "LG3D"; matlab'
if exists tmux ;
then
alias tmux="tmux -2"
fi
if exists nvim;
then
alias vi="nvim";
elif exists vim.gnome; then
alias vi="vim.gnome";
else
alias vi="vim";
fi