Using Warp workflows to make the shell easier
source link: https://kchodorow.com/2022/05/15/using-warp-workflows-to-make-the-shell-easier/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Using Warp workflows to make the shell easier
Disclaimer: GV is an investor in Warp.
Whenever I start a new Python project, I have to go look up the syntax for creating a virtual environment. Somehow it can never stick in my brain, but it seems too trivial to add a script for. I’ve been using Warp as my main shell for a few months now and noticed they they have a feature called “workflows,” which seems to make it easy to add a searchable, documented command you frequently use right to the shell.
To add a workflow to the Warp shell, create a ~/.warp/workflows directory and add a YAML file describing the workflow:
$ mkdir -p ~/.warp/workflows
$ emacs ~/.warp/workflows/venv.yaml
Then I used one of the built-in workflows as a template and modified it to create a virtual environment:
---
name: Create a virtual environment
command: "python3 -m venv {{directory}}"
tags: ["python"]
description: Creates a virtual environment for the current directory.
arguments:
- name: directory
description: The directory to contain the virtual environment.
default_value: .venv
source_url: "https://docs.python.org/3/library/venv.html"
author: kchodorow
author_url: "https://www.kchodorow.com"
shells: []
I saved the file, typed Ctrl-Shift-R, and typed venv and my nice, documented workflow popped up:
However, I’d really like this to handle creating or activating it, so I changed the command to:
command: "[ -d '{{directory}}' ] && source '{{directory}}/bin/activate' || python3 -m venv {{directory}}"
Which now yields:
So nice.
Posted bykchodorowMay 15, 2022Posted inUncategorized
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK