Introducing Posting 2.0
Posting is a powerful HTTP client that runs entirely inside your terminal.
Version 2.0 has just arrived, bringing some powerful new features to Posting, including scripting, keymaps, and more!
Pre-request and post-response scripts
A common feature request has been around adding scripting capabilities to Posting. With 2.0, you can now attach Python functions to requests, and have them run before or after the request is sent. All output from these scripts is captured and displayed in the new “Scripts” tab. This makes it easy to see the results of your script executions and troubleshoot any issues.
This is an extremely versatile feature. You can use scripts to perform setup, set variables which requests and other scripts can access, modify outgoing requests, and much more. Here’s an example of some Python code which you can attach to a request:
def on_request(request: RequestModel, posting: Posting) -> None:
request.headers.append(Header(name="X-Custom-Header", value="foo"))
request.auth = Auth.basic_auth("username", "password")
print("Request is being sent!")
posting.notify("Request is being sent!")
The API is currently a bit rough around the edges, but it’ll be improved in future releases.
Attached scripts can even be edited in an external editor, and Posting will automatically reload them when they are changed.
There’s also a convenience keyboard shortcut which allows you to quickly open a request’s scripts in your preferred $EDITOR
,
so you could quickly swap over to vim
or nano
to make changes, then return to Posting to continue working.
Check out the scripting docs for more details!
Keymaps
Posting 2.0 also allows you to declare custom keybindings, thanks to an update in the underlying Textual framework. For 2.0 only “global” keybindings can be remapped, but this will be expanded in future releases to include most keybindings.
You can customise your keymap by adding a keymap
section to your Posting config.
Here’s a short example which changes the default for sending the request to ctrl+r
:
keymap:
send-request: "ctrl+r"
Hopefully this will help you feel more at home in Posting, and avoid awkward clashes with emulators and multiplexers!
See the keymap docs for more details!
Customisable hostnames
Posting is a TUI, which means it works great over SSH. However, when working inside a TUI, it’s sometimes easy to forget which host you’re on.
In 2.0, there’s a new config option which allows you to customise the hostnames which are displayed in the header, including styling them with Rich markup to make them stand out.
This is useful if you work with Posting in multiple environments, such as your local machine, a staging server, and a production server.
Here’s the config I use on my “production” server to achieve the effect above:
heading:
hostname: "[black on #ff0000 bold blink]PRODUCTION[/]"
Documentation
Posting’s documentation has been expanded, making it easier than ever to get started!
The additions include:
- Duplicating and “quick duplicating” requests.
- Scripting.
- Keymaps.
- Integrating Posting with external tools.
- An improved getting started guide which better showcases some quality-of-life features that may not be obvious at first glance :)
What’s next?
Textual 1.0 is around the corner, and will unlock a better theming system for Posting as well as a more powerful command palette!
I’ve also braindumped some features I’d like to implement in Posting here.
The new features mentioned in this post and those on the roadmap are very much driven by users. If you’d like to suggest new features, please open a discussion on GitHub!