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 else
echo "export PATH=$PATH:~/.config/scut/" >> ~/.bashrc # si le shell est bash
if [ "$CurrentShell" == "bash" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .bashrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.bashrc
# si le shell est zsh # si le shell est zsh
elif [ "$CurrentShell" == "zsh" ]; then elif [ "$CurrentShell" == "zsh" ]; then
# Ajouter a la variable PATH le path .config/scut/ au fichier .zshrc
echo "export PATH=$PATH:~/.config/scut/" >> ~/.zshrc
# Ajouter a la variable PATH le path .config/scut/ au fichier .zshrc # si le shell est fish
echo "export PATH=$PATH:~/.config/scut/" >> ~/.zshrc elif [ "$CurrentShell" == "fish" ]; then
# si le shell est fish # Ajouter a la variable PATH le path .config/scut/ au fichier .config/fish/config.fish
elif [ "$CurrentShell" == "fish" ]; then echo "set PATH $PATH ~/.config/scut/" >> ~/.config/fish/config.fish
# Ajouter a la variable PATH le path .config/scut/ au fichier .config/fish/config.fish # si le shell est NuShell
echo "set PATH $PATH ~/.config/scut/" >> ~/.config/fish/config.fish elif [ "$CurrentShell" == "nu" ]; then
# si le shell est NuShell # Ajouter a la variable PATH le path .config/scut/ au fichier .config/nu/config.toml
elif [ "$CurrentShell" == "nu" ]; then echo "path = [\"$PATH\", \"~/.config/scut/\"]" >> ~/.config/nu/config.toml
# 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" error "!! => Shell courant non supporté : $CurrentShell"
error "!! => Veuillez ajouter le path ~/.config/scut/ à votre variable PATH manuellement." error "!! => Veuillez ajouter le path ~/.config/scut/ à votre variable PATH manuellement."
error "!! => les shells supportés sont : bash, zsh, fish et NuShell." error "!! => les shells supportés sont : bash, zsh, fish et NuShell."
fi
fi fi
} }