diff --git a/command_alias-editor-v1.0.py b/command_alias-editor-v1.0.py deleted file mode 100644 index 7d9124b..0000000 --- a/command_alias-editor-v1.0.py +++ /dev/null @@ -1,52 +0,0 @@ -import os, random - -print("[Thread/Info] Create command alias") -print("[Thread/Info] Set save directory for sh-file (press enter for default directory '~/.sh/):") -save_directory = input("~/") - -if save_directory == "": - save_directory = ".sh" - print("[Thread/Info] No directory set, proceeding with default directory: '~/.sh/'") -else: - print("[Thread/Info] Set directory to '~/" + save_directory + "'") - -print("[Thread/Info] Attempting to create new directory '~/" + save_directory + "'. Ignoring if already exists.") -os.system("mkdir ~/" + save_directory) - -print("[Thread/Info] Set the command name:") -command_alias = input("~/" + save_directory + "/") - -if command_alias == "": - command_alias = "command_alias-" + str(random.randint(100, 999)) - print("[Thread/Info] No command alias set, proceeding with: '" + command_alias + "'") -else: - print("[Thread/Info] Set command alias to '" + command_alias + "'") - -print("[Thread/Info] Creating new file '" + command_alias + ".sh' in directory '~/" + save_directory + "'") -os.system("touch ~/" + save_directory + "/" + command_alias + ".sh") - -print("touch ~/" + save_directory + "/" + command_alias + ".sh") -print("~/" + save_directory + "/" + command_alias + ".sh", "w") - -print("[Thread/Info] Formating file for shell script use.") -print("[Thread/Info] File location: " + os.path.expanduser('~') + "/" + save_directory + "/" + command_alias + ".sh") -command_alias_file = open(os.path.expanduser('~') + "/" + save_directory + "/" + command_alias + ".sh", "w") -command_alias_file.write("#! /usr/bin/sh\n") - -print("[Thread/Info] Insert new command. Press enter to proceed to next line. Press enter on blank input to exit editor.") - -command_input = input(">>") -command_alias_file.write(command_input + "\n") - -while command_input != "": - command_input = input(">>") - command_alias_file.write(command_input + "\n") - print(command_input) -command_alias_file.close() - -print("[Thread/Info] File editor closed. Applying command alias to system") -bashrc = open(os.path.expanduser('~') + "/.bashrc", "a") -bashrc.write("\nalias " + command_alias + "='~/" + save_directory + "/" + command_alias + ".sh'") -bashrc.close() -print("[Thread/Info] bashrc file editing successful.") -print("[Thread/Info] EXECUTE COMMAND 'source ~/.bashrc' OR RESTART YOUR DEVICE IN ORDER FOR THE ALIAS TO BE APPLIED!") diff --git a/command_alias-editor-v1.2.py b/command_alias-editor-v1.2.py deleted file mode 100644 index 8e7f045..0000000 --- a/command_alias-editor-v1.2.py +++ /dev/null @@ -1,52 +0,0 @@ -import os, random - -print("[Thread/Info] Create command alias") -print("[Thread/Info] Set save directory for sh-file (press enter for default directory '~/.sh/):") -save_directory = input("~/") - -if save_directory == "": - save_directory = ".sh" - print("[Thread/Info] No directory set, proceeding with default directory: '~/.sh/'") -else: - print("[Thread/Info] Set directory to '~/" + save_directory + "'") - -print("[Thread/Info] Attempting to create new directory '~/" + save_directory + "'. Ignoring if already exists.") -os.system("mkdir ~/" + save_directory) - -print("[Thread/Info] Set the command name:") -command_alias = input("~/" + save_directory + "/") - -if command_alias == "": - command_alias = "command_alias-" + str(random.randint(100, 999)) - print("[Thread/Info] No command alias set, proceeding with: '" + command_alias + "'") -else: - print("[Thread/Info] Set command alias to '" + command_alias + "'") - -print("[Thread/Info] Creating new file '" + command_alias + ".sh' in directory '~/" + save_directory + "'") -os.system("touch ~/" + save_directory + "/" + command_alias + ".sh") - -print("touch ~/" + save_directory + "/" + command_alias + ".sh") -print("~/" + save_directory + "/" + command_alias + ".sh", "w") - -print("[Thread/Info] Formating file for shell script use.") -print("[Thread/Info] File location: " + os.path.expanduser('~') + "/" + save_directory + "/" + command_alias + ".sh") -command_alias_file = open(os.path.expanduser('~') + "/" + save_directory + "/" + command_alias + ".sh", "w") -command_alias_file.write("#! /usr/bin/sh\n") - -print("[Thread/Info] Insert new command. Press enter to proceed to next line. Press enter on blank input to exit editor.") - -command_input = input(">>") -command_alias_file.write(command_input + "\n") - -while command_input != "": - command_input = input(">>") - command_alias_file.write(command_input + "\n") - print(command_input) -command_alias_file.close() - -print("[Thread/Info] File editor closed. Applying command alias to system") -bashrc = open(os.path.expanduser('~') + "/.bashrc", "a") -bashrc.write("\nalias " + command_alias + "='~/" + save_directory + "/" + command_alias + ".sh'") -bashrc.close() -print("[Thread/Info] bashrc file editing successful.") -print("[Thread/Info] EXECUTE COMMAND 'source ~/.bashrc' OR RESTART YOUR DEVICE IN ORDER FOR THE ALIAS TO BE APPLIED!") \ No newline at end of file diff --git a/command_alias_editor-v2.0.py b/command_alias_editor-v2.0.py deleted file mode 100644 index 30d8bdf..0000000 --- a/command_alias_editor-v2.0.py +++ /dev/null @@ -1,67 +0,0 @@ -VERSION = "2.0" - -def main(): - try: - from os import system, mkdir - import os.path - - # STEP ONE save directory for the Shell Script Files - print("Welcome to Bash Command Alias Editor v" + VERSION + " by Jonas_Jones") - print("\n1. Set the script directory (leave blank for default):") - save_directory = input("~/") - if save_directory == "": - save_directory = os.path.expanduser("~") + "/.sh" - else: - save_directory = os.path.expanduser("") + "/" + save_directory - print("Directory set to " + save_directory) - - try: - if not os.path.exists(save_directory): - os.mkdir(save_directory) - print("uwu") - except: - print("Something went wrong while creating the directory.") - exit() - - # STEP TWO command alias name - print("\n2. Choose the name for the command alias:") - command_alias = input(save_directory + "/") - print("Command Alias script for '" + command_alias + "' is saved at '" + save_directory + "/" + command_alias) - - # STEP THREE commands to be executed - print("\n3. Type the command(s) you wish to be executed upn running the alias. Press Enter for new lines, press enter on empty line to quit the editor.") - command = None - print(save_directory + "/" + command_alias + ".sh") - - command_alias_file = open(save_directory + "/" + command_alias + ".sh", 'w') - - command_alias_file.write("#! /usr/bin/sh\n") - - while command != "": - command = input(">> ") - command_alias_file.write(command + "\n") - command_alias_file.close() - - # STEP FOUR Apply alias to shell - print("\n4. Applying alias to the shell.") - try: - bashrc = open(os.path.expanduser('~') + "/.bashrc", "a") - bashrc.write("\nalias " + command_alias + "='" + save_directory + "/" + command_alias + ".sh'") - bashrc.close() - except: - print("ERROR: Couldn't open the bashrc file. Are you using the Bash shell? Is the file missing or requires higher permission levels?") - exit() - system("./.temp.sh") - system("chmod u+x " + save_directory + "/" + command_alias + ".sh") - system("rm .temp.sh") - print("Execute the command 'source ~/.bashrc' in the terminal to complete the final step.") - - - - except: - print("Something went wrong. Please make sure that all dependencies are installed.") - - - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/command_alias_editor-v2.0.1.py b/command_alias_editor.py similarity index 100% rename from command_alias_editor-v2.0.1.py rename to command_alias_editor.py