mauvehed's dotfiles for personal and work environments
1# Enhanced Command-Line Interface (CLI) Usage
2
3This document details configurations and tools aimed at creating a powerful, consistent, and user-friendly command-line interface (CLI) experience, primarily within a Zsh environment managed by `chezmoi`.
4
5## Overview
6
7A productive CLI environment goes beyond just the shell and prompt. It involves using enhanced versions of standard utilities, organizing shell configurations logically, and leveraging tools that streamline common tasks.
8
9## Striving for Consistency (GNU Coreutils on macOS)
10
11To achieve a more GNU/Linux-like CLI experience on macOS, GNU core utilities are often installed. These provide versions of common commands (`ls`, `cp`, `mv`, `date`, `cat`, etc.) with features and options consistent with their Linux counterparts.
12
13* **Installation (macOS with Homebrew)**:
14 ```sh
15 brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt grep
16 ```
17 (You might have a more specific list in your `Brewfile`.)
18* **Usage**: These GNU versions are typically prefixed with `g` (e.g., `gls`, `gcat`, `gdate`) to avoid conflicts with the native macOS utilities.
19* **PATH Configuration**: To use these GNU versions by their standard names (e.g., `ls` instead of `gls`), you would add their directory (e.g., `$(brew --prefix coreutils)/libexec/gnubin`) to the beginning of your `$PATH`.
20 * This is often handled in a dedicated `.path` file or directly in your `.zshrc` / `.zshenv`, managed by `chezmoi`.
21
22## Shell Configuration Files
23
24To keep the main shell configuration file (e.g., `~/.zshrc`) clean and organized, specific aspects of the shell setup are often broken out into separate files, sourced by the main config. These are managed by `chezmoi`.
25
26* **`~/.path` (or similar)**: Manages the `$PATH` environment variable. It defines the order in which directories are searched for executables. Example content:
27 ```sh
28 # Example .path structure
29 export PATH="$HOME/.local/bin:$PATH"
30 export PATH="$(brew --prefix)/bin:$(brew --prefix)/sbin:$PATH" # Homebrew
31 # Add GNU coreutils if preferred
32 # export PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
33 ```
34
35* **`~/.exports` (or similar)**: Sets other essential environment variables (e.g., `EDITOR`, `LANG`, `PAGER`, custom variables for tools).
36 ```sh
37 # Example .exports
38 export EDITOR='vim'
39 export LANG='en_US.UTF-8'
40 export PAGER='less'
41 ```
42
43* **`~/.functions` (or similar)**: Defines custom shell functions to automate common tasks or create complex commands.
44 ```sh
45 # Example function in .functions
46 # mkcd() {
47 # mkdir -p "$1" && cd "$1"
48 # }
49 ```
50
51* **`~/.aliases` (or similar)**: Contains command aliases for frequently used commands or commands with common options.
52 ```sh
53 # Example .aliases
54 # alias ll='ls -alhF'
55 # alias update='sudo apt update && sudo apt upgrade -y' # Linux example
56 # alias brewup='brew update && brew upgrade && brew cleanup' # macOS example
57 ```
58
59These files are typically sourced from `~/.zshrc` in a specific order.
60
61## Essential CLI Enhancement Tools
62
63These tools replace or augment standard CLI utilities for a better experience. They are usually installed via package managers (Homebrew, apt, etc.) and managed by `chezmoi`.
64
65* **`exa`** or **`lsd`**: Modern replacements for `ls` with more colors, icons, and features.
66 * [exa](https://the.exa.website/), [lsd](https://github.com/Peltoche/lsd)
67* **`bat`**: A `cat` clone with syntax highlighting and Git integration.
68 * [bat](https://github.com/sharkdp/bat)
69* **`fd`**: A simple, fast, and user-friendly alternative to `find`.
70 * [fd](https://github.com/sharkdp/fd)
71* **`ripgrep` (`rg`)**: A line-oriented search tool that recursively searches the current directory for a regex pattern (very fast alternative to `grep`).
72 * [ripgrep](https://github.com/BurntSushi/ripgrep)
73* **`fzf`**: A command-line fuzzy finder for history, files, processes, etc. Often integrated with shell keybindings (`Ctrl+R`, `Ctrl+T`).
74 * [fzf](https://github.com/junegunn/fzf)
75* **`zoxide`**: A smarter `cd` command that learns your habits.
76 * [zoxide](https://github.com/ajeetdsouza/zoxide)
77* **`jq`**: A lightweight and flexible command-line JSON processor.
78 * [jq](https://stedolan.github.io/jq/)
79* **`yq`**: A command-line YAML, JSON, and XML processor (similar to `jq` but for more formats).
80 * [yq (Python version)](https://github.com/kislyuk/yq) or [yq (Go version)](https://github.com/mikefarah/yq)
81* **`tldr`**: Collaborative cheatsheets for console commands. Provides simplified man pages.
82 * [tldr-pages](https://tldr.sh/)
83* **`navi`** or **`cheat`**: Interactive command-line cheatsheet tools.
84 * [navi](https://github.com/denisidoro/navi), [cheat](https://github.com/cheat/cheat)
85* **`procs`**: A modern replacement for `ps` written in Rust.
86 * [procs](https://github.com/dalance/procs)
87* **`httpie`** or **`curlie`**: User-friendly CLI HTTP clients, alternatives to `curl`.
88 * [HTTPie](https://httpie.io/), [curlie](https://github.com/rs/curlie)
89
90## General Tips
91
92* **Keybindings**: Customize Zsh keybindings (often in `.zshrc` or a dedicated file) for frequently used actions or fzf integrations.
93* **Dotfiles Management**: Use `chezmoi edit <filename>` to easily edit any of these configuration files.
94
95## Resources
96
97* **GNU Coreutils**: [https://www.gnu.org/software/coreutils/](https://www.gnu.org/software/coreutils/)
98* Links to individual tools are provided in the list above.
99* **Awesome Shell**: [https://github.com/alebcay/awesome-shell](https://github.com/alebcay/awesome-shell) (A curated list of awesome command-line frameworks, toolkits, guides, and gizmos)
100* **Awesome CLI Apps**: [https://github.com/agarrharr/awesome-cli-apps](https://github.com/agarrharr/awesome-cli-apps)
101
102This setup aims to make your command-line interactions more efficient and enjoyable. Explore the tools and customize them to fit your workflow.