Hot answers tagged

5

The standard way to define directory abbreviations for the prompt is to use named directories. Named directories are used when expanding the %~ prompt escape sequence, generalizing ~ to abbreviate your home directory and ~bob to abbreviate Bob's home directory. mu3 [~]: cd /Users/mu3/Development/Web/test mu3 [~/Development/Web/test]: hash -d test=$PWD mu3 ...


4

Try: for f in *; do if [ -f "$f" ] && [ "$(tail -n1 -- "$f")" != "hello world" ]; then printf '%s\n' "$f" fi done


4

% PS1='%% ' exec zsh -f % autoload -U compinit && compinit % setopt GLOB_COMPLETE % touch aa ab ac ad % vim a* Will cycle through the options; and then for a menu (on, like, everything) % zstyle ':completion*:default' menu 'select=0' % vim a* For more information see zshoptions(1) and the "From Bash to Z Shell" book for slightly readable docs on ...


4

That is because you are trying to use the GNU find, which is default in Linux, but Mac OS X comes with BSD find which has many differences. To install GNU find you will need Homebrew, pretty easy to install, just follow http://brew.sh/ After that you can install findutils: brew install findutils More info and other tools to mimic a Linux environment on ...


4

? is special (being used by both glob and history expansion, see zshexpn(1)), and thus requires escaping, but otherwise can be used as an alias, though probably should not be, given that it is special. % alias \?='echo hi' % ? hi


3

The vicmd mode, despite the name, is for Vi's normal-mode commands. The prompt started by : isn't for Vi's ex-mode commands, but for running ZLE (Zsh's line editor) commands: $ echo foo execute: e_ edit-command-line emacs-forward-word end-of-history end-of-line-hist exchange-point-and-mark execute-named-cmd ...


2

Give this tested version a try: #!/usr/bin/awk -f BEGIN { last=FILENAME; } { if (last != FILENAME) { if (line !~ /^hello world$/ && line != "hello world") { print last; } last=FILENAME; } line=$0; } END { if (line !~ /^hello world$/ && line != "hello world") { print FILENAME; } } The test: $ chmod +x ...


2

How about using read? $ cat /dev/null | read pointless || echo no output no output $ echo something | read pointless || echo no output $ printf "\n" | read pointless || echo no output $ printf " \n" | read pointless || echo no output $ false | read pointless || echo no output no output According to the Open Group definition: EXIT STATUS The ...


2

Try pressing Control+[ immediately followed by h. Terminals do not send key presses directly to the shell (as in Control was pressed/released). Instead the terminal sends character sequences depending on keys pressed. The keys in a sequence are to be pressed - well - in sequence, not all at once. The big exception to this are the Control-keys and the ...


2

You can (as in bash) use a function in your prompt. Here is an example: setopt PROMPT_SUBST print_dir(){ case $PWD in (*/Development*) echo DEV/${PWD:t} ;; (*) echo $PWD ;; esac } export PROMPT=$'[$(print_dir)]: ' The zshall manual page documents PROMPT_SUBST: If the PROMPT_SUBST option is set, the prompt string is first ...


2

(command1; command2)& - should do it, works in bash. This creates a subshell (the two parenthesis) and runs the whole subshell in the background.


1

Turns out that removing all ~/.zcompdump files solved it: rm -r ~/.zcompdump*


1

Use emacs, start an inferior shell and issue your command. The output will be available in the shell buffer and can be selected using the usual commands. Alternatively, select file in $(find <whatever>); do vi $file; break; done The emacs approach is more practical if you already know the editor. Emacs can run arbitrary "inferior processes", ie. ...


1

^[ actually means Escape character. Check here: https://en.wikipedia.org/wiki/ASCII In your case it seems your ALT key works as a synonym for Escape key: https://en.wikipedia.org/wiki/Alt_key


1

It seems that prezto is loading the module from /usr/lib/prezto/modules/completion. With everything enabled, I deleted the contents of /usr/lib/prezto/modules/completion/init.zsh, which gave me the second quickest load time again. I then started systematically deleting lines in this file, and could isolate a single line causing the slowdowns. unsetopt ...


1

You can reverse the order of the files (sort --reverse) so the latest files will always be the first in a block of files with the same prefix. Then you can keep track of the current block (with $current_prefix) and keep the first file in each block (continue) and rm all the other files in the block: current_prefix= find . -name '???_*.txt' | sort --reverse ...


1

The simple typeset -U dirstack fails, as dirstack is doubtless too special for the usual unique limitation to apply (this typeset is however handy for things like the path array). On closer inspection the Arch Wiki code suffers from incomplete uniqueness, in that only dirstack only when being written out is made unique, and not with PWD, nor when reading the ...


1

With recent Linux, printf foo > /proc/$$/comm will change the executable name (the ps -p thing) provided "noclobber" isn't set (and the wind is in the right direction). In zsh, printf foo >! /proc/$$/comm works regardless of clobbering state.


1

You can setup a pager to capture output and then quit if it fits on one screen. When it doesn't fit, you can use the pager to scroll and search. export PAGER=less export LESS=-FSXRi # -F and -X are relevant here, but that's what I use # also, less quickly toggles most by typing '-' and the option I imagine zsh has a way to automatically modify commands ...



Only top voted, non community-wiki answers of a minimum length are eligible