No longer set complete_aliases option
[zsh.git] / .zsh / 30_Options.zsh
1 # -*- mode: sh;-*-
2
3 ## Zsh options
4 #
5 # see man zshoptions(1) for more details ;-)
6 #
7
8 function SetOPT() {
9 SetOPTifExists $1 on
10 }
11 function UnsetOPT() {
12 SetOPTifExists $1 off
13 }
14
15 function SetOPTifExists() {
16 local option=${(L)1//_/} # lowercase and no '_'
17
18 if [[ -n ${options[$option]} ]]; then
19 # option exists, set it.
20 case "$2" in
21 on)
22 debug "$fg_bold[cyan]setopt$reset_color $option"
23 setopt $option
24 ;;
25 off)
26 debug "$fg_bold[cyan]unsetopt$reset_color $option"
27 unsetopt $option
28 ;;
29 esac
30 else
31 debug "$option not supported by this version of zsh !"
32 fi
33 }
34
35 # These are the options that apply to noninteractive shells.
36 # Ones in capitals are variations from the default ZSH behaviour.
37
38 # Treat the `#', `~' and `^' characters as part of patterns for filename
39 # generation, etc. (An initial unquoted `~' always produces named
40 # directory expansion.)
41 SetOPT EXTENDED_GLOB
42
43 # Do not require a leading `.' in a filename to be matched explicitly.
44 SetOPT GLOBDOTS
45
46 # If numeric filenames are matched by a filename generation pattern,
47 # sort the filenames numerically rather than lexicographically.
48 SetOPT NUMERIC_GLOB_SORT
49
50 # Don't push multiple copies of the same directory onto the directory
51 # stack.
52 SetOPT PUSHD_IGNORE_DUPS
53
54 # Exchanges the meanings of `+' and `-' when used with a number to
55 # specify a directory in the stack.
56 SetOPT PUSHD_MINUS
57
58 # Do not print the directory stack after pushd or popd.
59 SetOPT PUSHDSILENT
60
61 # Have pushd with no arguments act like `pushd $HOME'.
62 SetOPT PUSHDTOHOME
63
64 # If a completion is performed with the cursor within a word, and a full
65 # completion is inserted, the cursor is moved to the end of the word.
66 # That is, the cursor is moved to the end of the word if either a single
67 # match is inserted or menu completion is performed.
68 SetOPT ALWAYS_TO_END
69
70 # If a command is issued that can't be executed as a normal command, and
71 # the command is the name of a directory, perform the cd command to that
72 # directory.
73 SetOPT AUTO_CD
74
75 # Any parameter that is set to the absolute name of a directory
76 # immediately becomes a name for that directory, that will be used by
77 # the `%~' and related prompt sequences, and will be available when
78 # completion is performed on a word starting with `~'. (Otherwise, the
79 # parameter must be used in the form `~param' first.)
80 SetOPT AUTO_NAME_DIRS
81
82 # Make cd push the old directory onto the directory stack.
83 SetOPT AUTO_PUSHD
84
85 # Treat single word simple commands without redirection as candidates
86 # for resumption of an existing job.
87 SetOPT AUTO_RESUME
88
89 # Expand expressions in braces which would not otherwise undergo brace
90 # expansion to a lexically ordered list of all the characters. See the
91 # section `Brace Expansion'.
92 SetOPT BRACE_CCL
93
94 # If unset, the cursor is set to the end of the word if completion is
95 # started. Otherwise it stays there and completion is done from both
96 # ends.
97 SetOPT COMPLETE_IN_WORD
98
99 # Try to correct the spelling of commands. Note that, when the
100 # HASH_LIST_ALL option is not set or when some directories in the path
101 # are not readable, this may falsely report spelling errors the first
102 # time some commands are used.
103 #
104 # The shell variable CORRECT_IGNORE may be set to a pattern to match
105 # words that will never be offered as corrections.
106 SetOPT CORRECT
107
108 # Do not enter command lines into the history list if they are
109 # duplicates of the previous event.
110 SetOPT HIST_IGNORE_DUPS
111
112 # If a new command line being added to the history list duplicates an
113 # older one, the older command is removed from the list (even if it is
114 # not the previous event).
115 SetOPT HIST_IGNORE_ALL_DUPS
116
117 # Remove the history (fc -l) command from the history list when invoked.
118 # Note that the command lingers in the internal history until the next
119 # command is entered before it vanishes, allowing you to briefly reuse
120 # or edit the line.
121 SetOPT HIST_NO_STORE
122
123 # Remove superfluous blanks from each command line being added to the
124 # history list.
125 SetOPT HIST_REDUCE_BLANKS
126
127 # This options works like APPEND_HISTORY except that new history lines
128 # are added to the $HISTFILE incrementally (as soon as they are
129 # entered), rather than waiting until the shell exits. The file will
130 # still be periodically re-written to trim it when the number of lines
131 # grows 20% beyond the value specified by $SAVEHIST (see also the
132 # HIST_SAVE_BY_COPY option).
133 SetOPT INC_APPEND_HISTORY
134
135 # When searching for history entries in the line editor, do not display
136 # duplicates of a line previously found, even if the duplicates are not
137 # contiguous.
138 SetOPT HIST_FIND_NO_DUPS
139
140 # Remove command lines from the history list when the first character on
141 # the line is a space, or when one of the expanded aliases contains a
142 # leading space. Only normal aliases (not global or suffix aliases)
143 # have this behaviour. Note that the command lingers in the internal
144 # history until the next command is entered before it vanishes, allowing
145 # you to briefly reuse or edit the line. If you want to make it vanish
146 # right away without entering another command, type a space and press
147 # return.
148 SetOPT HIST_IGNORE_SPACE
149
150 # Allow comments even in interactive shells.
151 SetOPT INTERACTIVE_COMMENTS
152
153 # List jobs in the long format by default.
154 SetOPT LONG_LIST_JOBS
155
156 # If set, parameter expansion, command substitution and arithmetic
157 # expansion are performed in prompts. Substitutions within prompts do
158 # not affect the command status.
159 SetOPT PROMPT_SUBST
160
161 # If the internal history needs to be trimmed to add the current command
162 # line, setting this option will cause the oldest history event that has
163 # a duplicate to be lost before losing a unique event from the list.
164 # You should be sure to set the value of HISTSIZE to a larger number
165 # than SAVEHIST in order to give you some room for the duplicated
166 # events, otherwise this option will behave just like
167 # HIST_IGNORE_ALL_DUPS once the history fills up with unique events.
168 SetOPT HIST_EXPIRE_DUPS_FIRST
169
170 # Try to make the completion list smaller (occupying less lines) by
171 # printing the matches in columns with different widths.
172 SetOPT LIST_PACKED
173
174 # This option both imports new commands from the history file, and also
175 # causes your typed commands to be appended to the history file (the
176 # latter is like specifying INC_APPEND_HISTORY). The history lines are
177 # also output with timestamps ala EXTENDED_HISTORY (which makes it
178 # easier to find the spot where we left off reading the file after it
179 # gets re-written).
180
181 # By default, history movement commands visit the imported lines as well
182 # as the local lines, but you can toggle this on and off with the
183 # set-local-history zle binding. It is also possible to create a zle
184 # widget that will make some commands ignore imported commands, and some
185 # include them.
186 is4 && SetOPT SHARE_HISTORY
187
188 # Save each command's beginning timestamp (in seconds since the epoch)
189 # and the duration (in seconds) to the history file.
190 SetOPT EXTENDED_HISTORY
191
192 # By default, shell history that is read in from files is split into
193 # words on all white space. This means that arguments with quoted
194 # whitespace are not correctly handled, with the consequence that
195 # references to words in history lines that have been read from a file
196 # may be inaccurate. When this option is set, words read in from a
197 # history file are divided up in a similar fashion to normal shell
198 # command line handling. Although this produces more accurately
199 # delimited words, if the size of the history file is large this can be
200 # slow. Trial and error is necessary to decide.
201 is4311 && SetOPT HIST_LEX_WORDS
202
203 # When writing out the history file, by default zsh uses ad-hoc file
204 # locking to avoid known problems with locking on some operating
205 # systems. With this option locking is done by means of the system's
206 # fcntl call, where this method is available. On recent operating
207 # systems this may provide better performance, in particular avoiding
208 # history corruption when files are stored on NFS.
209 SetOPT HIST_FCNTL_LOCK
210
211 # Allows `>' redirection to truncate existing files, and `>>' to create
212 # files. Otherwise `>!' or `>|' must be used to truncate a file, and
213 # `>>!' or `>>|' to create a file.
214 UnsetOPT CLOBBER
215
216 # If this option is set, passing the -x flag to the builtins declare,
217 # float, integer, readonly and typeset (but not local) will also set the
218 # -g flag; hence parameters exported to the environment will not be made
219 # local to the enclosing function, unless they were already or the flag
220 # +g is given explicitly. If the option is unset, exported parameters
221 # will be made local in just the same way as any other parameter.
222 UnsetOPT GLOBAL_EXPORT
223
224 # On an ambiguous completion, instead of listing possibilities or
225 # beeping, insert the first match immediately. Then when completion
226 # is requested again, remove the first match and insert the second
227 # match, etc. When there are no more matches, go back to the first one
228 # again. reverse-menu-complete may be used to loop through the list in
229 # the other direction. This option overrides AUTO_MENU.
230 UnsetOPT MENU_COMPLETE
231
232 # Beep on error in ZLE.
233 UnsetOPT BEEP
234
235 # If this option is unset, output flow control via start/stop characters
236 # (usually assigned to ^S/^Q) is disabled in the shell's editor.
237 UnsetOPT FLOW_CONTROL
238
239 # Do not exit on end-of-file. Require the use of exit or logout
240 # instead. However, ten consecutive EOFs will cause the shell to exit
241 # anyway, to avoid the shell hanging if its tty goes away.
242
243 # Also, if this option is set and the Zsh Line Editor is used, widgets
244 # implemented by shell functions can be bound to EOF (normally
245 # Control-D) without printing the normal warning message. This works
246 # only for normal widgets, not for completion widgets.
247 UnsetOPT IGNORE_EOF
248
249 # Beep on an ambiguous completion. More accurately, this forces the
250 # completion widgets to return status 1 on an ambiguous completion,
251 # which causes the shell to beep if the option BEEP is also set; this
252 # may be modified if completion is called from a user-defined widget.
253 UnsetOPT LIST_BEEP
254
255 # Remove any right prompt from display when accepting a command line.
256 # This may be useful with terminals with other cut/paste methods.
257 is41 && SetOPT TRANSIENT_RPROMPT
258
259 # Send the HUP signal to running jobs when the shell exits.
260 UnsetOPT HUP
261
262 # Run all background jobs at a lower priority.
263 UnsetOPT BG_NICE
264
265 unfunction -m SetOPT
266 unfunction -m UnsetOPT
267 unfunction -m SetOPTifExists