Here is the script, which is a hack that I use with i3wm, I already converted most of it to a single line and it still works:

#!/usr/bin/env bash

is-leaf-node() { i3-msg -t get_tree | jq 'recurse(.nodes[]?, .floating_nodes[]?) | select(.type == "con" or .type == "floating_con") | select(.focused == true) | .nodes == []';}; parent-type() { i3-msg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.nodes[]?.focused == true) | .type' ;}; if [ "$(is-leaf-node)" == "true" ]; then i3-msg focus parent, focus parent; else i3-msg focus child, focus child; fi

Here is where I’m stuck:

The script needs the #!/usr/bin/env bash to work, it is the only script that I have that needs it.

Changing it to #!/usr/bin/env bash; <SCRIPT> does not work, it has have a second line for it to work.

  • misophist@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    Save it in a file called “myprog.sh”, then the one line would be ./myprog.sh (you can replace . With the full file path to make it more robust).