https://github.com/farghul/redundancy
A RubyGem that deletes duplicate entries from Terminal's zsh, bash, and irb history files.
https://github.com/farghul/redundancy
gem ruby
Last synced: 5 months ago
JSON representation
A RubyGem that deletes duplicate entries from Terminal's zsh, bash, and irb history files.
- Host: GitHub
- URL: https://github.com/farghul/redundancy
- Owner: farghul
- License: unlicense
- Created: 2024-07-02T04:56:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T18:49:34.000Z (over 1 year ago)
- Last Synced: 2025-10-28T05:23:49.150Z (8 months ago)
- Topics: gem, ruby
- Language: Ruby
- Homepage:
- Size: 366 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Redundancy
[](https://badge.fury.io/rb/redundancy)
Redundancy is a RubyGem that loads the .zsh_history, .bash_history, .irb_history files, and applies the built-in Ruby ***uniq!*** function to trim any duplicate commands present. It then writes the filtered output back to the appropriate file.
## Install
Install the gem with:
```bash
gem install redundancy
```
Or add to your Gemfile:
```bash
gem "redundancy"
```
## Usage
You simply need to call the gem by name. The effects of the command execution will not be seen until you restart terminal:
```bash
redundancy
```
## Source Code
```ruby
#!/usr/bin/env ruby
$stdin.flush
$stdout.flush
$stdout.sync = true
arr = ["/.bash_history", "/.irb_history", "/.zsh_history"]
for i in arr do
l = Dir.home + i
e = File.readlines(l)
e.uniq!
f = File.open(l, "w")
e.each do |line|
f.puts(line)
end
f.close
end
```
## Apple Shortcuts
The source code works better as an Apple Shortcut, as there is a significant delay running **redundancy** when Terminal is open (several closings and reopenings).

## License
Code is distributed under [The Unlicense](https://github.com/farghul/redundancy/blob/main/LICENSE.md) and is part of the Public Domain.