This commit is contained in:
bruno 2023-07-26 10:35:31 -04:00
parent fc801c31ec
commit 9b556fc333
1 changed files with 32 additions and 24 deletions

View File

@ -127,40 +127,48 @@ installSoftware() {
fi fi
} }
# Fonction permettant de déterminer le shell courant # Fonction permettant de déterminer le shell courant
setPATHCurrentShell(){ setPATHCurrentShell(){
CurrentShell = $(echo $SHELL | awk -F/ '{print $NF}') CurrentShell = $(echo $SHELL | awk -F/ '{print $NF}')
info "===> Shell courant : $CurrentShell" info "===> Shell courant : $CurrentShell"
# si le shell est bash # vérifier que ~/.config/scut/ est dans la variable PATH
if [ "$CurrentShell" == "bash" ]; then if [[ $PATH == *~/.config/scut/* ]]; then
warn "===> ~/.config/scut/ est déjà dans la variable PATH"
# Ajouter a la variable PATH le path .config/scut/ au fichier .bashrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.bashrc
# si le shell est zsh
elif [ "$CurrentShell" == "zsh" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .zshrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.zshrc
# si le shell est fish
elif [ "$CurrentShell" == "fish" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .config/fish/config.fish
echo "set PATH $PATH ~/.config/scut/" >> ~/.config/fish/config.fish
# si le shell est NuShell
elif [ "$CurrentShell" == "nu" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .config/nu/config.toml
echo "path = [\"$PATH\", \"~/.config/scut/\"]" >> ~/.config/nu/config.toml
else else
error "!! => Shell courant non supporté : $CurrentShell" # si le shell est bash
error "!! => Veuillez ajouter le path ~/.config/scut/ à votre variable PATH manuellement." if [ "$CurrentShell" == "bash" ]; then
error "!! => les shells supportés sont : bash, zsh, fish et NuShell."
# Ajouter a la variable PATH le path .config/scut/ au fichier .bashrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.bashrc
# si le shell est zsh
elif [ "$CurrentShell" == "zsh" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .zshrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.zshrc
# si le shell est fish
elif [ "$CurrentShell" == "fish" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .config/fish/config.fish
echo "set PATH $PATH ~/.config/scut/" >> ~/.config/fish/config.fish
# si le shell est NuShell
elif [ "$CurrentShell" == "nu" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .config/nu/config.toml
echo "path = [\"$PATH\", \"~/.config/scut/\"]" >> ~/.config/nu/config.toml
else
error "!! => Shell courant non supporté : $CurrentShell"
error "!! => Veuillez ajouter le path ~/.config/scut/ à votre variable PATH manuellement."
error "!! => les shells supportés sont : bash, zsh, fish et NuShell."
fi
fi fi
} }