diff --git a/.gitignore b/.gitignore index 0f6eb64..aafb0df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ bin/mount_discus bin/swinglauncher bin/tabby bin/technobabylon +bin/tabbynstall diff --git a/README.md b/README.md index 4aec31a..5440085 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,23 @@ A collection of scripts and software I made to save time & mental health, op - [megafix](#megafix) - [Dependencies](#dependencies-3) - [Usage](#usage-8) - - [pathis](#pathis) + - [mp](#mp) + - [Warning \& Disclaimer](#warning--disclaimer-2) + - [Requirements](#requirements) - [Usage](#usage-9) + - [pathis](#pathis) + - [Usage](#usage-10) - [Various](#various-3) - [phantom](#phantom) - - [Usage](#usage-10) + - [Usage](#usage-11) - [Various](#various-4) - [prettyall](#prettyall) - [Dependencies](#dependencies-4) - - [Usage](#usage-11) + - [Usage](#usage-12) - [Warning](#warning-1) - [waybareload](#waybareload) - [Dependencies](#dependencies-5) - - [Usage](#usage-12) + - [Usage](#usage-13) - [Warning](#warning-2) @@ -183,6 +187,22 @@ Kills and re-run megasync with the --nogfx option to avoid thumbnails generation `megafix` +### mp +A package manager mashup that makes it easy to install stuff when you can't be bothered with multiple package managers. Avoid using 6 commands and check it all at once. + +#### Warning & Disclaimer +The script is very very primitive but it works. Remember to set up your favorite ordering and package managers before executing this program. + +For example: `mp install randompackage` will execute one by one package manager commands (apt, brew, pip...) until one of them works. Same goes for `mp remove randompackage`. + +#### Requirements + +- Set your configuration in this script: the order is followed as it is. + +#### Usage + +`mp ` + ### pathis A simple tool to add the current path to the $PATH environment variable permanently diff --git a/bin/mp b/bin/mp new file mode 100755 index 0000000..be1320c --- /dev/null +++ b/bin/mp @@ -0,0 +1,75 @@ +#!/bin/python +import os +import sys + +package_managers = [ + { + "name": "apt", + "install": "sudo apt install ", + "remove": "sudo apt remove ", + }, + { + "name": "brew", + "install": "brew install ", + "remove": "brew remove ", + }, + { + "name": "pip", + "install": "pip install ", + "remove": "pip uninstall ", + }, + { + "name": "pipx", + "install": "pipx install ", + "remove": "pipx uninstall ", + }, + { + "name": "npm", + "install": "npm install -g ", + "remove": "npm uninstall -g ", + }, + { + "name": "mist", + "install": "mist install ", + "remove": "mist remove ", + }, +] + + +def get_args(): + # We need 2 arguments + if len(sys.argv) < 3: + print("Usage: mp ") + sys.exit(-1) + + # Sanity checks + possible_operations = ["install", "remove"] + operation = sys.argv[1] + + if operation not in possible_operations: + print("Invalid operation: " + operation) + sys.exit(-1) + + package = sys.argv[2] + + return package, operation + + +def main(): + args = get_args() + package = args[0] + operation = args[1] + for manager in package_managers: + print("\n[mp] Trying with " + manager["name"]) + # trunk-ignore(bandit/B605) + if os.system(manager[operation] + package) == 0: + print("\n[mp] Installed with " + manager["name"]) + sys.exit(0) + print("Failed with " + manager["name"]) + + print("\n[mp] Failed to install " + package) + sys.exit(-2) + + +if __name__ == "__main__": + main()