LukeSmithxyz / LARBS

Luke's Auto-Rice Bootstrapping Scripts: Installation Scripts for My Arch Linux Meta-Distribution
GNU General Public License v3.0
2.06k stars 800 forks source link

Can't create a shortcut for lfcd #502

Closed janluijk closed 1 year ago

janluijk commented 1 year ago

I want to have a shortcut for lfcd as I use it often, so instead of opening the terminal and then using ^o, I want a direct shortcut

I tried to change the keybind Mod+r in ~/.local/src/dwm from TERMINAL, "lf", NULL to TERMINAL, "lfcd", NULL, but this didn't work. A terminal opens and instantly closes. I then tried making a script named lfcd in ~/.local/bin with:

trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
    dir="$(cat "$tmp")"
    [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi

This still didn't work. I have very little experience and have no idea how to get this working. Any suggestions?

LukeSmithxyz commented 1 year ago

As it is, lfcd is a zsh function defined in the zshrc, not an independent script.

If you create an executable file lfcd somewhere in your $PATH, it can be run from dwm, like you want.