├── .github └── ISSUE_TEMPLATE │ ├── custom.md │ └── bug-report.md ├── Makefile ├── README.md ├── LICENSE └── gitplug.py /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PLUGIN_DIR=$(if $(XDG_CONFIG_HOME),$(XDG_CONFIG_HOME),$(HOME)/.config)/ranger/plugins 2 | 3 | install: 4 | install -Dm644 gitplug.py $(PLUGIN_DIR)/gitplug.py 5 | 6 | uninstall: 7 | $(RM) $(PLUGIN_DIR)/gitplug.py 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | 13 | **To Reproduce** 14 | 15 | 16 | 17 | **Expected behavior** 18 | 19 | 20 | 21 | **Additional context** 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gitplug 2 | ======= 3 | ### Development will not be continued. Feel free to fork and upgrade. 4 | 5 | 6 | git plugin for ranger file manager. 7 | 8 | #### Install: 9 | ``` 10 | git clone https://github.com/yonghie/ranger-gitplug 11 | cd ranger-gitplug 12 | make install 13 | ``` 14 | 15 | #### Working command list: 16 | * ```:git init``` 17 | * ```:git status``` 18 | * ```:git clone ``` 19 | * ```:git add ``` 20 | * ```:git rm ``` 21 | * ```:git restore ``` 22 | * ```:git remote add/rm ``` 23 | * ```:git push``` 24 | * ```:git commit ``` 25 | 26 | #### TODO: 27 | - [x] ```:git push``` 28 | - [x] ```:git remote``` 29 | - [ ] tabbing 30 | - [ ] _something more i think_ 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Gabriels Kukutis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /gitplug.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | from ranger.api.commands import Command 3 | 4 | 5 | class git(Command): 6 | 7 | commands = 'init status clone add rm restore commit remote push'.split() 8 | 9 | 10 | def execute(self): 11 | # empty 12 | if not self.arg(1): 13 | return self.fm.notify("For commands check \"git help\"") 14 | 15 | # help 16 | if self.arg(1) == "help": 17 | return self.fm.notify("Not done yet!", bad=True) 18 | 19 | # init 20 | if self.arg(1) == self.commands[0]: 21 | subprocess.run(["git", "init", "--quiet"]) 22 | return self.fm.notify("Repository initialized successefully") 23 | 24 | # status 25 | if self.arg(1) == self.commands[1]: 26 | output = subprocess.check_output(["git", "status"]).decode() 27 | 28 | with open('/tmp/gitplug-status', 'w') as out: 29 | out.write(output) 30 | 31 | return self.fm.edit_file('/tmp/gitplug-status') 32 | 33 | # clone 34 | # TIP! 35 | # to clone private repositorues you have to store your data 36 | # using: "git config --global credential.helper store" in your 37 | # terminals emulator(not ranger! it will not work!) and then 38 | # do one pull still from terminals emulator and then you can 39 | # clone private repositories from ranger. 40 | if self.arg(1) == self.commands[2]: 41 | if not self.arg(2): 42 | return self.fm.notify("Missing url!", bad=True) 43 | 44 | if self.arg(2): 45 | subprocess.run(["git", "clone", self.arg(2), "--quiet"]) 46 | return self.fm.notify("Repository successfully cloned!") 47 | 48 | # add 49 | if self.arg(1) == self.commands[3]: 50 | if not self.arg(2): 51 | return self.fm.notify("Missing arguments! Usage :git add ", bad=True) 52 | 53 | if self.arg(2): 54 | subprocess.run(["git", "add", self.arg(2)]) 55 | return self.fm.notify("Successfully added files to branch!") 56 | 57 | #rm 58 | if self.arg(1) == self.commands[4]: 59 | if not self.arg(2): 60 | return self.fm.notify("Missing arguments! Usage :git rm ", bad=True) 61 | 62 | if self.arg(2): 63 | subprocess.run(["git", "rm", self.arg(2)]) 64 | return self.fm.notify("Successfully removed files from branch!") 65 | 66 | # restore 67 | if self.arg(1) == self.commands[5]: 68 | if not self.arg(2): 69 | return self.fm.notify("Missing arguments! Usage :git restore ", bad=True) 70 | 71 | if self.arg(2): 72 | subprocess.run(["git", "restore", "--staged", self.arg(2), "--quiet"]) 73 | return self.fm.notify("Successfully restored files!") 74 | 75 | # commit 76 | if self.arg(1) == self.commands[6]: 77 | if not self.rest(2): 78 | return self.fm.notify("Missing commit text", bad=True) 79 | 80 | if self.rest(2): 81 | subprocess.run(["git", "commit", "-m", self.rest(2), "--quiet"]) 82 | return self.fm.notify("Successfully commited!") 83 | 84 | # remote 85 | if self.arg(1) == self.commands[7]: 86 | if not self.arg(2): 87 | return self.fm.notify("Missing arguments! Use: git remote add/rm ", bad=True) 88 | 89 | if self.arg(2) == "add": 90 | if not self.arg(3): 91 | return self.fm.notify("Missing name and url!", bad=True) 92 | 93 | if self.arg(3): 94 | if not self.arg(4): 95 | return self.fm.notify("Missing url!", bad=True) 96 | 97 | if self.arg(4): 98 | subprocess.run(["git", "remote", "add", self.arg(3), self.arg(4)]) 99 | return self.fm.notify("Remote successfully added!") 100 | 101 | if self.arg(2) == "rm": 102 | if not self.arg(3): 103 | return self.fm.notify("Missing name!", bad=True) 104 | 105 | if self.arg(3): 106 | subprocess.run(["git", "remote", "rm", self.arg(3)]) 107 | return self.fm.notify("Remote successfully removed") 108 | 109 | # push 110 | if self.arg(1) == self.commands[8]: 111 | if self.arg(2) == "-u" and self.arg(3) and self.arg(4): 112 | subprocess.run(["git", "push", "--quiet", "-u", self.arg(3), self.arg(4)]) 113 | return self.fm.notify("Repository successfully pushed") 114 | 115 | if not self.arg(2): 116 | subprocess.run(["git", "push", "--quiet"]) 117 | return self.fm.notify("Repository successfully pushed") 118 | --------------------------------------------------------------------------------