Hot answers tagged

4

That's because you have a space between the path and the $1. Try this instead: function chef(){ /opt/chefdk/embedded/bin/"$1" }


4

Instead of >(cmd), assuming it's cmd's stdin you wish be a tty instead of a pipe, you could try and use: >(socat -u - exec:'cmd',pty) socat would use a pseudo-tty pair and have cmd's stdin connected to the slave part ([ -t 0 ] would then return true). The pseudo-terminal will be put in raw mode, so the line discipline should not interfere with the ...


3

You had the options auto_cd and cdable_vars turned on. With auto_cd, if you type a directory as a command name, the cd command is implied. With cdable_vars, if a directory doesn't exist, or a command doesn't exist with auto_cd, then the name is looked up in the directory hash table. As long as you're using the “new-style” (compinit) completion system, which ...


3

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


3

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. ...


3

editphpini() subl /usr/local/etc/php/${1[1]}.${1[2,-1]}/php.ini ${1[1]}.${1[2,-1]} is one of the many ways to transform xyz into x.yz. Other approaches could be: ${1[1]}.${1#?}, or ${1/(#m)?/$MATCH.} or ${(j:.:)${(s::)1}} (for x.y.z)


2

The test command runs isatty(fd) to check whether a descriptor is related to a TTY. isatty(3) is a C library function that checks whether a file descriptor allows to send terminal ioctl(2) calls to the descriptor. You therefore cannot fake the result unless you use LD_PRELOAD= to overwrite the isatty() function in the shell.


2

This will depend on the exact flavour of ps involved, but may run something along the lines of zstyle ':completion:*:processes' command 'ps -A'


2

There is a function documented in zshcontrib called up-line-or-beginning-search, you can view this by running. man zshcontrib | less '+/^\s*up-line-or-beginning-search' These widgets are similar to the builtin functions up-line-or-search and down-line-or-search: if in a multiline buffer they move up or down within the buffer, ...


2

Thanks to @forquare's reminder, I checked oh-my-zsh config and discovered the problem: plugin safe-paste. After removing safe-paste from ~/.zshrc, pasting works in the vi mode.


2

It is probably % bindkey '^[/' "^[/" _history-complete-older % or similar. And that's how you find out. Further reading Paul Falstad (2015-12-02). "ZLE builtins". Z Shell Manual. 5.2.


2

Your fonts and colors would be determined by the type of terminal emulator and where it is run. Some people do something like ssh -X remotehost -e xterm and some do this ssh (running in a terminal on the local host). Technically the local X display determines the maximum number of colors which you can use (in either case), but most users have ...


2

You shouldn't define aliases in /etc/zprofile or ~/.zprofile. These files is only loaded in login shells (“shells” meaning zsh of course). The proper place to define aliases is in /etc/zshrc or ~/.zshrc, which is read by all interactive shells. To run zsh without loading /etc/zprofile, just run zsh with no option. The option -f tells zsh not to read ...


2

I'm (brand) new to zsh, so this could probably be improved: tile_lengths=() num=19 times=6 repeat $times { tile_lengths+=( $num ); ((--times)) } num=18 times=9 repeat $times { tile_lengths+=( $num ); ((--times)) } print $tile_lengths 19 19 19 19 19 19 18 18 18 18 18 18 18 18 18 Inspired by terdon's answer, I think this is a cleaner variation of my ...


1

How about: % tile_lengths=( $(repeat 25 echo 19; repeat 30 echo 18 ) ) % echo $tile_lengths 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 For other shells, you could do something like: $ ...


1

Also related is the KEYTIMEOUT setting, which indicates how long ZSH will wait to detect multi-key sequences, minimized by setting: KEYTIMEOUT=1 If you're feeling super extreme, you can also remove all the ESC-something binds, so that ZSH has no multi-key sequences it will waste time waiting for following the escape key being pressed. bindkey -rpM viins ...


1

In bash You can abuse the --rcfile option like so: bash --noprofile --rcfile <(alias) But the --noprofile is pretty useless without the -l option to make it a login shell.


1

thanks to @don_crissti linking through this Arch wiki documentation. For some reason the code on the Arch wiki causes this error on invocation /home/velour/.zshrc:unalias:368: no such hash table element: run-help zsh --version => zsh 5.1.1 (x86_64-ubuntu-linux-gnu) so to get it to work, I added the below block to ~/.zshrc, then commented out the alias ...


1

function editphpini() { local version=$( echo $1 | sed 's/^\(.\)/\1./' ) subl /usr/local/etc/php/${version}/php.ini } usage: % editphpini 54


1

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


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.



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