• Stars
    star
    210
  • Rank 187,585 (Top 4 %)
  • Language
    Shell
  • Created almost 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SixArm.com → Z shell → zsh configuration

Z shell configuration

We use Z shell extensively, on many kinds of systems. We use Z shell configurations and conventions that can help us with compatibility, flexibility, and portability. This repo describes our configurations and conventions. This repo has our typical starter setup for Z shell aliases, functions, settings, etc. In practice this works well with other Z shell tools, such as oh-my-zsh.

zsh startup files

There are five startup files that zsh will read commands from in order:

zshenv
zprofile
zshrc
zlogin
zlogout

zsh startup files: when they load and what they do

zshenv

zshenv is sourced on all invocations of the shell, unless the -f option is set.

What goes in it:

  • Set up the command search path

  • Other important environment variables

  • Commands to set up aliases and functions that are needed for other scripts

What does NOT go in it:

  • Commands that produce output

  • Anything that assumes the shell is attached to a tty

zprofile

zprofile is sourced in login shells. It is meant as an alternative to zlogin for ksh fans; the two are not intended to be used together, although this could certainly be done if desired.

What goes in it:

  • Commands that should be executed only in login shells.

  • As a general rule, it should not change the shell environment at all.

  • As a general rule, set the terminal type then run a series of external commands e.g. fortune, msgs, etc.

What does NOT go in it:

  • Alias definitions

  • Function definitions

  • Options

  • Environment variable settings

zshrc

zshrc is sourced in interactive shells.

What goes in it:

  • Commands to set up aliases, functions, options, key bindings, for interactive use etc.

zlogin

zlogin is like zprofile, except sourced after zshrc.

zlogout

zlogout is sourced when login shells exit.

extras

Some zsh setups provide more files that are not read by zsh:

  • .zsh-update: contains a timestamp of the most recent update

  • .zshrc-e: an example file; the Z shell convention is example files end in -e.

zsh file locations

The default location for zsh system files:

/etc/zshenv
/etc/zprofile
/etc/zshrc
/etc/zlogin
/etc/zlogout

The default location for zsh user files:

$HOME/.zshenv
$HOME/.zprofile
$HOME/.zshrc
$HOME/.zlogin
$HOME/.zlogout

The custom location for zsh user files uses the environment variable ZDOTDIR:

${ZDOTDIR:-$HOME}/.zshenv
${ZDOTDIR:-$HOME}/.zprofile
${ZDOTDIR:-$HOME}/.zshrc
${ZDOTDIR:-$HOME}/.zlogin
${ZDOTDIR:-$HOME}/.zlogout

zsh directory locations

Our location for zsh system directories:

/etc/zshenv.d
/etc/zprofile.d
/etc/zshrc.d
/etc/zlogin.d
/etc/zlogout.d

Our default location for zsh user directories:

$HOME/.config/zshenv.d
$HOME/.config/zprofile.d
$HOME/.config/zshrc.d
$HOME/.config/zlogin.d
$HOME/.config/zlogout.d

Our custom location for zsh user directories uses the environment variable XDG_CONFIG_HOME:

${XDG_CONFIG_HOME:-$HOME/.config}/zshenv.d
${XDG_CONFIG_HOME:-$HOME/.config}/zprofile.d
${XDG_CONFIG_HOME:-$HOME/.config}/zshrc.d
${XDG_CONFIG_HOME:-$HOME/.config}/zlogin.d
${XDG_CONFIG_HOME:-$HOME/.config}/zlogout.d

Repo files

This repo contains our Z shell conventions for subdirectories and also our files that we like to use with multiple teams.

Notable subdirectories:

  • zshenv.d/functions is for functions.

  • zshenv.d/programs is for configuring environment programs via environment variables, such as $EDITOR, $PAGER, etc.

  • zshenv.d/settings is for Z shell settings, such as for completion, history, etc.

  • zshrc.d/aliases is for aliases, such as g for git, now for printing the current time, etc.

Conventions

Alias conventions:

  • For an alias that is a one-letter shortcut, we use a naming convention for the file: the letter, an equal sign, and the result. For example, the file g=git.zsh is the alias that sets g to run git.

  • For an alias that is intended to launch a program, we use a convention of trying probable locations for the tool. For example, for the alias firefox, we look in order in /opt (e.g. typical for our custom installs), then on the path, then in the typical macOS location.

Environment program conventions:

  • $EDITOR for editing text files, such as vi or emacs.

  • $PAGER for showing text files, such as more or less.

  • $FINDER for searching text files, such as grep or rg.

  • $CLIPPER for copying text to a clipboard, such as xclip or pbcopy.

  • $DATER for showing dates and times, such as date or gdate.

  • $JUMPER for moving among directories, such as jump or jumpdir.

