Give github actions the -e flag in the shebang #! so they fail on any one
command failure. Otherwise each line will set the exit status, but only the
last one will be passed to ci.
#!/bin/bash -e
What is -e #
The -e flag to the bash command allows your script to exit immediately if any command within the script returns a non-zero exit status. This can be useful for ensuring that your script exits with an error if any of the commands it runs fail, which can help you identify and debug issues in your script. For example, if you have a script that runs several commands and one of those commands fails, the script will continue running without the -e flag, but will exit immediately if the -e flag is present. This can make it easier to troubleshoot your script and ensure that it runs correctly.
Solution for Windows #
In windows the solution is not quite as simple. You can define a function in a Windows batch script that wraps an if statement to check the exit status of a command and handle any errors that may have occurred. Here is an example of how you might define a function called “check_error” that does this:
:check_error
if errorlevel 1 (
echo An error occurred!
exit /b 1
)
To use this function in your script, you would simply call it after running a command, like this:
some_command
call :check_error
This would run the “some_command” and then call the “check_error” function to check the exit status and handle any errors that may have occurred. This approach allows you to reuse the error-checking logic in your script, which can make it easier to write and maintain.
minecraft documentary
I recently setup some vm’s on my main machine and got sick of signing in with passwords.
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub virt
Moving panes between tmux sessions is something that makes tmux a very flexible and powerful tool. I don’t need this feature very often, but it comes in clutch when you need it.
Pull a pane from any other session #
Using choose-window I was able to come up with a way to select any pane
withing any other session and join it into my current session.
# Choose a pane to join in horizontally
bind f choose-window -Z 'join-pane -h -s "%%"'
Push/Pull from scratch #
I’ve long had this one in my tmux config, I always have a “scratch” session
that I’m running, I often use for looking at things like k9s accross repos
within a popup.
This use case puts a pane into the scratch session, then pulls it back out. I will use this to move a pane between sessions in the rare cases I need to do this.
# push the active pane into the scratch session horizonally
bind -n M-f join-pane -ht scratch
# pull the last active pane from the scratch session horizonally into this session
bind -n M-F join-pane -hs scratch
I just shared some ssh keys with myself and ran into this error telling me that I did not set the correct permissions on my key.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0750 for '/home/waylon/.ssh/id_*******' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/waylon/.ssh/id_*******": bad Permissions
repo: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I changed them with the following commands.
chmod 644 ~/.ssh/id_*******.pub
chmod 600 ~/.ssh/id_*******
With the latest release of version of nvim 0.8.0 we get access to a new winbar feature. One thing I have long wanted somewhere in my nvim is navigation for pairing partners or anyone watching can keep track of where I am. As the driver it’s easy to keep track of the file/function you are in. But when you make big jumps in a few keystrokes it can be quite disorienting to anyone watching, and having this feedback to look at is very helpful.
winbar #
nvim exposes the winbar api in lua, and you can send any text to the winbar as follows.
vim.o.winbar = "here"
You can try it for yourself right from the nvim command line.
:lua vim.o.winbar = "here"
Now you will notice one line above your file with the word here at the very
beginning.
Clearing the winbar #
If you want to clear it out, you can just set it to an empty string or nil.
:lua vim.o.winbar = ""
:lua vim.o.winbar = nil
Setting up nvim-navic #
You will need to install nvim-navic if you want to use it. I added it to my
plugins using Plug as follows.
call plug#begin('~/.local/share/nvim/plugged')
Plug 'SmiteshP/nvim-navic'
call plug#end()
Note!
nvim-navicdoes require the use of the nvim lsp, so if you are not using it then maybe this won’t work for you.
I created an on_attach function long ago, cause that’s what Teej told me to
do. Now I am glad I did, because it made this change super easy.
local function on_attach(client, bufnr)
if client.server_capabilities.documentSymbolProvider then
navic.attach(client, bufnr)
end
end
Then you need to use that on_attach function on all of the lsp’s that you
want navic to work on.
Then in a lua file you need to setup the winbar, for now I put this in my lsp-config settings file, but eventually I want to move my settings to lua and put it there.
vim.o.winbar = " %{%v:lua.vim.fn.expand('%F')%} %{%v:lua.require'nvim-navic'.get_location()%}"
What my winbar looks like #
What I have right now is everything someone who is watching would need to know to navigate to the same place that I am in the project.
waylonwalker/app.py Link > on_click
Diff #
Here are the changes that I made to to my plugins list and my lsp-config to get it.
/home/u_walkews/.config/nvim/plugins.vim
call plug#begin('~/.local/share/nvim/plugged')
+Plug 'SmiteshP/nvim-navic'
# /home/u_walkews/.config/nvim/lua/waylonwalker/lsp-config.lua
-local function on_attach() end
+local navic = require("nvim-navic")
+local function on_attach(client, bufnr)
+ if client.server_capabilities.documentSymbolProvider then
+ navic.attach(client, bufnr)
+ end
+end
+
+vim.o.winbar = " %{%v:lua.vim.fn.expand('%F')%} %{%v:lua.require'nvim-navic'.get_location()%}"
GH commit #
If you want to see the change on GitHub, here is the diff
I really like having global cli command installed with pipx. Since textual
0.2.x (the css release) is out I want to be able to pop into textual devtools
easily from anywhere.
Pipx Install #
You can pipx install textual.
pipx install textual
But if you try to run any textual cli commands you will run into a
ModuleNotFoundError, because you need to install the optional dev
dependencies.
Traceback (most recent call last):
File "/home/u_walkews/.local/bin/textual", line 5, in <module>
from textual.cli.cli import run
File "/home/u_walkews/.local/pipx/venvs/textual/lib/python3.10/site-packages/textual/cli/cli.py", line 4, in <module>
import click
ModuleNotFoundError: No module named 'click'
Pipx Inject #
In order to install optional dependencies with pipx you need to first install
the library, then inject in the optional dependencies using the square bracket
syntax.
pipx install textual
pipx inject textual 'textual[dev]'
I am working through the textual tutorial, and I want to put it in a proper cli
that I can pip install and run the command without textual run --dev app.py.
This is a fine pattern, but I also want this to work when I don’t have a file
to run.
pyproject.toml entrypoints #
I set up a new project running hatch new, and added the following entrypoint,
giving me a tutorial cli command to run.
...
[project.scripts]
tutorial = 'textual_tutorial.tui:tui'
https://waylonwalker.com/hatch-new-cli/
setup.py entrypoints #
If you are using setup.py, you can set up entrypoints in the setup command.
from setuptools import setup
setup(
...
entry_points={
"console_scripts": ["tutorial = textual_tutorial.tui:tui"],
},
...
)
https://waylonwalker.com/minimal-python-package/
tui.py #
adding features
Now to get devtools through a cli without running through textual run --dev.
I pulled open the textual cli source code, and this is what it does at the time
of writing.
Note: I used sys.argv as a way to implement a
--devquickly tutorial. For a real project, I’d setup argparse, click, or typer.typeris my go to these days, unless I am really trying to limit dependencies, then the standard libraryargparsemight be what I go with.
def tui():
from textual.features import parse_features
import os
import sys
dev = "--dev" in sys.argv # this works, but putting it behind argparse, click, or typer would be much better
features = set(parse_features(os.environ.get("TEXTUAL", "")))
if dev:
features.add("debug")
features.add("devtools")
os.environ["TEXTUAL"] = ",".join(sorted(features))
app = StopwatchApp()
app.run()
if __name__ == "__main__":
tui()
Other Flags??? #
If you look at the source, there is one other flag for headless mode.
FEATURES: Final = {"devtools", "debug", "headless"}
Run it #
Here it is running with tutorial --dev on the left, and textual console on
the right.
For far too long I have had to fidget with v4l2oloopback after reboot. I’ve had this happen on ubuntu 18.04, 22.04, and arch.
After a reboot the start virtual camera button won’t work, It appears and is clickable, but never turns on. Until I run this command.
sudo modprobe v4l2loopback video_nr=10 card_label="OBS Video Source" exclusive_caps=1
Today I learned that you can turn on kernel modules through some files in /etc/modules...
This is what I did to my arch system to get it to work right after boot.
echo "v4l2loopback" | sudo tee /etc/modules-load.d/v4l2loopback.conf
echo "options v4l2loopback video_nr=10 card_label=\"OBS Video Source\" exclusive_caps=1" | sudo tee /etc/modprobe.d/v4l2loopback.conf
