dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

swallow (629B)


      1 #!/bin/sh
      2 #
      3 # swallow
      4 
      5 usage() {
      6     base=$(basename "$0")
      7 
      8     cat >&2 << EOF
      9 Usage:
     10     $base "program" "arguments"
     11 EOF
     12 
     13     [ $# -eq 0 ] || exit "$1"
     14 }
     15 
     16 main() {
     17     [ -z "$*" ] && usage 1
     18 
     19     # test first argument as a command and only proceed if it exists on $PATH
     20     if type "$1" > /dev/null 2>&1; then
     21         # hide current window which is almost always where the command would be
     22         # run from
     23         PFW="$(pfw)"
     24         mapw -u "$PFW"
     25 
     26         printf '%s\n' "$*" | ${SHELL:-"/bin/sh"}
     27 
     28         # remap and refocus window command was run from
     29         mapw -m "$PFW"
     30 #        focus -w "$PFW"
     31     fi
     32 }
     33 
     34 main "$@"