-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_bash.sh
More file actions
24 lines (24 loc) · 1.26 KB
/
setup_bash.sh
File metadata and controls
24 lines (24 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
echo "Initializing aishell for $SUDO_USER..."
for shell_config in "$USER_HOME/.bashrc" "$USER_HOME/.zshrc"; do
if [ -f "$shell_config" ]; then
if ! grep -q 'eval "$(aishell init' "$shell_config"; then
echo "Adding aishell init to $shell_config"
echo 'eval "$(aishell init bash)"' >> "$shell_config"
echo 'aishell_suggestion() {' >> "$shell_config"
echo ' local suggestion_file="/tmp/aishell_suggestion"' >> "$shell_config"
echo ' if [ -f "$suggestion_file" ]; then' >> "$shell_config"
echo ' fix=$(< "$suggestion_file")' >> "$shell_config"
echo ' rm -f "$suggestion_file"' >> "$shell_config"
echo ' READLINE_LINE="$fix"' >> "$shell_config"
echo ' READLINE_POINT=${#fix}' >> "$shell_config"
echo ' else' >> "$shell_config"
echo ' echo "No suggestion available."' >> "$shell_config"
echo ' fi' >> "$shell_config"
echo '}' >> "$shell_config"
#echo 'bind -x \'"\\C-t":aishell_suggestion\'' >> "$shell_config"
printf "bind -x '\\\"\\\\C-t\\\":aishell_suggestion'\n" >> "$shell_config"
else
echo "aishell already initialized in $shell_config"
fi
fi
done