Skip to content
This repository
Browse code

Format helpful tips.

  • Loading branch information...
commit 605dc9950671076b567e95cc582ff06ebe92effd 1 parent 1c49ff8
Gabe Berke-Williams authored October 02, 2012
3  helpful-tips/osx → helpful-tips/osx.md
Source Rendered
... ...
@@ -1,2 +1,3 @@
1 1
 How do I get a copy-and-pasteable version of my Macbook's serial number?
2  
-ioreg -l | grep IOPlatformSerialNumber
  2
+
  3
+    ioreg -l | grep IOPlatformSerialNumber
0  helpful-tips/vim → helpful-tips/vim.txt
File renamed without changes
111  helpful-tips/zsh
... ...
@@ -1,111 +0,0 @@
1  
-How do I change my shell to ZSH?
2  
-chsh -s /bin/zsh
3  
-
4  
-Where can I find awesome 'zshrc's?
5  
-http://dotfiles.org/.zshrc (and check out the rest of the site too)
6  
-
7  
-Search backward through history: Ctrl-R
8  
-
9  
-Modify the most recent command: r search=replace
10  
-  i.e., $ mkdir my_dir
11  
-        $ r mkdir=cd # this runs "cd my_dir"
12  
-
13  
-Open an editor ($EDITOR) to edit the last command: fc
14  
-
15  
-Print an ASCII calendar: cal or ncal
16  
-
17  
-hashing: hash -d HASH=directory, then "cd ~HASH"
18  
-- Do not use ~ in the directory, either. Use /Users/gabe/.
19  
-- more info: http://michael-prokop.at/blog/2008/12/01/mikas-advent-calendar-day-1/
20  
-
21  
-How do I unset a function?
22  
-unfunction <function-name>
23  
-
24  
-How do I do a named hexdump, with "nul" instead of hexdump -C's "0"?
25  
-od -a (and check out `man od`)
26  
-
27  
-How do I re-initialize my PATH, so that newly-installed programs show up for autocomplete?
28  
-`export PATH=$PATH`, or as a function: function reinitialize { export
29  
-  PATH=$PATH }.
30  
-  You can also use an alias, though I'd recommend against it: `alias
31  
-  reinitialize="export PATH=$PATH". The alias will be expanded when you source
32  
-  the file with the alias, but in this case that doesn't matter since you want
33  
-  to set it to that same value anyway.  Of course, if you've modified your
34  
-  path since that source time, then the alias will remove those modifications.
35  
-  *** Long story short: go with the function. ***
36  
-
37  
-## COMPLETION
38  
-How do I make compinit (autoload compinit && compinit) find the directory where I store my completion scripts?
39  
-compinit searches the $fpath array of directories. Simply add your directory via:
40  
-  fpath=(/my/completion/directory $fpath)
41  
-
42  
-How do I complete $cmd_1 like $cmd_2?
43  
-`compdef viw=which` completes the "viw" command like "which"
44  
-
45  
-## zstyle
46  
-How do I delete all zstyle settings?
47  
-zstyle -d
48  
-For more on style: http://zsh.sourceforge.net/Doc/Release/zsh_21.html#SEC182
49  
-
50  
-## OPTIONS (setopt/unsetopt)
51  
-correct: correct commands
52  
-correctall: correct commmands AND arguments
53  
-hist_reduce_blanks: Removes meaningless whitespace in previous commands, so
54  
-  "echo 'asdf 1234'    " shows up as "echo 'asdf 1234'" when you press <UP> to
55  
-  go back in history
56  
-setopt hist_ignore_all_dups: don't store repeated commands
57  
-setopt autocd: type a directory name to cd to it, no need to type out "cd"
58  
-setopt prompt_subst: allow commands in prompt, so you can do
59  
-  PS1="%{my_function%}" and it'll work.
60  
-
61  
-## ZSH Variables
62  
-SAVEHIST: The maximum number of history events to save in the history file.
63  
-HISTSIZE: The maximum number of events stored in the internal history list. If
64  
-  you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than
65  
-  the SAVEHIST size will give you the difference as a cushion for saving
66  
-  duplicated history events. (i.e., SAVEHIST will then be the number of unique
67  
-  events to save)
68  
-
69  
-## VCS info (mostly git)
70  
-# this is helpful: http://kriener.org/articles/2009/06/04/zsh-prompt-magic
71  
-First: autoload -Uz vcs_info
72  
-# zstyle settings
73  
-# http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#SEC273
74  
-# :vcs_info:<vcs-string>:<user-context>:<repo-root-name>
75  
-# 	<vcs-string>: one of: git, svn, cvs, etc.
76  
-# 	<user-context>: a freely configurable string, assignable by the user as
77  
-# 				  	the first argument to vcs_info.
78  
-# 	<repo-root-name>: the name of a repository in which you want a style to
79  
-# 					  match.  So, if you want a setting specific to
80  
-# 					  /usr/src/zsh, with that being a cvs checkout, you can
81  
-# 					  set <repo-root-name>  to zsh to make it so.
82  
-## set formats:
83  
-# In normal formats and actionformats:
84  
-#  %s - vcs in use (git, svn, etc)
85  
-#  %b - info about current branch
86  
-#  %a -
87  
-#  %b - branchname
88  
-#  %u - unstagedstr (see below)
89  
-#  %c - stagedstr (see below)
90  
-#  %a - action (e.g. rebase-i) [only makes sense in actionformats]
91  
-#  %R - base dir of repository
92  
-#  %r - repository name. If %R is /foo/bar/repoXY, %r is repoXY.
93  
-#  %S - path in the repository. If $PWD is /foo/bar/reposXY/beer/tasty,
94  
-#     %S is "beer/tasty".
95  
-#  - you probably want %R/%S -> "~/repo/subdir"
96  
-# In branchformat:
97  
-#  %b - the branch name
98  
-#  %r - the current revision number
99  
-## colors as %F{n}: (advantage of not needing %{...%}
100  
-# 1: red (%F{1})
101  
-# 2: green
102  
-# 3: yellow
103  
-# 4: blue
104  
-# 5: purple
105  
-# 6: cyan
106  
-# 7: gray
107  
-# 8: black
108  
-# %f: reset color
109  
-
110  
-How do I enable specific VCSes?
111  
-zstyle ':vcs_info:*' enable git hg # disables all other VCSes
102  helpful-tips/zsh.md
Source Rendered
... ...
@@ -0,0 +1,102 @@
  1