Date/time format conventions:

  • We default to nanoseconds precision (not seconds precision), because we use subsecond precision on some of our systems.

  • We default to UTC timezone and the format "+00:00" (not "Z"), because this maximizes our compatibility with fintech systems and logs.

Install

Clone:

git clone https://github.com/sixarm/sixarm_zsh_config

Move the directories and files as you like, to wherever you want.

Install for one user using the way we prefer

For one user, we prefer to put files in a user's configuration directory:

config=${XDG_CONFIG_HOME:-$HOME/.config}

Make directories:

mkdir -p $config/{zshenv.d,zprofile.d,zshrc.d,zlogin.d,zlogout.d}

Copy files:

cp -R sixarm-zsh-config/zshenv.d/* $config/zshenv.d
cp -R sixarm-zsh-config/zprofile.d/* $config/zprofile.d
cp -R sixarm-zsh-config/zshrc.d/* $config/zshrc.d
cp -R sixarm-zsh-config/zlogin.d/* $config/zlogin.d
cp -R sixarm-zsh-config/zlogout.d/* $config/zlogout.d

Add this to the user file .zshenv:

config=${XDG_CONFIG_HOME:-$HOME/.config}
for file in $config/zshenv.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the user file .zprofile:

config=${XDG_CONFIG_HOME:-$HOME/.config}
for file in $config/zprofile.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the user file .zshrc:

config=${XDG_CONFIG_HOME:-$HOME/.config}
for file in $config/zshrc.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the user file .zlogin:

config=${XDG_CONFIG_HOME:-$HOME/.config}
for file in $config/zlogin.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the user file .zlogout:

config=${XDG_CONFIG_HOME:-$HOME/.config}
for file in $config/zlogout.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Install for the system using the way we prefer

For the system, we prefer to put files in the system's /etc directory:

config=/etc

Make directories:

mkdir -p $config/{zshenv.d,zprofile.d,zshrc.d,zlogin.d,zlogout.d}

Copy files:

cp -R sixarm-zsh-config/zshenv.d/* $config/zshenv.d
cp -R sixarm-zsh-config/zprofile.d/* $config/zprofile.d
cp -R sixarm-zsh-config/zshrc.d/* $config/zshrc.d
cp -R sixarm-zsh-config/zlogin.d/* $config/zlogin.d
cp -R sixarm-zsh-config/zlogout.d/* $config/zlogout.d

Add this to the system file zshenv:

config=/etc
for file in $config/zshenv.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the system file /etc/zprofile:

config=/etc
for file in $config/zprofile.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the system file zshrc:

config=/etc
for file in $config/zshrc.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the system file zlogin:

config=/etc
for file in $config/zlogin.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Add this to the sytem file zlogout:

config=/etc
for file in $config/zlogout.d/**/*(.N)
do 
    [ -x "$file" ] &&  . "$file"
done

Contribute your files

If you have zsh files that you like and that are good for many people, then send them along. We welcome additions, and also welcome pull requests.

More Repositories

1

unix-shell-script-tactics

Unix shell script tactics - best practices style guide
Shell
270
star
2

gitconfig-settings

gitconfig setttings, files, aliases, colors, branches, etc.
Shell
133
star
3

sixarm-macos-setup

SixArm.com » Mac » Setup notes for new Mac computer and macOS
Shell
58
star
4

gpg-encrypt

Use GPG to encrypt a file using our best settings
Shell
58
star
5

sixarm_unix_shell_scripts

SixArm.com » Unix » shell scripts for command line programs in sh, bash, etc.
Shell
55
star
6

usv

USV: Unicode Separated Values, the standard for data markup of units, records, groups, files
Shell
53
star
7

rust-guideposts

Rust Guideposts are for developers learning Rust, who want quick topic summaries about the Rust language, ecosystem, concepts, crates, and more.
Rust
45
star
8

assertables-rust-crate

Assertables: a Rust crate of assert macros for testing
Rust
41
star
9

tmux-conf

tmux configuration files with annotations
35
star
10

unix-shell-script-kit

Unix shell script kit with many utility functions, constant exit codes, and POSIX helpers.
Shell
25
star
11

BoldContacts

BoldContacts mobile app for people with visual/cognitive/motor disabilities
Swift
24
star
12

sixarm_mac_osx_installation_help

SixArm.com » Mac OSX installation help, notes, and guides
Shell
23
star
13

kill-palo-alto-networks-global-protect

Kill Palo Alto Networks Global Protect VPN software
Shell
20
star
14

curl-chatgpt

Curl shell script to connect to OpenAI.com ChatGPT API
Shell
16
star
15

sixarm_ruby_unaccent

SixArm.com » Ruby » Unaccent replaces a string's accented characters with ASCII characters.
Ruby
16
star
16

cargo-install-favorites

Use the `cargo` command install our favorite crates
Shell
15
star
17

pandoc-from-markdown-to-pdf

