-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
164 lines (137 loc) · 3.76 KB
/
dot_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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
# Custom PS1 prompt
# Set colors
username_color='\[\033[01;35m\]'
hostname_color='\[\033[01;32m\]'
filepath_color='\[\033[01;34m\]'
reset_color='\[\033[0m\]'
# Set prompt format
PS1="${username_color}\u${reset_color}@${hostname_color}\h${reset_color}:${filepath_color}\w${reset_color}\$ "
alias brc='nv ~/.bashrc && source ~/.bashrc'
alias sbrc='source ~/.bashrc'
# Navigating up the directory tree
x=".."
y=".."
alias $x="cd $y"
for i in {1..15}; do x="${x}."; y="${y}/.."; alias $x="cd $y"; done
# My Stuff
alias nv=nvim
alias rmswp='rm ~/.local/state/nvim/swap/*.swp'
rmmac() {
find . -type f -name ".DS_Store" -delete
find . -type d -name "__MACOSX" -exec rm -rf {} +
}
# Other aliases
alias op='xdg-open 2>/dev/null'
complete -F _filedir_xspec op
alias fop='op "$(fzf)"'
fcd() {
local dir
dir="$(find * -type d 2> /dev/null | fzf)" && cd "$dir"
}
fmv() {
local files=()
local dest_dir
# If no file arguments provided, show an error message and return
if [ "$#" -eq 0 ]; then
echo "No files specified for moving. Usage: fmv file1 file2 file3 ..."
return 1
fi
# Collect file arguments
for file in "$@"; do
if [ -f "$file" ]; then
files+=("$file")
else
echo "File '$file' not found."
fi
done
# Use fzf to select the destination directory from ~
dest_dir=$(find "$HOME" -type d -not -path '*/\.*' 2>/dev/null | fzf)
if [ -z "$dest_dir" ]; then
echo "No destination directory selected. Aborting."
return 1
fi
# Move selected files to the destination directory
for file in "${files[@]}"; do
mv "$file" "$dest_dir"
done
cd "$dest_dir"
}
socprint() {
FILE=$1
TMPNAME="~/__TO_PRINT"
scp "$FILE" stu:$TMPNAME &&
ssh stu "lpr -Ppsts $TMPNAME && rm $TMPNAME"
}
complete -F _filedir_xspec psts
alias back="git checkout main"
alias new="git checkout main; git checkout -b"
alias gad="git add"
alias gcm="git commit -m"
alias gca="git commit --amend --no-edit"
alias gco="git checkout"
alias gcob="git checkout -b"
alias gdf="git diff"
alias glg="git lg"
alias gmg="git merge"
alias gps="git push -u origin HEAD"
alias gpl="git pull"
alias gst="git status"
getpr() {
if [ $# -ne 1 ]; then
echo "Usage: getpr ID"
return 1
fi
ID=$1
BRANCHNAME="pr-$ID"
git fetch origin "pull/$ID/head:$BRANCHNAME"
echo "Fetched pull request $ID and created branch $BRANCHNAME"
}
eval "$(zoxide init bash)"
alias dwr="dnf repoquery --whatrequires"
alias dwd="dnf repoquery --whatdepends"
chezupdate() {
ORIG=$(pwd)
chezmoi re-add
cd $(chezmoi source-path)
git diff
echo "confirm? (y/n)"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
git add . && git commit -m "$(git diff --staged --name-only | xargs -rd '\n' basename -a | sed 's/dot_//g' | awk '{print}' ORS=' ')" && git push -u origin HEAD
fi
cd $ORIG
}
alias fz="fzf --preview-window=up,20%,wrap --preview='basename {}' --hscroll-off=180 --cycle --height=~25%"
frg() {
rg --line-number --color=always --smart-case "$@" | fzf \
--delimiter : \
-n 2.. \
--ansi --no-sort \
--preview-window '+{2}/2' --preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \
--cycle \
--bind alt-k:preview-up,alt-j:preview-down | \
sed 's/^\([^:]*\):[0-9]*:.*/\1/' | \
xargs -r nvim
}