pithy alias

Install, remove, or report the p. shell shortcut for the pithy command line.

Synopsis

pithy alias [--json]
pithy alias --remove [--json]
pithy alias --status [--json]

Flags

FlagTypeDefaultMeaning
--removebooleanfalseUninstall the alias
--statusbooleanfalseReport whether the alias is installed
--jsonbooleanfalseMachine-readable output

No flags installs. --remove and --status are mutually exclusive.

What it does

Two characters, ending in the brand mark: p. init, p. add auth, p. deploy.

It detects the shell, from $SHELL plus the platform, and resolves where its alias line belongs.

Shellrc fileAlias syntax
bash~/.bashrc, or ~/.bash_profile on macOS when it existsalias p.='pithy'
zsh~/.zshrcalias p.='pithy'
fish~/.config/fish/config.fishalias p. pithy
nushell~/.config/nushell/config.nualias p. = pithy
PowerShell~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1function p. { pithy @args }

PowerShell gets a function rather than an alias because Set-Alias rejects a . in a name. macOS bash prefers .bash_profile — the platform convention — and falls back to .bashrc only when it is absent.

It writes a delimited block, never a bare line:

# >>> pithy alias >>>
alias p.='pithy'
# <<< pithy alias <<<

Universal # comment syntax, and the markers are what --remove finds and deletes. Nothing outside them is touched.

pithy init** offers this once**, at the end of a scaffold and only to a human at a terminal — which is why most people never run this command themselves.

Idempotent. A second install detects the existing block — or a hand-added alias p.= in any form — and writes nothing.

An unrecognized shell is never guessed at. It prints the POSIX form and how to add it by hand, then exits 0. It writes to no rc file it does not recognize.

--status reads only. It answers on the marker block alone, so a hand-added alias p.= reads as not installed — the command reports what --remove could act on, not what the shell happens to define.

Two hidden flags

Handled before the command dispatch, so neither is a subcommand and neither appears in --help.

pithy --pithier is a synonym for pithy alias. It installs, with the same output.

pithy --pithiest declines:

$ pithy --pithiest
Pithy enough.

Exit 0. No alias is installed. The refusal is the point.

Neither hidden flag takes --json.

--json

One line, one object. The shape follows the path taken, and there are four. command and action lead every one of them: alias has no subcommands, so action is what tells the paths apart.

$ pithy alias --json
{"command":"alias","action":"install","installed":true,"alreadyInstalled":false,"shell":"bash","rcPath":"/home/you/.bashrc","alias":"alias p.='pithy'"}

$ pithy alias --remove --json
{"command":"alias","action":"remove","removed":true,"rcPath":"/home/you/.bashrc"}

$ pithy alias --status --json
{"command":"alias","action":"status","installed":true,"shell":"bash","rcPath":"/home/you/.bashrc"}

$ pithy alias --json
{"command":"alias","action":"install","shell":null,"manual":true,"alias":"alias p.='pithy'"}

That last one is the unknown-shell path. It used to carry no action at all — so the one case where the command exited 0 and changed nothing was the one case a consumer keying on action could not classify, and it is the case that most needs detecting.

KeyTypeMeaning
command"alias"The command that produced the line. On every payload
action"install", "remove" or "status"Which path ran. On every payload, the unknown-shell one included
installedbooleanInstall: always true — the alias is in place, whether this run put it there or found it. Status: whether the marker block is in the rc file
alreadyInstalledbooleanInstall only. true when the block, or a hand-added alias p.=, was already there and nothing was written
removedbooleanRemove only. false when there was no block to remove — not an error, and the exit is 0
shellstring or nullThe detected shell family: bash, zsh, fish, nushell, powershell. null when detection failed
rcPathstring or nullAbsolute path to the rc file the alias line belongs in
aliasstringThe alias line itself. The shell-specific syntax on the install path; the plain POSIX form on the unknown-shell path
manualtruePresent only on the unknown-shell path, and only from an install or a remove. Says the shell was not detected, nothing was written, and alias is for you to add by hand

installed and alreadyInstalled answer different questions on the install path, and both are worth reading: installed is the state afterwards, alreadyInstalled is whether this run changed anything.

Errors

Both --remove and --status. The only error this command raises. Exit 1.

$ pithy alias --remove --status
Pass either --remove or --status, not both.
Choose one.

Nothing else here fails. An undetected shell, a missing rc file, and a remove with nothing to remove are all ordinary outcomes with exit 0.

Examples

$ pithy alias
Added `alias p.='pithy'` to /home/you/.zshrc
Reload your shell or run: source /home/you/.zshrc

$ pithy alias
Already pithy.

$ pithy alias --status
Installed in /home/you/.zshrc

$ pithy alias --remove
Removed `alias p.='pithy'` from /home/you/.zshrc
Reload your shell or run: source /home/you/.zshrc

$ pithy alias --remove
No Pithy alias installed.

A shell Pithy does not know:

$ pithy alias
Couldn't detect your shell.
Add `alias p.='pithy'` to your shell config to use `p.`.
ESC