Use pandoc to convert from markdown to PDF with our preferred options
Shell
15
star
18

pitch-deck-template

SixArm® pItch deck template
14
star
19

project-management-rope-estimate

Project management ROPE™ estimate: realistic estimate, optimistic estimate, pessimistic estimate, equilibristic estimate
14
star
20

sixarm_ruby_magic_number_type

SixArm.com » Ruby » MagicNumberType infers a data type from the data's leading bytes
Ruby
13
star
21

webservers

Webservers with implementations using many languages and tools
13
star
22

urlencode.sh

URL encode: shell function and command line script
Shell
12
star
23

port-to-process

port-to-process: Given a port number, look up any associated process and pid
Shell
11
star
24

git-tools

Git scripts for version control by SixArm.com
Shell
11
star
25

macos-defaults

Mac defaults: macOS system setup configuration script via default write
Shell
11
star
26

sixarm_css_holy_grail_layout_with_flexbox

SixArm.com » CSS » Holy Grail layout with flexbox
CSS
11
star
27

project-management-priority-score

Project management priority score for ranking goals, tasks, issues, etc.
10
star
28

data-for-geolocation

Data for geolocation, countries, cities, postal codes, etc. by SixArm.com
10
star
29

sixarm_ruby_email_address_validation

SixArm.com » Ruby » Email address validation using RFC 822
Ruby
10
star
30

uri-parser

Parse a URI or URL to its scheme, host, path, query, fragment, etc.
Shell
9
star
31

venn

venn: set operations with a command line shell script
Shell
9
star
32

sixarm_brew_install

SixArm.com » Brew install scripts for our various packages
Shell
9
star
33

sixarm_ruby_gemfile

SixArm.com » Ruby » Gemfile chock full of lots of gems and descriptions
Ruby
9
star
34

apt-tools

Apt scripts for system administration
Shell
8
star
35

sqlite-import-csv

SQLite shell script to import a CSV file
Shell
8
star
36

ssh-keygen-pro

ssh-keygen-pro: generate SSH keys using professional quality conventions
Shell
8
star
37

file-size

File size script that works on many operating systems
Shell
7
star
38

change-case

Change case of text using the command line: upper-case, lower-case, title-case, camel-case, snake-case, chain-case, token-case, slug-case
Shell
7
star
39

tmux-start

Start a tmux session with windows and keys suitable for scripting
Shell
7
star
40

vboxmanage-createvm

VirtualBox VBoxManage script to create a virtual machine for Ubuntu
Shell
7
star
41

software-programming-guide

Software Programming Guide: this book explains one topic per page, like a big glossary, easy wiki, quick encyclopedia, or summary notes. Edited by Joel Parker Henderson (@joelparkerhenderson).
Makefile
7
star
42

brew-install-favorites

Use the `brew` command to install our favorite pacakages and applications for macOS
Shell
6
star
43

firefox-optimize-sqlite-vacuum

Firefox script to optimize SQLite by using vacuum to delete stale data
Shell
6
star
44

git-rename-master-branch-to-main

Use git to rename the default branch from "master" to "main"
Shell
5
star
45

chown-chmod-me

Use `chown` and `chmod` to set access control to exactly my user and primary group
Shell
5
star
46

sixarm_nagios_plugins

SixArm.com » Nagios » Plugins for monitoring servers
Shell
5
star
47

passable

passable: password manager command line tool that's just good enough
Shell
5
star
48

sixarm_unix_installation_help

SixArm.com » Unix » Installation help for servers and desktops, esp. Debian and Ubuntu
Shell
5
star
49

gpg-decrypt

Use GPG to decrypt a file using our best settings
Shell
5
star
50

git-clone-favorites

git clone our favorite repositories to our favorite paths
Shell
5
star
51

safari-reset

Reset the macOS Safari web brower via terminal command line shell script
Shell
5
star
52

hostinfo-commands

hostinfo commands for macOS
Shell
4
star
53

log-file-cleaning

Log file cleaning script that deletes old files and logrotate files
Shell
4
star
54

sixarm_bash_config

SixArm.com → Bash shell → Bash configuration files
Shell
4
star
55

sixarm_brew_scripts

SixArm.com » Brew scripts for the Homebrew OS X package manager
Shell
4
star
56

sixarm_unix_etc_files

SixArm.com » Unix » /etc » /etc system configuration files, like /etc/profile
Shell
4
star
57

brew-cask-font-sync-to-system

Command to synchronize Homebrew fonts from Caskroom to /Library/Fonts
Shell
4
star
58

ievm

Internet Explorer virtual machine download scripts for http://modern.ie
Shell
4
star
59

kill-port

kill-port: kill all processes that are attached to a given port; this is POSIX shell command
Shell
4
star
60

pmset-commands

pmset commands for power management settings for macOS
Shell
4
star
61

