Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (95 sloc) 4.22 KB
How do I change my shell to ZSH?
chsh -s /bin/zsh
Where can I find awesome 'zshrc's?
http://dotfiles.org/.zshrc (and check out the rest of the site too)
Search backward through history: Ctrl-R
Modify the most recent command: r search=replace
i.e., $ mkdir my_dir
$ r mkdir=cd # this runs "cd my_dir"
Open an editor ($EDITOR) to edit the last command: fc
Print an ASCII calendar: cal or ncal
hashing: hash -d HASH=directory, then "cd ~HASH"
- Do not use ~ in the directory, either. Use /Users/gabe/.
- more info: http://michael-prokop.at/blog/2008/12/01/mikas-advent-calendar-day-1/
How do I unset a function?
unfunction <function-name>
How do I do a named hexdump, with "nul" instead of hexdump -C's "0"?
od -a (and check out `man od`)
How do I re-initialize my PATH, so that newly-installed programs show up for autocomplete?
`export PATH=$PATH`, or as a function: function reinitialize { export
PATH=$PATH }.
You can also use an alias, though I'd recommend against it: `alias
reinitialize="export PATH=$PATH". The alias will be expanded when you source
the file with the alias, but in this case that doesn't matter since you want
to set it to that same value anyway. Of course, if you've modified your
path since that source time, then the alias will remove those modifications.
*** Long story short: go with the function. ***
## COMPLETION
How do I make compinit (autoload compinit && compinit) find the directory where I store my completion scripts?
compinit searches the $fpath array of directories. Simply add your directory via:
fpath=(/my/completion/directory $fpath)
How do I complete $cmd_1 like $cmd_2?
`compdef viw=which` completes the "viw" command like "which"
## zstyle
How do I delete all zstyle settings?
zstyle -d
For more on style: http://zsh.sourceforge.net/Doc/Release/zsh_21.html#SEC182
## OPTIONS (setopt/unsetopt)
correct: correct commands
correctall: correct commmands AND arguments
hist_reduce_blanks: Removes meaningless whitespace in previous commands, so
"echo 'asdf 1234' " shows up as "echo 'asdf 1234'" when you press <UP> to
go back in history
setopt hist_ignore_all_dups: don't store repeated commands
setopt autocd: type a directory name to cd to it, no need to type out "cd"
setopt prompt_subst: allow commands in prompt, so you can do
PS1="%{my_function%}" and it'll work.
## ZSH Variables
SAVEHIST: The maximum number of history events to save in the history file.
HISTSIZE: The maximum number of events stored in the internal history list. If
you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than
the SAVEHIST size will give you the difference as a cushion for saving
duplicated history events. (i.e., SAVEHIST will then be the number of unique
events to save)
## VCS info (mostly git)
# this is helpful: http://kriener.org/articles/2009/06/04/zsh-prompt-magic
First: autoload -Uz vcs_info
# zstyle settings
# http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#SEC273
# :vcs_info:<vcs-string>:<user-context>:<repo-root-name>
# <vcs-string>: one of: git, svn, cvs, etc.
# <user-context>: a freely configurable string, assignable by the user as
# the first argument to vcs_info.
# <repo-root-name>: the name of a repository in which you want a style to
# match. So, if you want a setting specific to
# /usr/src/zsh, with that being a cvs checkout, you can
# set <repo-root-name> to zsh to make it so.
## set formats:
# In normal formats and actionformats:
# %s - vcs in use (git, svn, etc)
# %b - info about current branch
# %a -
# %b - branchname
# %u - unstagedstr (see below)
# %c - stagedstr (see below)
# %a - action (e.g. rebase-i) [only makes sense in actionformats]
# %R - base dir of repository
# %r - repository name. If %R is /foo/bar/repoXY, %r is repoXY.
# %S - path in the repository. If $PWD is /foo/bar/reposXY/beer/tasty,
# %S is "beer/tasty".
# - you probably want %R/%S -> "~/repo/subdir"
# In branchformat:
# %b - the branch name
# %r - the current revision number
## colors as %F{n}: (advantage of not needing %{...%}
# 1: red (%F{1})
# 2: green
# 3: yellow
# 4: blue
# 5: purple
# 6: cyan
# 7: gray
# 8: black
# %f: reset color
How do I enable specific VCSes?
zstyle ':vcs_info:*' enable git hg # disables all other VCSes
Something went wrong with that request. Please try again.