Skip to content

Instantly share code, notes, and snippets.

@kidpixo
Last active July 12, 2022 09:13
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 kidpixo/2c6eb090c383b649795837c74a591cc5 to your computer and use it in GitHub Desktop.
Save kidpixo/2c6eb090c383b649795837c74a591cc5 to your computer and use it in GitHub Desktop.
small bash alias to open program from CLI and send to background
#!/bin/bash
alias open='xdg-open' # opening files with xdg-open on linux, on mac you don't need this.
# open 1 file and send the proces in background
function openback() {
if [ "$#" -lt 1 ]
then echo "openback : No input given"
else open $1 > /dev/null & disown
fi
}
# open multiple files and send the proces in background
# shameless copy of [18.04 - xdg-open: Open various tab at the same time - Ask Ubuntu](https://askubuntu.com/a/1248314)
function openn() {
if [ "$#" -lt 1 ]
then
echo "You must enter 1 or more command line arguments";
elif [ "$#" -eq 1 ]; then
open "$1" > /dev/null & disown;
else
for file in "$@"; do
open "$file" > /dev/null & disown;
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment