-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
143 lines (121 loc) · 4.08 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
141
142
143
# Blesh
#[[ $- == *i* ]] && source /usr/share/blesh/ble.sh --noattach
export PATH=$PATH:~/bin
alias DUSORT="du -ksh * | sort -rh"
alias DUSORTA="du -kah * | sort -rh"
alias rebash=". ~/.bashrc"
alias rehist="history -r"
alias i3-log='less $(ls -art ~/logs/i3* | tail -n 1)'
alias sway-log='less $(ls -art ~/logs/sway* | tail -n 1)'
# Commands
alias ls='ls --color=auto'
alias ll='ls -l'
alias cdn='cd $(\ls -1dt ./*/ | head -n 1)'
alias make='rederr make'
alias less='less -S -M -z-5 -W'
alias remake="rederr make $@ clean uninstall && rederr make $@"
alias gitk='gitk --all &'
alias RESET='clear && printf "\e[3J"'
alias ducks='du -cksh -- * | sort -rh | head'
alias lg="lazygit $@"
alias vimr="vim -R $@"
## Have to escape single quotes outside of quotes and concatenate seprate strings implicitly
alias mansearch='man $(apropos --long . | dmenu -i -l 30 | awk '\''{print $2, $1}'\'' | tr -d '\''()'\'')'
alias dotfiles="/usr/bin/git --git-dir=$HOME/dotfiles.git/ --work-tree=$HOME"
# Check for ssh connection
for f in ~/.ssh/*pc0118*user; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
[ -e "$f" ] && echo "Found existing ssh socket: $f" && ssh pc0118
## This is all we needed to know, so we can break after the first iteration
break
done
# Check pc0118 is reachable
alias waitpc0118="until nc -vzw 2 pc0118 22; do sleep 2; done; aplay /usr/share/sounds/alsa/Side_Right.wav"
function highlight() {
grep --color -E "$1|$" "${@:1}"
}
function highlightp() {
grep --color -E "$1|$"
}
# Override cd to allow swapping
function cds() {
if [ $# -eq 2 ]; then builtin cd ${PWD/$1/$2}; else builtin cd $1; fi
}
function del_known_host() {
sed -i.bak -e "$1d" ~/.ssh/known_hosts
}
function undel_known_host() {
mv ~/.ssh/known_hosts.bak ~/.ssh/known_hosts
}
function repeat() {
fc -$1 -1
}
function opacity() {
xprop -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY 0x$1FFFFFFF
}
function whathaveidone() {
ls -t --color=always -l | grep $(whoami) | tail -n +2 | head
}
function tldr {
curl cht.sh/${1} | less -r
}
# Function for creating git aliases
GIT_ALIAS() {
ALIAS=$1
shift
echo 'Executing: git config --global alias.'$ALIAS' "'$@'"'
git config --global alias.$ALIAS "$@"
}
export GIT_ALIAS
# Show log of tags and their commits
GIT_TAG_LOG() { git tag | sort --reverse | xargs git show --quiet; }
export GIT_TAG_LOG
# Trace all commits touching the given file
GIT_TRACE() { git log --oneline --follow -- "$@"; }
export GIT_TRACE
function git_commit_diff() {
#echo "Commit $1:"; \
#git show "$1"; \
#echo "Commit $2:"; \
#git show "$2"; \
#echo "Difference:"; \
#diff -y <(git show "$1") <(git show "$2"); \
vimdiff <(git show "$1") <(git show "$2")
}
# Man page colour
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
# Save all history
export HISTCONTROL=ignoreboth:erasedups # Remove adjacent duplicate entries, ignorespace and ignoredups
export HISTSIZE= # Unlimited history
export HISTFILESIZE= # Unlimited history
export HISTFILE=~/.bash_eternal_history # Move bash history so it doesn't get manually trucated byt applications
shopt -s histappend # Append to history, don't overwrite it
# Append to history after each command finishes - Will be written to file on shell close
PROMPT_COMMAND="history -a"
# Apply solarized colours for Dracula theme
eval $(dircolors ~/.dircolors)
# Manually bind inputrc for some reason
bind -f ~/.config/readline/inputrc
# Keep pwd in new tab
if [[ -f /etc/profile.c/vte.sh ]]; then
source /etc/profile.d/vte.sh
fi
# Starship
export STARSHIP_CONFIG=$HOME/.config/starship.toml
eval "$(starship init bash)"
# blesh
#[[ ${BLE_VERSION-} ]] && ble-attach
# Atuin
eval "$(atuin init bash)"
# zoxide
eval "$(zoxide init --cmd cd bash)"
# Source antidot environment variables
eval "$(antidot init)"