sixarm-company-consulting-agreement

SixArm.com → Company consulting agreement
4
star
62

compaudit-fixer

Command `compaudit-fixer` that repairs file owners and permissions on zsh scripts
Shell
4
star
63

base64-decode-gpg-decrypt

base64-decode-gpg-decrypt: Unix command to do base64 decode then gpg decrypt
Shell
4
star
64

github-api-tools-with-python

GitHub API scripts
Python
4
star
65

sixarm_ruby_zid

SixArm.com » Ruby » ZID: Zen Identifier
Ruby
4
star
66

checkline-rust-crate

checkline is a Unix command line interface (CLI) terminal user interface (TUI) that prompts you to check each line of stdin, to pick each line to output to stdout
Rust
4
star
67

sixarm_git_ignore

SixArm.com » git » gitignore configuration files
3
star
68

urldecode.sh

URL decode: shell function and command line script
Shell
3
star
69

markline

markable line picker for stdin line input
Rust
3
star
70

sixarm_shell_random_scripts

SixArm.com → Shell → Random scripts to generate text
Shell
3
star
71

sixarm_rust_standard_echo_server

SixArm.com → Rust → standard → echo server
Rust
3
star
72

sixarm_aws_cli

Amazon Web Service (AWS) Command Line Interface (CLI) examples
Shell
3
star
73

sixarm_schema_org

SixArm » Schema.org Utilties
Ruby
3
star
74

mast-cell-help

Mast cell help: a guide book glossary about mast cell activation syndrome (MCAS) symptoms, diagnosis, treatments, and healthcare.
Svelte
3
star
75

sixarm-company-confidentiality-agreement

SixArm.com → Company confidentiality agreement (CA) a.k.a. non-disclosure agreement (NDA)
3
star
76

getoptsy

getoptsy: getopts alternative to parse command line arguments to long options, in POSIX, using custom code.
Shell
3
star
77

sixarm-virtualbox-scripts

SixArm VirtualBox scripts
Shell
3
star
78

data-mock-helpers

Data mock helpers for generating samples
3
star
79

sixarm_ssh_scripts

SixArm.com » SSH » Scripts for secure shell keys, hosts, fingerprints, etc.
Shell
3
star
80

openssl-encrypt

OpenSSL encrypt: use openssl to encrypt a file using our best symmetric settings
Shell
3
star
81

rm-rotated-files

Remove rotated log files: files that are compressed, or numbered, or datestamped, e.g. syslog.1, history.gz, etc.
Shell
3
star
82

sixarm_git_dot_files

SixArm.com → git → dot files for configuration
3
star
83

markdown-tools

SixArm.com » Markdown » Scripts for parsing markdown
Ruby
3
star
84

markdown-toc-generator

Markdown Table Of Contents generator script
Ruby
3
star
85

sixarm_postfix_checks

SixArm.com » Postfix » Checks for spam blocking
3
star
86

sixarm_ruby_markdown_table_of_contents

SixArm.com → Ruby → Markdown table of contents generator
Ruby
3
star
87

sixarm_ruby_rbac

SixArm.com » Ruby » RBAC: Role Based Access Control for users, roles, permissions, etc.
Ruby
3
star
88

rsvg-convert-svg-to-apple-xcode-icon-pixel-sizes

Use `rsvg` command to convert from a SVG image to Apple Xcode icon pixel sizes as PNG files
Shell
3
star
89

apt-install-favorites

Use the `apt-get` command to install our favorite packages for Debian, Ubuntu, Mint, etc.
Shell
3
star
90

unix-system-version-information

Unix system version information
Shell
3
star
91

html-span-data-chatgpt-prompt

HTML span data-chatgpt-prompt autocomplete via Python and OpenAI.com ChatGPT API
Python
2
star
92

boldcontacts-site-as-svelte

BoldContacts site implemented as SvelteKit
Svelte
2
star
93

sixarm_rust_actix_epoch

SixArm.com → Rust → Actix → Epoch → Show Unix epoch timestamp
Rust
2
star
94

git-mv-file-name-from-underscore-to-dash

git-mv-file-name-from-underscore-to-dash command to rename a file from "_" to "-"
Shell
2
star
95

postgresql-brew-macos-help

PostgreSQL brew macOS help
2
star
96

read-lines-into-rust-crate

file_into_string Rust crate to read lines of a text file into a string or vector of strings
Rust
2
star
97

sixarm_unicode_emoji

SixArm.com Unicode Emoji Examples
2
star
98

swagger-starter

Swagger Starter Kit for sharing API specifications
JavaScript
2
star
99

wipe-free-disk-space

wipe-free-disk-space: Unix command to secure erase all extra bytes on a drive
Shell
2
star
100

yaml-to-json

yaml-to-json: Unix command to convert YAML text to JSON text
Ruby
2
star