mardi 1 janvier 2019

how to change PS1 based on what directory i`m working in?

I get errors

-bash: test1.bash: line 5: syntax error near unexpected token elif' 'bash: test1.bash: line 5:elif [$PWD | grep /mnt/c/ !="" OR pwd | grep /mnt/d/ !=""] then

i have tried nothing other than the code i written

if [$PWD | grep /mnt/c/ =="" OR pwd | grep /mnt/d/ =="" OR pwd | grep /mnt/usb/ ==""] then export PS1="$(tput setaf 47)bob$(tput setaf 14):$(tput setaf 47)linux$(tput setaf 14)>"

elif [$PWD | grep /mnt/c/ !="" OR pwd | grep /mnt/d/ !=""] then export PS1="$(tput setaf 47)bob$(tput setaf 14):$(tput setaf 47)windows$(tput setaf 14)>"

else then export PS1="$(tput setaf 47)bob$(tput setaf 14):$(tput setaf 47)unknows$(tput setaf 14)>" if

i want my PS1 tag to change if i mount a drive for example if im in the directory /mnt/c/ or /mnt/d/ i want PS1 change to windows

Aucun commentaire:

Enregistrer un commentaire