alias not read in ~/.profile

I added a few aliases to ~/.profile to make creating and activating virtualenvs in python easier. However it doesn’t appear to be reading it as knosole thinks its a typo. I restarted to make sure it could load but stil not activated.

this is all I added.

# Alias for activating virtualenv
alias activate='source .env/bin/activate'
alias virt27='virtualenv -p /usr/bin/python2.7 .env'
alias virt33='virtualenv -p /usr/bin/python3.3 .env'


How can I get the aliases to activate?

flebber wrote:
>
> I added a few aliases to ~/.profile to make creating and activating
> virtualenvs in python easier. However it doesn’t appear to be reading it
> as knosole thinks its a typo. I restarted to make sure it could load but
> stil not activated.
>
> this is all I added.
>
> Code:
> --------------------
> # Alias for activating virtualenv
> alias activate=‘source .env/bin/activate’
> alias virt27=‘virtualenv -p /usr/bin/python2.7 .env’
> alias virt33=‘virtualenv -p /usr/bin/python3.3 .env’
>
>
> --------------------
>
>
> How can I get the aliases to activate?
>
>

Have you installed the relevant virtualenv commands/packages


$virtualenv
If 'virtualenv' is not a typo you can use command-not-found to lookup
the package that contains it, like this:
cnf virtualenv
$cnf virtualenv

The program 'virtualenv' can be found in the following package:
* python-virtualenv  path: /usr/bin/virtualenv, repository: zypp
(download.opensuse.org-oss_1) ]

Try installing with:
sudo zypper install python-virtualenv

$


GNOME 3.6.2
openSUSE Release 12.3 (Dartmouth) 64-bit
Kernel Linux 3.7.10-1.16-desktop

Yeah its installed and I can use it manually.

sayth@linux-g8u9:~/dev/tproj> sudo zypper in python-virtualenv
root's password:
Loading repository data...
Reading installed packages...
'python-virtualenv' is already installed.
No update candidate for 'python-virtualenv-1.10-2.1.3.noarch'. The highest available version is already installed.
Resolving package dependencies...

Nothing to do.
sayth@linux-g8u9:~/dev/tproj> 


Which only proves you have it (well some package) installed. Not that you can use it manualy.

Thus either show how you call it from the console, or at least show

which virtualenv

You allso failed to show what leads you to tell “as knosole thinks its a typo”. You should copy/paste and show us what you see and not tell your conclusions.

Another thing is that in ~/.bashrc I find:

test -s ~/.alias && . ~/.alias || true

which suggest to put extra aliases in a file (to be created) ~/.alias

I do not say that your way of adding aliasses is not correct, but this is what I found.

sayth@linux-g8u9:~> cd testvirt/
sayth@linux-g8u9:~/testvirt> virtualenv -p /usr/bin/python3.3 .env
Running virtualenv with interpreter /usr/bin/python3.3
Using base prefix '/usr'
New python executable in .env/bin/python3.3
Also creating executable in .env/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
sayth@linux-g8u9:~/testvirt> activate
If 'activate' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf activate
sayth@linux-g8u9:~/testvirt> 


Have never created an alias file before but will look at it.

Well there you go.

Never created an ~/.alias file before. But indeed it works.

Thanks

sayth@linux-g8u9:~/testvirt> nano ~/.alias
sayth@linux-g8u9:~/testvirt> exec $SHELL
sayth@linux-g8u9:~/testvirt> activate
(.env)sayth@linux-g8u9:~/testvirt> 


There are many things I did not do before (or even ever), but they work also. lol!

flebber wrote:
> Well there you go.
>
> Never created an ~/.alias file before. But indeed it works.
>
> Thanks

Does it also work if you put the aliases directly in .bashrc instead of
in .alias?

Remember there is a difference between .profile and .bashrc! Was
…profile actually being read in the cases where it didn’t work?

I had the same problem.

It does work to put alias directly in .bashrc.

It does not work in .profile. Which is confusing. .profile is supposed to be done for every login. Which means that every sub-shell is supposed to have the alias values. But no… To make it more confusing, any environment values set in .profile are kept in sub-shells.

The .bashrc is supposed to be done for every interactive shell. It keeps the alias values.