-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
140 lines (112 loc) · 3.92 KB
/
.bashrc
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
# shellcheck shell=bash
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
if [[ $- != *i* ]] ; then
return
fi
# bash options
export PAGER="less -RS"
export MANPAGER="less -X -j3"
export EDITOR='micro'
export LESSHISTFILE=-
export NODE_REPL_HISTORY=""
export FZF_DEFAULT_COMMAND="fd --type file --color=always"
export FZF_DEFAULT_OPTS="--ansi"
HISTCONTROL=ignoreboth:erasedups
history -r ~/.bash_commands.sh
unset HISTFILE
for option in autocd dotglob extglob; do
shopt -s $option &>/dev/null
done
# shell helpers
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias la='ls -Fhlva --color=auto'
alias ll='ls -Fhlv --color=auto'
alias mkdir='mkdir -vp'
alias cp='cp -vi'
alias mv='mv -vi'
alias rm='rm -vi --one-file-system'
alias path='printf "%s\n" "$PATH" | tr -s ":" "\n"'
alias where='find . -name'
alias count='sort | uniq -c | sort -hr'
alias watch='watch --color --differences'
alias uniqall='awk "!_[\$0]++"'
alias uncomment='grep -v "^#"'
alias reset='tput reset'
# rpm/zypper
alias provider='zypper search --provides --match-substrings'
alias pkg='zypper info --requires --provides --recommends --supplements --suggests'
alias dep='zypper search --requires-pkg --provides-pkg --recommends-pkg --supplements-pkg --suggests-pkg'
alias rpmkeys='rpm -q gpg-pubkey --qf "%{name}-%{version}-%{release} --> %{summary}\n"'
# tools
alias clip='xclip -selection clipboard'
alias newpasswd='read -r -n 16 pass < <(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom) && echo -n $pass'
alias newid='dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d " \t\n"; echo'
alias pubkey='xclip -selection clipboard < ~/.ssh/id_rsa.pub | echo "=> Public key copied to clipboard."'
alias json='python3 -m json.tool <'
alias up='TERM=xterm up'
alias decolorize=$'sed \'s/\x1b\[[0-9;]*m//g\''
alias shlint='ls bin/* | entr -s "shellcheck --external-sources --source-path=$HOME --color=always --exclude=SC2016 bin/*"'
alias browse='fzf --preview "bat --style=numbers --color=always {}"'
alias wanip4='dig @resolver1.opendns.com -4 myip.opendns.com A +short'
alias wanip6='dig @resolver1.opendns.com -6 myip.opendns.com AAAA +short'
alias ipv6_on='sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0'
alias ipv6_off='sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1'
alias lsint='watch -d -n 5 cat /proc/interrupts'
alias optirun="env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LIBVA_DRIVER_NAME=nvidia"
alias reset_webcam='sudo modprobe -r uvcvideo && sudo modprobe uvcvideo'
# sudo
alias btrfs='sudo btrfs'
alias etckeeper='sudo etckeeper'
alias etcdiff='etckeeper vcs diff | delta --navigate'
alias iotop='sudo iotop'
alias rpmconf='sudo rpmconf'
alias rpmconfigcheck='sudo rpmconfigcheck'
alias snapper='sudo snapper'
alias zypper='sudo zypper'
alias visudo='sudo visudo'
alias backup='sudo ~/bin/backup'
alias filefrag='/usr/sbin/filefrag'
diff() {
command diff -u "$@" | delta
}
highlight() {
grep --color=always --extended-regexp -e "^" -e "$*" | less -R
}
timeit() {
"$@" 2>&1 | awk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }'
}
mkd() {
[[ $1 ]] && mkdir "$1" && cd "$1"
}
duh() {
local path="$1"
local pattern="$2"
du $(find "$path" -name "$pattern") | awk '{total += $1} END {print total "K"}'
}
tldr() {
command tldr --color=always "$@" | less -F
}
edit() {
$EDITOR "$(browse)"
}
_editrc_files() {
dotfiles ls-files | nl -w2 -n'rz' -s' '
}
_editrc_completions() {
if [[ "${#COMP_WORDS[@]}" != "2" ]]; then
return
fi
local IFS=$'\n'
COMPREPLY=($(compgen -W "$(_editrc_files)" -- "${COMP_WORDS[1]}"))
}
complete -F _editrc_completions editrc
# Default options for interactive mode
set -o noclobber -o pipefail
return