-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some improvement #2
Open
workalitkp
wants to merge
2
commits into
aarmn:master
Choose a base branch
from
workalitkp:some-improvement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,19 @@ def angryinput(text="",list=None,func=None): | |
continue | ||
return tt | ||
|
||
|
||
def ResetBash(): | ||
print("\n So Run: source ~/.bashrc \n") | ||
sleep(4) | ||
|
||
def DetectShell(): | ||
Shell = os.popen('echo $SHELL').read() | ||
if('zsh' in Shell): | ||
return '.zshrc' | ||
return '.bashrc' | ||
|
||
def ResetShell(): | ||
if(DetectShell() == '.bashrc'): | ||
print("\n So Run: source ~/.bashrc \n") | ||
sleep(4) | ||
elif(DetectShell() == '.zshrc'): | ||
print("\n So Run: source ~/.zshrc \n") | ||
sleep(4) | ||
AsciiArt=r''' | ||
___ ___ | ||
/ \ / \ | ||
|
@@ -288,35 +296,40 @@ def ResetBash(): | |
#####AA Zone##### | ||
''' | ||
|
||
|
||
|
||
print(back+cyan+AsciiArt) | ||
print("A Tiny Script By AARMN The Limitless To Ease Bash With Some Funcs And Aliases\n") | ||
|
||
if (platform.system()!="Linux"): | ||
print("Installer Work Only On Gnu\Linux OS , If You Have Bash Installed In Your OS, Copy Script Var From Source to Your .bashrc File In Home Folder Of Your OS") | ||
exit() | ||
|
||
bash=str(subprocess.check_output(["bash","--version"])).find("GNU bash") | ||
if (bash==-1): | ||
print("There Is No Bash In Your System PATH , Try to Install Or Reinstall It") | ||
exit() | ||
|
||
if(DetectShell() == '.bashrc'): | ||
bash=str(subprocess.check_output(["bash","--version"])).find("GNU bash") | ||
if (bash==-1): | ||
print("There Is No Bash In Your System PATH , Try to Install Or Reinstall It") | ||
exit() | ||
else: | ||
zsh=str(subprocess.check_output(["zsh","--version"])).find("zsh") | ||
if (zsh==-1): | ||
print("your default shell is zsh but There Is No zsh In Your System PATH , Try to Install Or Reinstall It") | ||
exit() | ||
Home=os.path.expanduser("~") | ||
|
||
try: | ||
Bashrc=open(os.path.join(Home,".bashrc"),"r") | ||
Shell=open(os.path.join(Home,DetectShell()),"r") | ||
except IOError: | ||
ans3=yesno(angryinput("You Don't Have A Bashrc, Can I Create One? (Yes/No)",func=yesno)) | ||
if(DetectShell() == '.bashrc'): | ||
ans3=yesno(angryinput("You Don't Have A .bashrc, Can I Create One? (Yes/No)",func=yesno)) | ||
elif(DetectShell() == '.zshrc'): | ||
ans3=yesno(angryinput("You Don't Have A .zshrc, Can I Create One? (Yes/No)",func=yesno)) | ||
if not (ans3): | ||
exit() | ||
Bashrc=open(os.path.join(Home,".bashrc"),"w+") | ||
Bashrc.close() | ||
Shell=open(os.path.join(Home,DetectShell()),"w+") | ||
Shell.close() | ||
|
||
Bashrc=open(os.path.join(Home,".bashrc"),"r") | ||
Shell=open(os.path.join(Home,DetectShell()),"r") | ||
ans=None | ||
BashrcString=Bashrc.read() | ||
Bashrc.close() | ||
BashrcString=Shell.read() | ||
Shell.close() | ||
StartScript=BashrcString.find('#####AA Zone#####\n') | ||
EndScript=BashrcString.find('#####AA Zone#####\n',StartScript+1) | ||
WithoutScript=BashrcString[0:StartScript]+BashrcString[EndScript+17:-1] | ||
|
@@ -325,20 +338,39 @@ def ResetBash(): | |
|
||
def InstallScript(): | ||
try: | ||
Bashrc=open(os.path.join(Home,".bashrc"),"a") | ||
Shell=open(os.path.join(Home,DetectShell()),"a") | ||
except IOError: | ||
print("I Think Bashrc Is Write Protect, Fix It And Run Code Again") | ||
print("I Think Shell Is Write Protect, Fix It And Run Code Again") | ||
exit() | ||
Bashrc.write(Script) | ||
Bashrc.close() | ||
Shell.write(Script) | ||
Shell.close() | ||
|
||
def InstallExtra(): | ||
print(letsinstall) | ||
if(DetectShell() == '.bashrc'): | ||
print(omb) | ||
print(iowt) | ||
OptionList = ['0','1'] | ||
elif(DetectShell() == '.zshrc'): | ||
print(omz) | ||
print(iowt) | ||
OptionList = ['0','1'] | ||
ExtraTools = int(angryinput(list=OptionList)) | ||
if(DetectShell() == '.bashrc'): | ||
if(ExtraTools == 1): | ||
os.system('sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"') | ||
elif(DetectShell() == '.zshrc'): | ||
if(ExtraTools == 1): | ||
os.system('sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"') | ||
|
||
def UninstallScript(): | ||
try: | ||
Bashrc=open(os.path.join(Home,".bashrc"),"w") | ||
Shell=open(os.path.join(Home,DetectShell()),"w") | ||
except IOError: | ||
print("I Think Bashrc Is Write Protect, Fix It And Run Code Again") | ||
print("I Think Shell Is Write Protect, Fix It And Run Code Again") | ||
exit() | ||
Bashrc.write(WithoutScript) | ||
Bashrc.close() | ||
Shell.write(WithoutScript) | ||
Shell.close() | ||
def FindVer(start,scriptstr): | ||
endline="\n" | ||
ListTmpVer=list() | ||
|
@@ -347,18 +379,19 @@ def FindVer(start,scriptstr): | |
ListTmpVer.append(scriptstr[step]) | ||
step+=1 | ||
return int(''.join(ListTmpVer)) | ||
Bashrc=open(os.path.join(Home,".bashrc"),"r") | ||
for line in Bashrc: | ||
|
||
Shell=open(os.path.join(Home,DetectShell()),"r") | ||
for line in Shell: | ||
if (line=="#####AA Zone#####\n"): | ||
TagCount+=1 | ||
Bashrc.close() | ||
Shell.close() | ||
|
||
nonew="This Script Don't Have A New Version Of AA" | ||
installthem="To Upgrade Bash to Next Level We Suggest You to Install More Fancy Stuff too \nDo You Want to Install:" | ||
bashit="1.Bashit" | ||
omb="2.Oh My Bash" | ||
iowt="3.None Of Them, AA is Enough" | ||
omb="1.Oh My Bash" | ||
bashit="2.Bashit" | ||
omz = "1.Oh My Zsh" | ||
iowt="0.None Of Them, AA is Enough" | ||
donesad="Done :(" | ||
donehappy="Done :)" | ||
wisechoice="Wise Choice :)" | ||
|
@@ -367,28 +400,29 @@ def FindVer(start,scriptstr): | |
cancelit3="3.Cancel" | ||
cancelit2="2.Cancel" | ||
uninstallit="1.Uninstall AA" | ||
newincompatver="Your Version Is Newer And Backward Incompatible Or You Have A Corrupt Version of AA In Your Bashrc,In This Situation Try Delete It Manually And Have A New Installed" | ||
newincompatver="Your Version Is Newer And Backward Incompatible Or You Have A Corrupt Version of AA In Your Shell,In This Situation Try Delete It Manually And Have A New Installed" | ||
upgradeit="2.Down/Up-grade AA" | ||
otherver="If You Want to Upgrade Or Find It Useless, This Script Contain a diffrent ver" | ||
olderver="But It's Older :(" | ||
newerver="Good News, It's New :)" | ||
resetshell="To Effect Changes You Need To Run A New Bash Or Source Bashrc, Do You Want To Source Bashrc? (If You Are Already Running This In Bash Its Recommended) (Yes/No) : " | ||
resetshell="To Effect Changes You Need To Run A New Bash Or Source Shell, Do You Want To Source Shell? (If You Are Already Running This In Bash Its Recommended) (Yes/No) : " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a new bash or source shell XD? lets go with "a new shell or source your shell dotfile", same next line |
||
|
||
if (TagCount==0): | ||
ans=yesno(angryinput(letsinstall,func=yesno)) | ||
if (ans): | ||
InstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
InstallExtra() | ||
print(donehappy) | ||
elif (TagCount==1): | ||
ans=yesno(angryinput(pbbutinstalled,func=yesno)) | ||
if (ans): | ||
InstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
print(donehappy) | ||
elif (TagCount==2): | ||
if (('\n'+InstalledScript+'\n')==Script): | ||
|
@@ -401,7 +435,7 @@ def FindVer(start,scriptstr): | |
UninstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
print(donesad) | ||
else: | ||
print(wisechoice) | ||
|
@@ -424,22 +458,22 @@ def FindVer(start,scriptstr): | |
UninstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
print(donesad) | ||
if (ans2==2): | ||
UninstallScript() | ||
InstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
print(donehappy) | ||
else: | ||
ans=yesno(angryinput(pbbutinstalled,func=yesno)) | ||
if (ans): | ||
InstallScript() | ||
ansreset=yesno(angryinput(resetshell,func=yesno)) | ||
if (ansreset): | ||
ResetBash() | ||
ResetShell() | ||
print(donehappy) | ||
|
||
print(end + "\033[2J" + "\033[1;1H") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run this again, is better than run code