Last active
July 12, 2022 09:13
-
-
Save kidpixo/2c6eb090c383b649795837c74a591cc5 to your computer and use it in GitHub Desktop.
small bash alias to open program from CLI and send to background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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