Sometimes you will want to ensure that a file is sourced instead of executed. This ensures, among other things, that any environment variables that the script defines remain in your current shell after the script completes.
To do so, use the following to check whether the file was sourced or run in a sub-shell
I have no idea why, but for some reason I always have a hard time remembering the exact syntax for find when I want to prune some list of directories from a search.
Let’s say that you want to execute a find in a directory where there are a lot of .git directories and you don’t want to search through the guts of the repo directories. With the following command we specify the prune predicate ahead of the search for → Continue reading “Pruning directories from find”
The TLDR; is to first use tr to replace all occurrences of any horizontal whitespace character with a single space, and then squeeze down any number of spaces to a single space and then define the delimiter for cut as a single space. The following example assumes that you want to see from the 5th column to the end of the line.
I finally was able to get Visual Studio Code set-up correctly to run and debug unit and integration tests for a Python 3.8 project that I am working on (I’ll add a link to that post here once it is up).
After making some changes to the code and adding a test I got the following error when trying to debug the test:
Test result not found for: ./mylibs/integration_tests/myclient_integration_test.py::MyClientIntegrationTest::test_happy_path
Yes, I know. 3.8.x? That’s an older version of Python but there are still a number of current applications and libs that require 3.8 as well as a number of distros that still have 3.8 as the most recent easily installable version. With that being said, the following is a quick how to on getting it compiled under both RedHat/CentOS/Almalinux and Debian based systems.
I recently learned about the Bash built-in fc. It is a great tool that enables you to edit and re-execute commands from your bash history.
Oftentimes there is a command in your history that instead of just grepping through the history and then re-executing as-is you’ll want to make a modification or two. With fc you can first edit it in your favorite editor and then when closing the editor fc will execute the command.
I regularly use Python Invoke and Fabric for the automation of various tasks; from deploying code to developing my own set of tools for various projects. Following is an example on how to write a launch.json launch configuration for vscode so that you can step through the tasks.py code and debug it.
If you would like to have different tab configurations (tabs or spaces) along with the number of tab chars for different file types you can update your user settings.
The first thing you need to do is figure out what the file type code thinks the file that you want to change is. Open the file in vscode and then look at the bottom right of your window. In my case, I’m looking at an avro schema (.avsc) file:
I usually have at least two panes in my IDE so that I can see two files, or different parts of the same file, at the same time. VSCode pegs the debug variables in the Explorer side bar so I also end up having to make that panel large at times to see the variables while debugging.
Following are the keybindings that you can add to enable you to toggle the visibility of the left-hand side panel.