https://github.com/kilna/gnu-on
Run GNU CLI tools by default on Mac in an easily switchable way
https://github.com/kilna/gnu-on
Last synced: 8 months ago
JSON representation
Run GNU CLI tools by default on Mac in an easily switchable way
- Host: GitHub
- URL: https://github.com/kilna/gnu-on
- Owner: kilna
- License: mit
- Created: 2024-02-19T01:08:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-21T16:46:45.000Z (over 1 year ago)
- Last Synced: 2024-12-31T04:13:09.367Z (9 months ago)
- Language: Shell
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# gnu-on
Run GNU tools by default on Mac in an easily switchable way
## Features
* Makes it easy to run the most common GNU (linux-like) versions of command line
tools on the Mac by default *without* having to use Homebrew's g-prefixes
(for example `gsed` to run GNU's `sed`... you can have the same `sed` as
linux)
* Loads all tools into one directory for easy enabling/disabling in `$PATH`
* Provides a shell extension to make switching between GNU and default MacOS
CLI tools
* Also sets up symlinks so the `man` command for help works as well
* Compatibility with both `bash` and `zsh`
* Compatibility with new M-series MacOS machines## Tools Installed
MacOS tools:
* brewGNU tools:
* coreutils (many CLI utils)
* findutils (find, locate, updatedb, xargs)
* grep (egrep, fgrep)
* awk
* sed
* tar
* which## Install
This will install all of the above, and make symlinks into `/usr/local/gnu`
or `/opt/gnu` for all gnu tools, so you have one path to add.```
sh -c "$(curl -fsSL https://githubraw.com/kilna/gnu-on/main/install.sh)"
```## Usage
```
USAGE: gnu [command] [options]Options:
--verbose : Show debugging information
-vCommands:
* load : Enable shell extension
(Running 'gnu' after does not require sourcing or eval)* unload : Disable shell extension
* on : Loads the shell extension, and includes the GNU CLI tool in your
$PATH, overriding default MacOS CLI utils* off : Remove GNU from your $PATH, re-enabling MacOS CLI utils
status : Show the status of gnu shell extension and path
env : Display shell text that can enable GNU CLI utils, without
extensionbashrc : Adds 'eval "$(gnu on)"' to ~/.bashrc if it isn't there
zshrc : ^ Same for ~/.zshrchelp : Show usage
* = Command will display shell code to run if not sourced or within an eval.
If sourced, the commands will be run directly in the current shell.For usage examples see https://github.com/kilna/gnu-on
```## Examples
First, enable in your shell after install, if you haven't already:
```
$ gnu rcfile
```Fire up a new shell session (or run `eval "$(gnu on)"` yourself) and check:
```
$ gnu status
/usr/local/bin/gnu shell extension function is loaded
/usr/local/gnu/bin is not in PATH (gnu is off)
/usr/local/gnu/share/man is not in MANPATH (gnu man pages are off)
$ sort --version
sort (GNU coreutils) 9.4
...
```To disable GNU utils and return to standard MacOS CLI commands:
```
$ gnu off
/usr/local/bin/gnu shell extension function is loaded
/usr/local/gnu/bin is not in PATH (gnu is off)
/usr/local/gnu/share/man is not in MANPATH (gnu man pages are off)
$ gnu status
$ sort --version
2.3-Apple (165.80.1)
```## Manual enabling
You can optionally run the install and never use `gnu` itself; you can
enable gnu tools in your shell by adding the following to your path on an
Intel-based Mac:```
export PATH="/usr/local/gnu/bin:$PATH"
export MANPATH="/usr/local/gnu/share/man:$MANPATH"
```Or for M-series processor Macs:
```
export PATH="/opt/gnu/bin:$PATH"
export MANPATH="/opt/gnu/share/man:$MANPATH"
```## Author
Kilna, Anthony