Ctrl+P in Docker container
I strive to be efficient on the command line, and some of my favourite keyboard shortcuts in Bash are the ones that allows me to navigate and execute previous commands easily. Some of which are back and forward through the command history with Ctrl+P and Ctrl+N combined with Ctrl+J for executing the command. The problem This is all well and good until you jump in to a Docker container and suddenly Ctrl+P isn’t working as expected anymore. ...
Back up your Bitwarden vault in a future-proof and secure way
Introduction Your Bitwarden vault contains (hopefully) all of your passwords and other sensitive data, so it would be good to have a backup of it in case something goes wrong. ...
Format JSON in Vim with jq
jq is a very powerful command-line tool designed to manipulate JSON data. One of its great features is that it automatically formats JSON output for better readability: $ echo '{"is_jq_awesome": true}' | jq { "is_jq_awesome": true } But in Vim? Can we utilize this inside of Vim? Of course! In Vim, there’s a feature called filter commands that enables us to use external applications to modify our buffers. Filter commands take a range, which is a set of contiguous lines, and a command that processes these lines. This feature is exactly what we need for our purpose. ...
Backup files quick with Bash's brace expansion
Alright, here’s a quick trick that I use at least a few times a week. Problem Let’s say we have a file that we want to make a copy of for whatever reason. In this example we’re creating a backup of the SSH server config before modifying it: $ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak This is fine and dandy, but a bit verbose… We’re writing the same string two times and to be frank, it’s not fun. ...
Closing a stale SSH connection
Suppose you’re connected to a remote host with SSH and after a while the SSH session goes stale. The terminal is unresponsive and no keypress seem to take effect. There might be something with the network, the remote host is restarting or maybe your machine has been in hibernation, there could be multiple reasons for a stale session. The first solution that might come to mind is to just close the terminal emulator and create another one, but there is a better way. ...
Downloading Jenkins artifacts via the CLI
Problem I recently needed to download an artifact from a Jenkins build to my remote dev machine. The remote machine has access to the Jenkins controller, so I just ran wget with the link. $ wget https://jenkins.local/job/.../artifact/my_artifact.tar.gz I got this back: HTTP request sent, awaiting response... 403 Forbidden 2023-04-02 17:43:27 ERROR 403: Forbidden. ...