+How do I change my shell to ZSH?
  2
+
  3
+    chsh -s /bin/zsh
  4
+
  5
+Where can I find awesome 'zshrc's?
  6
+
  7
+http://dotfiles.org/.zshrc (and check out the rest of the site too)
  8
+
  9
+Search backward through history: Ctrl-R
  10
+
  11
+Modify the most recent command:
  12
+
  13
+    r search=replace
  14
+    # example
  15
+    $ mkdir my_dir
  16
+    $ r mkdir=cd # this runs "cd my_dir"
  17
+
  18
+Open an editor ($EDITOR) to edit the last command:
  19
+
  20
+    fc
  21
+
  22
+Print an ASCII calendar:
  23
+
  24
+    cal # or ncal
  25
+
  26
+hashing: hash -d HASH=directory, then "cd ~HASH"
  27
+- Do not use ~ in the directory, either. Use /Users/gabe/.
  28
+- more info: http://michael-prokop.at/blog/2008/12/01/mikas-advent-calendar-day-1/
  29
+
  30
+How do I unset a function?
  31
+
  32
+    unfunction <function-name>
  33
+
  34
+How do I do a named hexdump, with "nul" instead of hexdump -C's "0"?
  35
+
  36
+    # Also: man od
  37
+    od -a
  38
+
  39
+How do I re-initialize my PATH, so that newly-installed programs show up for autocomplete?
  40
+
  41
+    export PATH=$PATH
  42
+    # as a function
  43
+    function reinitialize { export PATH=$PATH }
  44
+
  45
+
  46
+You can also use an alias, though I'd recommend against it: `alias
  47
+reinitialize="export PATH=$PATH"`. The alias will be expanded when you source
  48
+the file with the alias, but in this case that doesn't matter since you want
  49
+to set it to that same value anyway.  Of course, if you've modified your
  50
+path since that source time, then the alias will remove those modifications.
  51
+Long story short: go with the function.
  52
+
  53
+## Completion
  54
+How do I make compinit (`autoload compinit && compinit`) find the directory where I store my completion scripts?
  55
+compinit searches the $fpath array of directories. Simply add your directory via:
  56
+
  57
+    fpath=(/my/completion/directory $fpath)
  58
+
  59
+How do I complete $cmd_1 like $cmd_2?
  60
+
  61
+    # complete `g` like `git`
  62
+    compdef g=git
  63
+
  64
+## zstyle
  65
+
  66
+How do I delete all zstyle settings?
  67
+
  68
+    zstyle -d
  69
+
  70
+For more on style, see [the ZSH docs](http://zsh.sourceforge.net/Doc/Release/zsh_21.html#SEC182).
  71
+
  72
+## Options
  73
+
  74
+Use via e.g. `setopt correct` or `unsetopt correct`
  75
+
  76
+`correct`: correct commands
  77
+`correctall`: correct commmands AND arguments
  78
+`hist_reduce_blanks`: Removes meaningless whitespace in previous commands, so
  79
+  `echo 'asdf 1234'    ` shows up as `echo 'asdf 1234'` when you press <UP> to
  80
+  go back in history
  81
+`hist_ignore_all_dups`: don't store repeated commands
  82
+`autocd`: type a directory name to cd to it, no need to type out "cd"
  83
+`prompt_subst`: allow commands in prompt, so you can do
  84
+  PS1="%{my_function%}" and it'll work.
  85
+
  86
+## ZSH Variables
  87
+
  88
+`SAVEHIST`: The maximum number of history events to save in the history file.
  89
+`HISTSIZE`: The maximum number of events stored in the internal history list. If
  90
+  you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than
  91
+  the SAVEHIST size will give you the difference as a cushion for saving
  92
+  duplicated history events. (i.e., SAVEHIST will then be the number of unique
  93
+  events to save)
  94
+
  95
+## VCS info (mostly git)
  96
+
  97
+First do `autoload -Uz vcs_info`.
  98
+
  99
+Try these articles:
  100
+
  101
+* http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information
  102
+* http://kriener.org/articles/2009/06/04/zsh-prompt-magic

0 notes on commit 605dc99

Please sign in to comment.
Something went wrong with that request. Please try again.