purplesyringa / win-sudo

Add `sudo` command to Git Bash
MIT License
183 stars 55 forks source link

install.sh : compressed cloning + automatic path (revised + working) #17

Closed DemonixCraft closed 6 years ago

DemonixCraft commented 6 years ago

I revised my previous code with various installs and I came up with a solution. Instead of installing the entire project, moving the 'sudo' files one by one to ~/bin, and then deleting the project, now all we have to do is grab all the files from the new 's' folder and clone them into ~/bin. I also added a new 'PATH' code line using the wildcard feature : PATH=$PATH:/c/Users/*/win-sudo The '*' in this line represents any folder in 'Users' with 'win-sudo' inside of it, which should be just installed. And the best part is, it can be run directly from script, meaning only 1 line of code is needed to install and setup win-sudo. For the install I excluded the .md and .gif files because they weren't necessary for installation, and also install.sh because that was already installed using the cloning command. I named the folder 's' for two reasons : 1. It is the first letter of every file that needs to be moved to ~/bin 2. It's name is unique from every file in the folder so it won't be confusing

Important Note : I have tried this .sh file when installing win-sudo and the 'git clone' command is proper syntax. It should work fine as long as there is connection to the network. The new PATH command I added also works on my machine.

Extra Changes :

Please take a look at this and any feedback would be appreciated.

purplesyringa commented 6 years ago

Hm... I can't make it work. I just checked it and git clone https://github.com/imachug/win-sudo.git/s line doesn't work.

purplesyringa commented 6 years ago

So, what about that git clone https://github.com/imachug/win-sudo.git/s ~/bin/win-sudo line that doesn't work?

DemonixCraft commented 6 years ago

You need to create the 's' folder and add all the 'sudo' .txt files to it. To do so you have to copy the code from each of them and create a new file with the same name and paste the code there, and then delete the files in the main directory.

Try downloading my install.sh file from my fork using : 'curl -s https://raw.githubusercontent.com/DemonixCraft/win-sudo/master/install.sh | sh'

DemonixCraft commented 6 years ago

Check my fork at DemonixCraft/win-sudo for reference

purplesyringa commented 6 years ago

I am getting fatal: repository 'https://github.com/DemonixCraft/win-sudo.git/s/' not found when I replace imachug with DemonixCraft everywhere.

DemonixCraft commented 6 years ago

Can you screenshot your git window with the code output?

DemonixCraft commented 6 years ago

I just changed my install.sh to grab from DemonixCraft's repo for the moment

Should work for my fork and if not the link to my repo folder might have to be altered

https://github.com/DemonixCraft/win-sudo/s is a proper link, right?

purplesyringa commented 6 years ago
#!/usr/bin/env bash
function doInstall {
    if ! [ -L ~/bin/win-sudo ] && ! [ -d ~/bin/win-sudo ]; then
        echo make dir
        mkdir ~/bin/win-sudo
    fi
    git clone https://github.com/DemonixCraft/win-sudo.git/s ~/bin/win-sudo
}
function doFail {
    echo "failed to install, sorry :'(";
    exit 1
}
doInstall || doFail
PATH=$PATH:/c/Users/*/win-sudo
echo "enjoy :)"
DemonixCraft commented 6 years ago

Sorry, I meant when you entered the 'git clone' command into your Git Bash window, you should take a screenshot of the error message. Sorry again for the misunderstanding.

purplesyringa commented 6 years ago
C:\Users\Ivanq\Documents>git clone https://github.com/DemonixCraft/win-sudo.git/s ~/bin/win-sudo
Cloning into '~/bin/win-sudo'...
remote: Not Found
fatal: repository 'https://github.com/DemonixCraft/win-sudo.git/s/' not found
purplesyringa commented 6 years ago

By the way, what is your Git version?

DemonixCraft commented 6 years ago

I'm pretty sure it's the latest version

DemonixCraft commented 6 years ago

maybe there has to be a '/' after the 's'?

DemonixCraft commented 6 years ago

I'll take a look into revisions and do some more testing. Keep this pull open until I can figure out the issue, if that's okay with you.

purplesyringa commented 6 years ago

Can you please make a screenshot of your result?

DemonixCraft commented 6 years ago

I'm actually not at my own computer right now, I'll try it on my Git in about an hour.

purplesyringa commented 6 years ago

Okay, I'll keep this PR open then.

DemonixCraft commented 6 years ago

Okay so I did some more testing and every line of code except for 'git clone' works perfectly fine. Apparently, git can only grab the entire directory with git clone, but somehow I'm managing to work around the problem. It's an unfinished one-liner that will perform the following :

  1. Clone a copy of my fork to ~/bin/win-sudo
  2. Navigate to ~/bin/win-sudo
  3. Remove the 'img' folder and it's contents, install.sh, and README.md Once done successfully it will set the path to the User's win-sudo. I can remove install.sh and README.md, but I'm still trying to work on img/screenshot.gif

Also I got the same output you did.

DemonixCraft commented 6 years ago

Okay I got the 'git clone' command to work but it's two lines and I'm still revising PATH

purplesyringa commented 6 years ago

Maybe you should try so-called sparse checkout?

DemonixCraft commented 6 years ago

I've been looking at that but idk how it works. It seems like a solution though so I'll look into it.

purplesyringa commented 6 years ago

When you manage to get it working, please tell me.