-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_functions.bash
49 lines (43 loc) · 1.25 KB
/
.bash_functions.bash
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
bash_login() {
# Define an array of the files to check
files=(~/.bash_profile ~/.bash_login ~/.profile)
# Loop through each file in the array
for file in "${files[@]}"; do
# Check if the file exists
if [ -f "$file" ]; then
# Source the file and print a message indicating which file was sourced
source "$file"
echo "Sourced: $file"
# Exit the loop after sourcing the first existing file
break
fi
done
}
ssh() {
if [ "$#" -gt 1 ]; then
command ssh "$@"
else
local remote_command=$(cat <<-'EOF'
DOTFILES_DIR=~/test/sbeer/dotfiles
if [[ -d "${DOTFILES_DIR}" ]]; then
git -C "${DOTFILES_DIR}" pull --rebase
else
mkdir -p "${DOTFILES_DIR}"
git clone 'https://github.com/MartyMcFlyInTheSky/dotfiles.git' "${DOTFILES_DIR}"
fi
bash --rcfile "${DOTFILES_DIR}/.bashrc" -i
EOF
)
command ssh -t -o "RemoteCommand=$remote_command" "$@"
fi
}
tmux() {
command tmux -f "$XDG_CONFIG_HOME/tmux/tmux.conf" -L sbeer "$@"
}
vim() {
command vim -Nu "$XDG_CONFIG_HOME/vim/vimrc" "$@"
}
# Export overwritten functions
export -f tmux
export -f ssh
export -f vim