New answers tagged

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


0

After some searching, I've found the answer: To discover what escape sequence the key combination is triggering, follow this excellent answer: echo "CtrlVEsc/" Which displays, for me, as: echo "^[/". CtrlV forces the following key to display as an escape sequence instead of being interpreted. So now we know we're trying to find what is bound to "^[/". ...


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.


0

This blog post from 2013 recommends a couple of keybinds that match all the words before the cursor. # Cycle through history based on characters already typed on the line autoload -U up-line-or-beginning-search autoload -U down-line-or-beginning-search zle -N up-line-or-beginning-search zle -N down-line-or-beginning-search bindkey "$terminfo[kcuu1]" ...


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

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


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.


0

There is a Zsh plugin created to do specifically what you request: https://github.com/psprint/ztrace


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


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


0

Assuming you have the default emacs keybindings, try using Alt+Enter instead of plain Enter to schedule a line for execution. For me when the lines are added this way I can easily move up and down those lines. e.g. When at a zsh terminal prompt: % cat << EOF<ALT-ENTER> first line<ALT-ENTER> second line<ALT-ENTER> thi ^ ...


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


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


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.


-1

The embedded date command will only be evaluated once: when the alias is created. That's the reason reloading the .zshrc makes it work again. If you use a function instead as djf suggested, it will be evaluated every time which seems to be your intended behavior.


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'


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)


1

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


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.


3

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


0

What about using https://github.com/zsh-users/zsh-autosuggestions? The thing is, for each command you type this plugin will show you some suggestions that could be accepted or not. Try it out and give us some feedback.


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


1

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


0

In answer to the question is my zsh completion script _cheat considered a "completer" in the context string? The answer seems to be no If you use ESC2, CTRL+x,h to dump zsh's completion context % cheat b tags in context ...


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.


0

Much thanks to @stéphane-chazelas who pointed out all the problems with my previous attempts, this now seems to work to serialise an array to stdout or into a variable. This technique does not shell-parse the input (unlike declare -a/declare -p) and so is safe against malicious insertion of metacharacters in the serialised text. Note: newlines are not ...


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


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



Top 50 recent answers are included