git-tui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +20 -0
- data/README.md +78 -0
- data/VERSION +1 -0
- data/bin/git-tui-setup +97 -0
- data/lib/git-tui.rb +48 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 361705c20ef0c469d7d98b40c1e1ff64d31a68ae8481413a290bfd7de75895be
|
4
|
+
data.tar.gz: 317b5228e657913d60a4a591715555d686b8efe97b541112858c34961330ca0c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b26a598ecfceb2d0c6ec4cbf26dc00346a391d0b2d9b086289508035e2a5907c263cf2c2dd97839aac331ff8e7923fff9c49089ebbf3066a8f5fc9c7d3d47cb
|
7
|
+
data.tar.gz: a3df8dfa310d39bd42060ff4e3935c5833dc041fe761b922f2e0b57ef26b3e01d8c2fab25b0711a1565ec36835dbb63cb6886b32b0e8246a6534b5bc2086305a
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2022 Andy Maleh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Git-TUI (Git Text-based User Interface)
|
2
|
+
[](https://badge.fury.io/rb/git-tui)
|
3
|
+
|
4
|
+

|
5
|
+
|
6
|
+
Other TUI gems you may be interested in:
|
7
|
+
- [rake-tui](https://github.com/AndyObtiva/rake-tui)
|
8
|
+
- [rvm-tui](https://github.com/AndyObtiva/rvm-tui)
|
9
|
+
|
10
|
+
## Pre-requisites
|
11
|
+
|
12
|
+
- [Git](https://git-scm.com/downloads)
|
13
|
+
- [MRI Ruby](https://www.ruby-lang.org/en/) installed via [RVM](https://rvm.io)
|
14
|
+
- [Bash](https://www.gnu.org/software/bash/) or [Zsh](http://zsh.sourceforge.net/) (Z Shell) (including Sed)
|
15
|
+
|
16
|
+
## Setup Instructions
|
17
|
+
|
18
|
+
The gem can be installed unto any [Ruby](https://rvm.io/rubies/installing)/[Gemset](https://rvm.io/gemsets/basics) in [RVM](https://rvm.io) and it will be used from there everywhere.
|
19
|
+
|
20
|
+
Since it is independent of any particular [Ruby](https://www.ruby-lang.org/en/) project, it is recommended you install unto the default [gemset](https://rvm.io/gemsets/basics) (or optionally into its own gemset if you prefer). Global gemset wouldn't be enough to share it since it does not cross Rubies yet is limited to a specific Ruby version.
|
21
|
+
|
22
|
+
Afterwards, run the `git-tui-setup` command from the same [Ruby](https://rvm.io/rubies/installing)/[Gemset](https://rvm.io/gemsets/basics) you installed the gem at to setup the `git-tui` function source in `~/.bash_profile` or `~/.bashrc` (whichever is available)
|
23
|
+
|
24
|
+
These are the commands you need to run in order to select a Ruby and gemset, install gem, and finally setup gem commands globablly in the shell environment:
|
25
|
+
|
26
|
+
```
|
27
|
+
rvm use @default # or a different ruby version/gemset like `rvm use ruby-3.1.0@git-tui --create`
|
28
|
+
gem install git-tui
|
29
|
+
git-tui-setup
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Currently, only git branch checkout is supported.
|
35
|
+
|
36
|
+
Simply run this command:
|
37
|
+
|
38
|
+
```
|
39
|
+
gitui
|
40
|
+
```
|
41
|
+
|
42
|
+
Or one of the aliases:
|
43
|
+
|
44
|
+
```
|
45
|
+
git-ui
|
46
|
+
git-tui
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
- Make sure you have [RVM](https://rvm.io) installed
|
52
|
+
- Check out the latest master to make sure the feature hasn't been
|
53
|
+
implemented or the bug hasn't been fixed yet.
|
54
|
+
- Check out the issue tracker to make sure someone already hasn't
|
55
|
+
requested it and/or contributed it.
|
56
|
+
- Fork the project.
|
57
|
+
- Start a feature/bugfix branch.
|
58
|
+
- `bundle`
|
59
|
+
- Commit and push until you are happy with your contribution.
|
60
|
+
- `rake install` to test (or `rake build`, `rvm use @default`, and then `gem install pkg/git-tui-{version}.gem`)
|
61
|
+
- Please try not to mess with the Rakefile, version, or change log. If
|
62
|
+
you want to have your own version, or is otherwise necessary, that
|
63
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
64
|
+
around it.
|
65
|
+
|
66
|
+
## TODO
|
67
|
+
|
68
|
+
[TODO.md](TODO.md)
|
69
|
+
|
70
|
+
## Change Log
|
71
|
+
|
72
|
+
[CHANGELOG.md](CHANGELOG.md)
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
[MIT](LICENSE.txt)
|
77
|
+
|
78
|
+
Copyright (c) 2022 Andy Maleh
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/git-tui-setup
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2022 Andy Maleh
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
version = File.read(File.expand_path('../../VERSION', __FILE__))
|
25
|
+
puts "== git-tui-setup version #{version.strip} =="
|
26
|
+
|
27
|
+
ruby = `which ruby`
|
28
|
+
ruby = `which jruby` if ruby.to_s.strip.empty?
|
29
|
+
ruby = ruby.strip
|
30
|
+
rvm = `rvm current`.strip
|
31
|
+
command = "rvm #{rvm} do #{ruby} #{File.expand_path('../../lib/git-tui.rb', __FILE__)}"
|
32
|
+
|
33
|
+
git_tui_script = <<~SHELL_SCRIPT
|
34
|
+
function git-tui()
|
35
|
+
{
|
36
|
+
# Load RVM into a shell session *as a function*
|
37
|
+
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
38
|
+
# First try to load from a user install
|
39
|
+
source "$HOME/.rvm/scripts/rvm"
|
40
|
+
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
41
|
+
# Then try to load from a root install
|
42
|
+
source "/usr/local/rvm/scripts/rvm"
|
43
|
+
else
|
44
|
+
printf "ERROR: An RVM installation was not found.\\n"
|
45
|
+
fi
|
46
|
+
|
47
|
+
current_rvm="$(rvm current)"
|
48
|
+
current_ruby="$(echo $current_rvm | sed -E 's/@.*$//')"
|
49
|
+
current_gemset="default"
|
50
|
+
if [[ $current_rvm == *"@"* ]] ; then
|
51
|
+
current_gemset="$(echo $current_rvm | sed -E 's/^[^@]+@//')"
|
52
|
+
fi
|
53
|
+
#{command} $current_ruby $current_gemset
|
54
|
+
if [ -f "$HOME/.git_command" ] ; then
|
55
|
+
source $HOME/.git_command > /dev/null
|
56
|
+
rm $HOME/.git_command
|
57
|
+
fi
|
58
|
+
}
|
59
|
+
alias gitui=git-tui
|
60
|
+
alias git-ui=git-tui
|
61
|
+
SHELL_SCRIPT
|
62
|
+
|
63
|
+
require 'fileutils'
|
64
|
+
home_dir = `echo ~`.strip
|
65
|
+
FileUtils.mkdir_p("#{home_dir}/bin")
|
66
|
+
git_tui_script_file = "#{home_dir}/.git_tui_source"
|
67
|
+
git_tui_script_file_bash = "$HOME/.git_tui_source"
|
68
|
+
File.write(git_tui_script_file, git_tui_script)
|
69
|
+
|
70
|
+
[
|
71
|
+
['.bash_profile', '.bashrc'],
|
72
|
+
['.zprofile', '.zshrc']
|
73
|
+
].each do |profile_and_fallback|
|
74
|
+
shell_profile_file_name = profile_and_fallback.first
|
75
|
+
shell_profile_file_name = profile_and_fallback.last if !File.exist?("#{home_dir}/#{shell_profile_file_name}")
|
76
|
+
shell_profile_file = "#{home_dir}/#{shell_profile_file_name}"
|
77
|
+
FileUtils.touch(shell_profile_file)
|
78
|
+
bash_profile = File.read(shell_profile_file)
|
79
|
+
git_tui_source_statement = "source \"#{git_tui_script_file_bash}\""
|
80
|
+
unless bash_profile.split("\n").detect {|line| line.include?(git_tui_source_statement) }
|
81
|
+
File.write(shell_profile_file, "#{bash_profile}\n#{git_tui_source_statement}")
|
82
|
+
end
|
83
|
+
puts "~/#{shell_profile_file_name} has been modified to source the `git-tui` function from ~/.git_tui_source"
|
84
|
+
end
|
85
|
+
|
86
|
+
puts <<~OUTPUT
|
87
|
+
|
88
|
+
Before using `git-tui`, start a new shell session (open a new terminal tab) or run:
|
89
|
+
|
90
|
+
source ~/.git_tui_source
|
91
|
+
|
92
|
+
Afterwards, you may run `git-tui` via one of these commands (aliases):
|
93
|
+
|
94
|
+
git-tui
|
95
|
+
git-ui
|
96
|
+
gitui
|
97
|
+
OUTPUT
|
data/lib/git-tui.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (c) 2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
23
|
+
|
24
|
+
puts "== git-tui version #{File.read(File.expand_path('../../VERSION', __FILE__)).strip} =="
|
25
|
+
|
26
|
+
require 'tty-prompt'
|
27
|
+
|
28
|
+
def clean_branch_name(branch_name)
|
29
|
+
branch_name.sub('* ', '').strip
|
30
|
+
end
|
31
|
+
|
32
|
+
git_branch_names = `git branch`.split("\n")
|
33
|
+
current_branch = clean_branch_name(git_branch_names.find {|l| l.start_with?('* ')})
|
34
|
+
puts "Current Git Branch: #{current_branch}"
|
35
|
+
|
36
|
+
begin
|
37
|
+
prompt = TTY::Prompt.new
|
38
|
+
git_branch = prompt.select("Choose Git Branch: ", git_branch_names, cycle: true, per_page: 40, filter: true)
|
39
|
+
git_branch = clean_branch_name(git_branch)
|
40
|
+
|
41
|
+
command = "git checkout #{git_branch}"
|
42
|
+
|
43
|
+
File.write("#{Dir.home}/.git_command", command)
|
44
|
+
rescue TTY::Reader::InputInterrupt => e
|
45
|
+
# No Op
|
46
|
+
puts # a new line is needed
|
47
|
+
puts "Staying at current (abort detected): #{CURRENT_RVM}"
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-tui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andy_maleh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tty-prompt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.23.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.23.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.5.0
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.5.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rdoc
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.12'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: juwelier
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 2.1.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.1.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: puts_debuggerer
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rake-tui
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
description: Git-TUI (Git Text-based User Interface)
|
132
|
+
email: andy.am@gmail.com
|
133
|
+
executables:
|
134
|
+
- git-tui-setup
|
135
|
+
extensions: []
|
136
|
+
extra_rdoc_files:
|
137
|
+
- CHANGELOG.md
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
files:
|
141
|
+
- CHANGELOG.md
|
142
|
+
- LICENSE.txt
|
143
|
+
- README.md
|
144
|
+
- VERSION
|
145
|
+
- bin/git-tui-setup
|
146
|
+
- lib/git-tui.rb
|
147
|
+
homepage: http://github.com/AndyObtiva/git-tui
|
148
|
+
licenses:
|
149
|
+
- Apache-2.0
|
150
|
+
metadata: {}
|
151
|
+
post_install_message: |2+
|
152
|
+
|
153
|
+
To finish setting up the git-tui Ruby gem in your shell environment, run: git-tui-setup
|
154
|
+
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubygems_version: 3.3.3
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Git-TUI (Git Text-based User Interface)
|
173
|
+
test_files: []
|
174
|
+
...
|