Bash tips and tricks¶
Create or open ~/.inputrc and add these lines:
nano ~/.inputrc
add these lines to ~/.inputrc
### Respect default shortcuts.
$include /etc/inputrc
### arrow up
"\e[A":history-search-backward
### arrow down
"\e[B":history-search-forward
################################################¶
Git credential manager install. (Install GIT for windows even if you intend to use git in wsl.)
Configure git: https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-git
Typically:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
git config --global user.name "Johan Dahlqvist"
git config --global user.email "johan.dahlqvist@majority.com"
git config --global credential.https://dev.azure.com.useHttpPath true
Make sure you don't have too much in your config :) (one helper)
################################¶
Use Pyenv¶
pyenv/pyenv
(install build tools and set up your shell for Pyenv
################################¶
Use python venv¶
create a python venv with command
python3 -m venv venv
activate the environment.
source venv/bin/activate
The name of the current virtual environment will now appear on the left of the prompt (e.g. (venv)Your-Computer:project_folder UserName$) to let you know that it’s active. From now on, any package that you install using pip will be placed in the venv folder, isolated from the global Python installation.
Install packages using the pip command:
$ pip install requests
If you are done working in the virtual environment for the moment, you can deactivate it:
$ deactivate
This puts you back to the system’s default Python interpreter with all its installed libraries.
To delete a virtual environment, just delete its folder. (In this case, it would be rm -rf venv.)
if your project includes a requirements.txt install all dependencies with:
pip install -r requirements.txt
if developing a new project dump requirements with:
pip freeze > requirements.txt
Check your packages with pip list