0
I am trying to insert commands in bashrc via script.
I turn the remote
source powerpyenv.sh
# powerpyenv.sh
echo '### Added by pyenv' >> teste
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> teste
echo 'eval "$(pyenv init -)"' >> teste
echo 'eval "$(pyenv virtualenv-init -)"' >> teste
cat << EOF > temp.txt
### Activate virtualenv
alias manage="python $VIRTUAL_ENV/../manage.py"
alias r="manage runserver"
alias sa='source .venv/bin/activate; PS1="(`basename \"$VIRTUAL_ENV\"`)\e[1;34m:/\W\e[00m$ "; clear'
### Short prompt
alias pa='PS1="(`basename \"$VIRTUAL_ENV\"`)\e[1;34m:/\W\e[00m$ "; clear'
alias p='PS1="\e[1;34m/\W\e[00m$ "; clear'
alias rm="rm -i"
EOF
cat temp.txt >> teste
rm -f temp.txt
source teste
echo "Done"
I’ve played it all in one test for now.
See the test result:
### Added by pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
### Activate virtualenv
alias manage="python /../manage.py"
alias r="manage runserver"
alias sa='source .venv/bin/activate; PS1="("")\e[1;34m:/\W\e[00m$ "; clear'
### Short prompt
alias pa='PS1="("")\e[1;34m:/\W\e[00m$ "; clear'
alias p='PS1="\e[1;34m/\W\e[00m$ "; clear'
alias rm="rm -i"
What are the problems here?
- aliasManage looked different. You need to see how to insert the literal $VIRTUAL_ENV.
- alias was different. Both because of $VIRTUAL_ENV and because of the crase and basename.
Good how to fix it?