Skip to content

Instantly share code, notes, and snippets.

@gbirke
Created May 1, 2020 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbirke/ec7c9b2bf77f178ed3479641975242bb to your computer and use it in GitHub Desktop.
Save gbirke/ec7c9b2bf77f178ed3479641975242bb to your computer and use it in GitHub Desktop.
custom rofi menu with tab-separated text file, cut and awk
ls_home>show home> ls ~
ranger> > ranger
config_nvim>Configure NVim> vim -c "cd ~/.config/nvim" ~/.config/nvim/init.vim
# vim: set list listchars:tab=>- noexpandtab tabstop=15
~
#!/bin/bash
# Show menu
if [[ -z "$@" ]]; then
cut -f 1,2 -s --output-delimiter=% cmds.txt | column -s% -t
else
# Use selection - work in progress, might need different menus or a third column that
# decides on prefixes (x-terminal-emulator, etc)
SELECTED="${1%% *}"
CMD=$(awk -F'\t' "\$1 == \"$SELECTED\" { print \$3 }" cmds.txt)
# Open a new Terminal
if [[ ! -z "$CMD" ]]; then coproc (x-terminal-emulator -e "sh -c '$CMD'" ); fi
exit 0
fi
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment