-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases
199 lines (171 loc) · 5.24 KB
/
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
########################################
# ~/.dotfiles/aliases
# Keeps all my aliases between bash and zsh
#
# Sections:
# -> General Shell
# -> Editors
# -> Git
# -> Ledger
# -> Distro Specific
# -> Misc Programs
# -> Functions
########################################
########################################
# General shell
########################################
alias cp='cp -iv'
alias df='df -h'
alias du='du -hsc'
alias h='history'
knownhosts() { sed -i -e "$1d" ~/.ssh/known_hosts; }
alias la='ls -a --color'
alias lal='ls -lah --color'
alias lb='lsblk'
alias less='less -Rni'
alias le='less'
alias ll='ls -oh --color'
alias ls='ls -h --color'
mcd() { mkdir -pv "$1" && cd "$1"; }
alias md='mkdir -pv'
alias mv='mv -v'
alias po='popd'
alias pu='pushd'
alias prettify-json='python -m json.tool'
alias prettify-xml='xmllint --format -'
alias psg='ps -aux | grep -i'
alias python='python3'
alias ipython='ipython3'
alias pip='pip3'
alias rd='rmdir'
alias reboot='sudo reboot'
alias remount='sudo mount -a'
alias rm='rm -v'
alias sl='ls'
function off() {
if [[ $1 ]]; then
echo $1
sudo shutdown $1
else
sudo shutdown 0
fi
}
########################################
# Editors
########################################
#if [[ -x /usr/bin/nvim || -x /usr/local/bin/nvim ]]; then
#alias vim='nvim'
#fi
alias em='emacsclient -c --no-wait'
alias realias='vim ~/.dotfiles/aliases; source ~/.dotfiles/aliases'
alias revariable='vim ~/.dotfiles/variables; source ~/.dotfiles/variables'
alias suvi='sudoedit'
alias vi='vim'
########################################
# Version Control
########################################
alias ga='git add'
alias gd='git diff'
alias gc='git commit -m'
alias gpsh='git push'
alias gpll='git pull'
alias gst='git status'
alias gco='git checkout'
alias glog='git log --oneline --decorate --color --graph'
# Get deleted files out of the repo
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"
alias svnrevert='svn status -q | xargs svn revert --depth infinity'
# Prints status of only revision controlled files, ignores unrevisioned stuff (be careful not to miss them on your checkin)
# This is useful when there is a log of autogenerated noise in the ‘svn status’ file list
alias svnstat='svn status . 2> /dev/null | grep -v \?'
# good when merging, checking out, or you want to paste a url into the browser to browse to an alternate branch version of a file
alias svnurl='svn info . 2> /dev/null | grep ^URL: | awk "{ print \$2; }"'
########################################
# Ledger
########################################
alias ledger='ledger --explicit'
alias bal='ledger bal -R'
alias balbit='ledger -R --current --flat bal assets:crypto'
alias balcash='ledger -R -X $ --current --flat bal assets:bank liabilities:credit'
alias balfid='ledger -R -X $ --current bal assets:fidelity'
alias balnet='ledger -R -X $ --current --depth 2 bal assets liabilities'
alias leg='ledger print --tail 5'
alias reg='ledger reg -R --tail 15'
cashflow() {
if [ -z "$1" ]; then
period="this month"
else
period="$@"
fi
ledger --current --invert --real --wide -s -X $ -S "amount" -p "$period" reg income expenses
}
########################################
# Distro Specific
########################################
browse_files() { nohup "$1" "$(pwd)" >/dev/null 2>&1 & }
# Files - ls + g(ui)
if [[ -x /usr/bin/dolphin ]]; then
alias lsg='browse_files dolphin' # KDE
elif [[ -x /usr/bin/nautilus ]]; then
alias lsg='browse_files nautilus' # GNOME
elif [[ -x /usr/bin/nemo ]]; then
alias lsg='browse_files nemo' # Cinnamon
elif [[ -x /usr/bin/thunar ]]; then
alias lsg='browse_files thunar' # XFCE
fi
# Packages
if [[ -x /usr/bin/pacman ]]; then
alias pacs='sudo pacman -S'
alias pacu='sudo pacman -U'
alias pacr='sudo pacman -R'
alias pacq='pacman -Q | grep'
elif [[ -x /usr/bin/apt ]]; then
alias apti='sudo apt-get install -y'
alias aptr='sudo apt-get remove'
elif [[ -x /bin/rpm ]]; then
alias yumi='sudo yum install -y'
alias yumr='sudo yum remove'
alias yumq='yum search'
alias yumup='sudo yum update'
alias rpmq='rpm -qa | grep'
fi
if [[ -x /usr/bin/vendor_perl/mimeopen ]]; then
alias open='mimeopen'
else
alias open='xdg-open'
fi
########################################
# Misc Programs
########################################
alias diff='colordiff'
alias ff='firefox 2>/dev/null &'
alias grep='grep --color'
alias play='mpv'
alias userctl='systemctl --user'
alias xclip='xclip -selection c'
# Redshift will toggle on the USR1 signal
alias redkill='pkill -USR1 redshift'
########################################
# Functions
########################################
# Generic extracting
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1;;
*.tar.gz) tar xzf $1;;
*.bz2) bunzip2 $1;;
*.rar) rar x $1;;
*.gz) gunzip $1;;
*.tar) tar xf $1;;
*.tbz2) tar xjf $1;;
*.tgz) tar xzf $1;;
*.zip) unzip $1;;
*.Z) uncompress $1;;
*.7z) 7z x $1;;
*) echo "'$1' cannot be extracted via extract()";;
esac
else
echo "'$1' is not a valid file"
fi
}