apt alternative for proxy environment with bash shell
Storing passwords in text files is never a good idea, especially if you give that file world-readable permissions.

Try this:

#!/bin/bash 

mkdir -p ~/bin/

# add ~/bin to PATH if not already there
echo '[[ :"$PATH": == *:"$HOME/bin":* ]] || PATH="$HOME/bin:$PATH"' &gt;&gt; .bashrc

# create the apt-proxy script
cat &lt;&lt;'END_SCRIPT' &gt; ~/bin/apt-proxy
#!/bin/bash

stty -echo
printf "Password for %s: " "$LOGNAME"
read password
stty echo
echo

export http_proxy="http://${LOGNAME}:${password}@10.20.10.50:3128"
sudo -S apt-get "$@" &lt;&lt;&lt; "$password"
END_SCRIPT

chmod 755 ~/bin/apt-proxy

cat &lt;&lt;INSTRUCTIONS
The apt-proxy script has been installed. 
You may need to log out and log back in before you can use it.

usage: apt-proxy package ...
INSTRUCTIONS



mkdir -p dir will silently do nothing if the directory already exists
you only need to add the user's bin dir to the PATH if it is not already there
DO NOT store the user's password. Have the user enter it each time.
you should not even need to use sudo to edit files in your home directory.
777 permissions is overly generous: the world does not have to be able to edit the file
use sudo -S and pass the user's password via stdin