Results 1 to 9 of 9

Thread: alias not read in ~/.profile

  1. #1
    Join Date
    Nov 2010
    Location
    NSW, Australia
    Posts
    87

    Default 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.
    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?

  2. #2
    Join Date
    May 2010
    Location
    Space Colony Lagrange Point 22° à, 77° Ƅ, 56° ɤ, 99° ɜ
    Posts
    3,166

    Default Re: alias not read in ~/.profile

    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

    Code:
    $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

  3. #3
    Join Date
    Nov 2010
    Location
    NSW, Australia
    Posts
    87

    Default Re: alias not read in ~/.profile

    Yeah its installed and I can use it manually.

    Code:
    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>

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,601

    Default Re: alias not read in ~/.profile

    Quote Originally Posted by flebber View Post
    Yeah its installed and I can use it manually.

    Code:
    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
    Code:
    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:
    Code:
    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.
    Henk van Velden

  5. #5
    Join Date
    Nov 2010
    Location
    NSW, Australia
    Posts
    87

    Default Re: alias not read in ~/.profile

    Code:
    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.

  6. #6
    Join Date
    Nov 2010
    Location
    NSW, Australia
    Posts
    87

    Default Re: alias not read in ~/.profile

    Well there you go.

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

    Thanks

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

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,601

    Default Re: alias not read in ~/.profile

    Quote Originally Posted by flebber View Post
    Well there you go.

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

    Thanks

    Code:
    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.
    Henk van Velden

  8. #8

    Default Re: alias not read in ~/.profile

    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?

  9. #9

    Default Re: alias not read in ~/.profile

    Quote Originally Posted by djh-novell View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •