Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 498ae58

Browse files
author
Joshua Wehner
committed
Add an installer, beefier Readme
1 parent 25ec311 commit 498ae58

File tree

2 files changed

+114
-3
lines changed

2 files changed

+114
-3
lines changed

README.md

+94-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,96 @@
1-
# Matthew's Shell Scripts
1+
# Training::Utils
22

3-
These are a series of utility scripts for Bash and ZShell from Matthew McCullough. Many are derived from prior works of open source, but some original URLs have been lost. Please point out any original art URLs and they will be added. I always strive to give credit to prior art authors.
3+
This collection of utilities originated [here](https://github.com/matthewmccullough/scripts). This gem packages the git- and training-specific scripts into an easily-installed package.
44

5-
Please fork, fix, enhance, and send pull requests.
5+
## Installation
6+
7+
If you have Ruby installed, you can install these scripts into a directory in your path by running:
8+
9+
```
10+
$ rake
11+
```
12+
13+
## Usage
14+
15+
#### `generaterandomchanges <N> <base> <extension>`
16+
17+
Generates **N** new **commits**, the content of each is a new file named "<base><I>.<extension>" with some random text.
18+
19+
```
20+
$ generaterandomchanges 3 file txt
21+
[master f377b54] A random change of 27129 to file1.txt
22+
2 files changed, 7 insertions(+), 1 deletion(-)
23+
create mode 100644 file1.txt
24+
[master fd0965c] A random change of 15808 to file2.txt
25+
1 file changed, 1 insertion(+)
26+
create mode 100644 file2.txt
27+
[master a704698] A random change of 26224 to file3.txt
28+
1 file changed, 1 insertion(+)
29+
create mode 100644 file3.txt
30+
31+
$ ls
32+
README.md file1.txt file2.txt file3.txt
33+
34+
$ git log --oneline
35+
a704698 A random change of 26224 to file3.txt
36+
fd0965c A random change of 15808 to file2.txt
37+
f377b54 A random change of 27129 to file1.txt
38+
ec9bce1 Add readme
39+
```
40+
41+
#### `generaterandomfiles <N> <base> <extension>`
42+
43+
Generates **N** new **files**, each named "<base><I>.<extension>" with some random text.
44+
45+
```
46+
$ generaterandomfiles 3 stuff txt
47+
48+
$ ls
49+
README.md stuff1.txt stuff2.txt stuff3.txt
50+
51+
$ git log --oneline
52+
ec9bce1 Add readme
53+
54+
$ cat stuff1.txt
55+
Some random text: 10660
56+
```
57+
58+
#### `git-graphlive <N optional, 10 default>`
59+
60+
Perpetually loop `git --no-pager log -<N> --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s' --abbrev-commit --date=relative`. It's like "tail -f" for `git log`. It's sometimes useful to have this on a split screen, showing the git one-line, ASCII art git graph.
61+
62+
```
63+
$ git graphlive 5
64+
* 6cad0b4 - (HEAD, master) A random change of 19964 to file30.txt
65+
* c9fd401 - A random change of 16742 to file29.txt
66+
* d5794af - A random change of 22469 to file28.txt
67+
* b2110a3 - A random change of 32088 to file27.txt
68+
* 75d01a9 - A random change of 12572 to file26.txt
69+
```
70+
71+
#### `historytailbash` and `historytailzsh`
72+
73+
Perpetually loop through `history`. It's like `tail -f` for history. Comes in `bash` and `zsh` flavors. It's sometimes useful to have this on a split screen, showing the recent history of commands.
74+
75+
#### `treelive <depth>`
76+
77+
Perpetually loop `tree`, up to `depth` folders deep in the hierarchy.
78+
79+
#### `welcome <name>`
80+
81+
Prints a welcome message:
82+
83+
```
84+
-------------------------------------------------
85+
Welcome to class on: Wed Jan 14 17:00:35 CST 2015
86+
I'm Instructor Name Here, your instructor
87+
-------------------------------------------------
88+
```
89+
90+
## Contributing
91+
92+
1. Fork it ( https://github.com/[my-github-username]/git-training-utils/fork )
93+
2. Create your feature branch (`git checkout -b my-new-feature`)
94+
3. Commit your changes (`git commit -am 'Add some feature'`)
95+
4. Push to the branch (`git push origin my-new-feature`)
96+
5. Create a new Pull Request

Rakefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'fileutils'
2+
3+
task default: :install
4+
5+
task :install do
6+
scripts = Dir['*'] - %w{LICENSE.txt Rakefile README.md}
7+
target = ENV["TARGET"] || ask_for_target_dir
8+
File.directory?(File.expand_path(target)) or abort("Install directory isn't a directory")
9+
10+
scripts.each do |f|
11+
puts " Linking #{target}/#{f}"
12+
FileUtils.symlink f, File.expand_path(target)
13+
end
14+
end
15+
16+
def ask_for_target_dir
17+
puts "Directory to install? (needs to be in your $PATH, ~/.bin is the default) "
18+
answer = STDIN.gets.chomp
19+
(answer unless answer == "") || "~/.bin"
20+
end

0 commit comments

Comments
 (0)