forked from zstenger93/42_minishell_tester
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
31 lines (24 loc) · 804 Bytes
/
install.sh
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
#!/bin/bash
cd
rm -rf "$HOME/42_minishell_tester"
git clone https://github.com/LeaYeh/42_minishell_tester.git "$HOME/42_minishell_tester"
cd -
chmod +x "$HOME/42_minishell_tester/tester.sh"
# List of rc files to update
RC_FILES=("$HOME/.bashrc" "$HOME/.zshrc")
# Alias to be added
ALIAS_LINE="\nalias mstest=\"bash $HOME/42_minishell_tester/tester.sh\"\n"
# Function to add alias to a file if it doesn't already exist
add_alias_if_not_present() {
local file=$1
if ! grep "mstest=" "$file" &> /dev/null; then
echo "mstest alias not present in $file"
echo "Adding alias in file: $file"
echo -e "$ALIAS_LINE" >> "$file"
fi
}
# Loop through each rc file and add the alias
for rc_file in "${RC_FILES[@]}"; do
add_alias_if_not_present "$rc_file"
done
exec $SHELL