- Author:
- HubertGrzeskowiak
- Posted:
- June 11, 2014
- Language:
- Shell
- Version:
- Not specified
- Score:
- 1 (after 1 ratings)
When you use Virtualfish, the virtualenv wrapper for the fish shell, you can add hooks for whenever the virtualenv is activated. This little snippet sets some important environment variables and adds the manage.py command with autocompletion so that you won't ever need to write "python ./manage.py help" ever again, but only "manage <TAB>".
For this to work you need to source or paste this code in your ~/.config/fish/config.fish
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function virtualenv_paths --on-event virtualenv_did_activate:YOUR_VIRTUALENV
# set pythonpath and settings module
set -gx PYTHONPATH ~/YOUR_PROJECT
set -gx DJANGO_SETTINGS_MODULE yourproject.settings.settings_dev
# make manage.py usable from anywhere while the virtualenv is active
function manage
python ~/YOUR_PROJECT/manage.py $argv
end
# set up autocompletions
function list_django_commands
manage | python -c "import sys; print '\n'.join([c.replace(' ', '') for c in sys.stdin.read().split('Available subcommands')[1].split('\n') if c.startswith(' ')])"
end
complete -x -c manage -a "(list_django_commands)"
end
|
More like this
- the steps of migration using south in Django... by lockys 10 years, 2 months ago
- One line SMTP sink server by Baguage 10 years, 3 months ago
- How to rename processes by diverman 13 years ago
- Add CSRF token to templates by coleifer 13 years, 4 months ago
Comments
Please login first before commenting.