// ZSH-OPENSHIFT-ALIASES — ENGINEERING REPORT

Single-file zsh plugin · 52 oc aliases · ocdev / ocqa login macros · ologin = oc rsh · auto-sourced oc completion · type -ap oc load guard

>_EXECUTIVE SUMMARY

zsh-openshift-aliases is a single-file zsh plugin that registers 52 short aliases over the OpenShift oc CLI, 5 helper functions for replica-stepping and pod lookup, and three login/session shortcuts (ocdev, ocqa, ologin). On source it guards with type -ap -- oc: if no oc executable is on PATH it returns immediately and defines nothing. When oc is present and __start_oc is not already defined it runs source <(oc completion zsh) to wire up native oc tab-completion. The login macros are env-templated — ocdev expands to oc login ${OCP_DEV_URL} -u ${OCP_USERNAME}. Source: 118 zsh lines in one .plugin.zsh file. Pinned by 15 @test blocks across 3 zunit files (230 lines).

52
oc Aliases
5
Helper Functions
118
Zsh Lines (plugin entry)
15
@test Blocks (zunit)
3
Test Files
230
Test Lines
3
Login / Session Macros
1
Load Guard (type -ap oc)

~ARCHITECTURE

One entry file. No autoload tree, no completions/ directory — completion is delegated to oc's own generator. The file is a flat sequence of guard → completion-source → env-var init → alias declarations → fn(){ } definitions.

File / GroupLinesRole
zsh-openshift-aliases.plugin.zsh 118 The whole plugin. Sole entry point.
 · load guard 3 type -ap -- oc — insists on a real executable on PATH (not a shell function); return 1 if absent, so the plugin no-ops when oc is not installed.
 · completion source 3 If __start_oc is not already defined, source <(oc completion zsh) to register oc tab-completion once.
 · env init + login macros 6 Initializes OCP_USERNAME / OCP_DEV_URL / OCP_QA_URL to empty; declares ocdev / ocqa (env-templated oc login) and ologin (oc rsh).
 · alias declarations 52 total 52 alias lines grouped by intent: get (og, opod, …), describe/deploy/logs (odesc, odep, olog, …), delete (odel, odeldc, …), export (oexp, opexp, …), scale (oscaled, ostopd, …), pod hygiene (opclean, opodr, opodt, obackup).
 · helper functions 5 fns pod (jsonpath name of a running pod by selector), oincs / oincd (step a statefulset / dc replicas up by 1), odecs / odecd (step down by 1). Each reads the current count via oc get ... -o jsonpath='{.spec.replicas}' then re-scales.
Total source 118 1 entry file · 52 aliases + 5 functions · pure zsh

Note: 15 of the 52 aliases wrap an inline _(){ … ;};_ positional-argument shim (e.g. opodo, oscaled, the *exp family) so they can take $1 / $@ — zsh aliases cannot otherwise consume positional arguments mid-command.


$ALIAS CONTRACT

Every alias is a thin expansion to an oc invocation. The table is the exact expansion grouped by family. No wrapper logic beyond the inline positional shims.

FamilyAliasesExpansion shape
Login / sessionocdev ocqa ologinoc login ${OCP_DEV_URL} -u ${OCP_USERNAME} / ... ${OCP_QA_URL} ... / oc rsh
Getog odc osts ohpa opod osvc opvc ois obc oall oalln opodo opd oimg olcp olpoc get [KIND] [-o wide | -o jsonpath=... | -l app=...]
Describe / deploy / logs / copyodesc odhist odep oroll orhist olog osync ocp ovoloc describe / oc apply -f / oc rollout {latest,history} dc / oc logs -f / oc rsync / oc cp / oc volume dc --all
Deleteodel odelo odela odeldc odelsts odelpod odelsvc odelbc odelpvcoc delete [KIND] [-l app=...]
Export YAMLoexp opexp odexp osexp ocexp ovexpoc get [KIND] $1 -o yaml --export
Scaleoscaled oscales ostopd ostartd ostarts ostopsoc scale --replicas=N {dc|statefulsets}
Pod hygiene / backupopclean opodr opodt obackupforce-delete Terminating pods / jsonpath phase filters / per-object-type YAML dump

=ENVIRONMENT

Three variables drive the login macros. The plugin sets all three to the empty string on source (lines 11–13), so values must be exported after the plugin loads.

VariableDefaultEffect
OCP_USERNAME(empty)Username passed to oc login -u by both ocdev and ocqa.
OCP_DEV_URL(empty)Cluster API URL ocdev logs into.
OCP_QA_URL(empty)Cluster API URL ocqa logs into.

#TEST COVERAGE

15 @test blocks across 3 zunit files (230 lines). The alias suite stages a fake oc executable on a tmpdir-prefixed PATH so the type -ap -- oc guard passes, then sources the plugin and asserts alias presence and expansion shape. The CI suite runs them under zunit — no live OpenShift cluster required.

FileTestsPins
t-aliases.zsh10Sourcing registers >40 o* aliases; ocdev / ocqa reference OCP_*_URL + OCP_USERNAME + oc login; ologin is oc rsh; odel is oc delete (catches name-vs-action drift); odc / obc are oc get ... -o wide; ocexp passes --export; graceful degradation when oc is missing (shell stays alive); re-source idempotency (same alias count).
t-contract.zsh3Entrypoint stem matches plugin dir basename (accepting the zsh- prefix variant); entrypoint parses under zsh -n; every _* completion file (if any) starts with #compdef.
t-syntax.zsh2zsh -n over every *.zsh in the plugin directory.
Total153 zunit files · alias-surface + install-contract + syntax

!DESIGN DECISIONS

No-op when oc is absent

The type -ap -- oc guard insists on a real executable on PATH — not a shell function or alias — and return 1s if missing. This lets the plugin be loaded unconditionally in a plugin manager array without a per-host command -v oc wrapper in .zshrc.

Delegate completion to oc

Rather than ship a hand-written _oc compdef, the plugin runs source <(oc completion zsh) — the completion is whatever oc's own generator emits, so it never drifts from the installed oc version. Guarded on __start_oc not already existing to avoid double-sourcing.

Env-templated login macros

ocdev / ocqa are single-quoted aliases that expand ${OCP_DEV_URL} / ${OCP_QA_URL} / ${OCP_USERNAME} at call time, not source time. Change the env vars between invocations and the next ocdev targets the new cluster — no re-source needed.

Inline _(){ } positional shims

Zsh aliases cannot consume positional args mid-command. 15 aliases wrap an inline anonymous-ish _(){ oc ... $1 ... ;};_ function so opodo myapp / oscaled 3 web / ocexp myconfig place the argument where oc needs it instead of appending it at the end.

-o wide on tabular gets

The pod / svc / pvc / dc / sts / is / bc getters default to -o wide so the node, IP, and selector columns oc hides in its narrow default are always shown. One fewer flag to type for the common case.

Replica stepping as functions

oincd / oincs / odecd / odecs need to read the current .spec.replicas before scaling — that round-trip can't be expressed as a static alias, so they are real functions. pod is a function for the same reason: it composes a jsonpath query from a label selector argument.


@FOOTPRINT