Compare commits

...

6 commits
v2.0 ... main

Author SHA1 Message Date
Jonas_Jones
8e78622a1f nbt changes 2022-09-20 16:55:09 +02:00
Jonas_Jones
17ef136165
Removed fart 2022-08-04 13:11:39 +02:00
J-onasJones
dfe12dfd97 Removed old files from main branch 2022-05-26 20:08:47 +02:00
Jonas_Jones
93388c5f36 Updated README.md
- fixed 'Windows and Linux' of 'How to use' section
2022-04-14 18:51:38 +01:00
Jonas_Jones
5313f5152a Removed unused import from main branch file 2022-04-14 18:48:43 +01:00
Jonas_Jones
cde655e791 Release of v2.0.1
- Release of v2.0.1
- Removed linux and windows executable from main branch
2022-04-14 18:46:02 +01:00
6 changed files with 2 additions and 107 deletions

3
README.md Normal file → Executable file
View file

@ -4,6 +4,7 @@ This program helps you to create and edit command aliases on Linux and MacOS (wi
# How to use
### Windows and Linux
1. Download the executable for your OS (clearly labeled) and execute it.
2. Run 'source ~/.bashrc' in the terminal
### MacOS (manually) and Windows and Linux (alternative to above)
1. Download the most recent verson of the python file
@ -16,5 +17,3 @@ This program helps you to create and edit command aliases on Linux and MacOS (wi
### Why do I have to manualy execute 'source ~/.bashrc'?
The reason that this can't be done by the program itself is that it wouldn't be applied to the main shell but only for the runtime of the program itself. After the program exits, all changes will be reverted.
This problem could technically be solved by using subprocesses but ffs I'm not in the mood for doing that. It's some work which I don't wanna do

View file

@ -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!")

View file

@ -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!")

Binary file not shown.

View file

@ -2,7 +2,7 @@ VERSION = "2.0"
def main():
try:
from os import system, mkdir
from os import system
import os.path
# STEP ONE save directory for the Shell Script Files