Edit files with your $EDITOR, like git commit does.
Project description
openeditor
Edit files with your $EDITOR, like git commit does.
Usage
Install with: pip install openeditor
# Let user edit file
s = openeditor.edit_file("path/to/my/file.txt")
print("The file now contains:\n" + s)
# Use a temp file
s = openeditor.edit_file(
"# Please edit this file, save and close editor when done",
"path/to/my/file.txt"
)
print("The file now contains:\n" + s)
The editor is obtained from, in order of precedence:
$VISUAL$EDITOR
If neither of these provide a useful editor, an exception will be thrown.
Limitations
openeditor expects an editor string similar to EDITOR=cmd such that:
cmd file.txt(filename as the final argument) is a correct way of editingfile.txt.cmdis not too complex. Simple things like space-separated flags (eg.EDITOR="vim -n") are fine but advanced shell magic may break.
If your cmd does need to be more complex, one possible workaround is to write a wrapper script that presents a compatible command-line interface to openeditor and invokes the full command as appopriate.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openeditor-0.3.1.tar.gz.
File metadata
- Download URL: openeditor-0.3.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
415d2f847b12a112f8d16989c37a697c93fd3b60f4cbf27d180f7815f08c132a
|
|
| MD5 |
8b665902f4333eb137d7780664b613ed
|
|
| BLAKE2b-256 |
462c36fe02e5f3a64849dd1a638921bc86fedfc6a4b59b39b180a9ba331ef6a6
|
File details
Details for the file openeditor-0.3.1-py3-none-any.whl.
File metadata
- Download URL: openeditor-0.3.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
251c792a10fe67bdd6b8b31b9ba4264a349f38740ddad0a5a47223c8bc85d26b
|
|
| MD5 |
77508910f52aa03acf8c28d1c506d1ae
|
|
| BLAKE2b-256 |
ebb6b3cf4bcbe8b416872736da91da224203c65e93ad452c41a387a1524c4e16
|