Skip to main content
Typo
Source Link
Edgar Magallon
  • 5.1k
  • 3
  • 15
  • 29

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). 
This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read someheresomewhere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

EDIT: To clarify, what I want my alias to run is iei.e:

  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && [ ! -f ./requirements.txt ] || pip install -r requirements.txt"txt
    • This creates a virtual for python projects
  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && pip install nodeenv && nodeenv -p"p
    • This creates virtual environments for projects that depend on nodejs, which in itself depend on python venv

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somehere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

EDIT: To clarify, what I want my alias to run is ie:

  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && [ ! -f ./requirements.txt ] || pip install -r requirements.txt"
    • This creates a virtual for python projects
  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && pip install nodeenv && nodeenv -p"
    • This creates virtual environments for projects that depend on nodejs, which in itself depend on python venv

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). 
This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somewhere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

EDIT: To clarify, what I want my alias to run is i.e:

  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && [ ! -f ./requirements.txt ] || pip install -r requirements.txt
    • This creates a virtual for python projects
  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && pip install nodeenv && nodeenv -p
    • This creates virtual environments for projects that depend on nodejs, which in itself depend on python venv
added 468 characters in body
Source Link
calexandru
  • 210
  • 2
  • 9

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somehere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

EDIT: To clarify, what I want my alias to run is ie:

  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && [ ! -f ./requirements.txt ] || pip install -r requirements.txt"
    • This creates a virtual for python projects
  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && pip install nodeenv && nodeenv -p"
    • This creates virtual environments for projects that depend on nodejs, which in itself depend on python venv

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somehere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somehere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.

EDIT: To clarify, what I want my alias to run is ie:

  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && [ ! -f ./requirements.txt ] || pip install -r requirements.txt"
    • This creates a virtual for python projects
  • python3 -m venv <CURRENT_DIRECTORY_NAME> && source <CURRENT_DIRECTORY_NAME>/bin/activate && pip install nodeenv && nodeenv -p"
    • This creates virtual environments for projects that depend on nodejs, which in itself depend on python venv
Source Link
calexandru
  • 210
  • 2
  • 9

Set alias to run python venv setup based on current directory name

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).

What I want to achieve is to create an alias that creates a python virtual environment, where the folder name for the virtual environment is the name of the current working directory (something akin to python3 -m venv $cwd). This is helpful especially when activating the venv (and later switching directories between project) you can easily identify which venv is enabled.

But for some odd reason this is not working as I expected. To note that I don't have much experience in creating complex aliases but still. I have created the following vars in .bashrc:

  • export cwd="pwd | rev | cut -d '/' -f1 | rev"
    • If I run this in termnial it displays the directory name test as I need it, but when running $cwd in the terminal I get home/<USERNAME>/Projects/VueJS/test
  • export cwd2="${PWD##*/}"
    • This one just displays my username for some reason. I've searched here on stackoverflow and this was one of the suggested methods to get the current directory name

Some indication on how to get started or where to look for info are appreciated. I've tried to search on multiple sources but I can't seem to figure it. I read somehere that double and single quotes make a difference, but I couldn't understand why and if it would affect this behaviour.