Hot answers tagged

5

To do anything more complex than to replace a simple command with an alias, use a shell function. In your case: function gvim { nvim-qt --geometry 500x320 -- "$@" & } Aliases are not really suited for much more than simple things, like adding your favourite flags to ls or whatever.


4

head or tail will not fix/change the character. What probably happens is that gedit tries to guess the encoding of the file based on the first few bytes. When that 0xD4 is far within the file, gedit guesses the file is in ASCII or UTF-8 and complains when it sees that 0xD4 byte that is invalid in either ASCII or UTF-8. While for the second shorter file, ...


4

if type emulate >/dev/null 2>/dev/null; then emulate ksh; fi In zsh, this activates options that make it more compatible with ksh and bash, including sh_word_split. In other shells, emulate doesn't exist so this does nothing.


3

Zsh does this provided that you enable the “new-style completion system” and turn on the complete_in_word option. autoload -U compinit; compinit setopt complete_in_word After that, you can press Tab anywhere in a word, including at the beginning, and you'll get completion proposals for the middle of the word (for the beginning, if the cursor is at the ...


3

One way to exchange one directory component for another in zsh is the two-argument version of cd: cd old new This substitutes new for the first substring matching old and tries to change directory to the resulting path. For example: % pwd /path/to/my/backup/back-2015-07-02T21_18_01/home/myuser/myfiles/somedir/subdir/ % cd "5-07-02T21_18_01" "6-04-...


3

The answer was simpler than I thought it would be. Credit to John B, one can use a sub-shell (...) for this: ➜ time (sleep $(sleep 3; echo 1)) ( sleep $(sleep 3; echo 1); ) 0.00s user 0.00s system 0% cpu 4.007 total


2

Aliases and functions are contained in aliases and functions, and one merely needs to print the keys of such. "Variables and arrays" is trickier; parameters may suffice? print -l ${(k)aliases} ${(k)functions} ${(k)parameters} (You may also need builtins, commands, and perhaps other things listed from print -l ${(k) and then mashing tab, assuming ...


2

The builtin : does nothing (it's a no-op). It's used in many places in zsh's completion code, amongst others. It may well be used in some code related to key bindings. If you override it with a function, expect your function to be called a lot. Overriding standard command names with something completely different is a bad idea. But if you really want to ...


2

This is a Z Shell module known as "url-quote-magic" in action. It is trying to ensure that you end up with what you intended even though you completely ignored shell metacharacters and quoting. It detects when (in ZLE) an unquoted word looks like a URL, with a schema on the front, and changes the way that character self-insertion happens to the rest of the ...


2

The place to look is with oh-my-zsh and its use (or not) of the safe-paste plugin: The safe-paste plugin does not make pasting safe and breaks other features. #1742 comments Enabling this plugin also breaks the escaping of special characters that are pasted including those of URLs. Keyboard input disabled after paste #4434 Debian Bug report logs - ...


2

I like to be pragmatic, and since writing a zsh completion is outside my current skills, I'd just write a special purpose function using the select menu system from zsh (and bash). cdd(){ typeset dir typeset -a dirs if [[ $PWD =~ ^(.*)(/back-[0-9-]+T[0-9_]+/)(.*)$ ]] then for dir in "$match[1]"/*/"$match[3]" do [ "$dir" !=...


2

Hmm, this method appears to get directly to selecting "aaa1" and being in a loop-on-the-menu-items mode: exec zsh -f zmodload zsh/complist autoload -U compinit; compinit bindkey "^I" menu-select cd a As does the menucomplete option: exec zsh -f autoload -U compinit; compinit setopt menucomplete cd a There is an autolist option, but that only lists the ...


2

Tack on (N) to the pattern; this tells zsh to not be upset about missing matching. rm -f *.{dot,svg,err}(N) It's a zsh glob feature. See man zshexpn for more details; under "Glob Qualifiers". It's annotated as "sets the NULL_GLOB option for the current pattern".


2

(Insprired by this answer) It is set in $ZSH/lib/directories.zsh: setopt auto_pushd setopt pushd_ignore_dups auto_pushd makes cd behave the same as pushd. However, this would result in an directory stack overflow if you keep changing directory, so they set pushd_ignore_dups as well, to limit the stack. This is not a problem for me, since I disabled ...


2

with PROMPT="…$(build_prompt)", you're running build_prompt at the time of the assignment, i.e. when your .zshrc is read, and using the result of that one run as the prompt. To run build_prompt each time the prompt is displayed, include the string $(build_prompt) directly in the value of the PROMPT variable. This requires turning on the prompt_subst option. ...


1

You don't get a warning in bash, you get an error by ls. In both zsh and bash, {...} is not a globbing operator, it's an expansion that occurs before globbing. In: ls -d -- *.{dot,svg,err} (you forgot the -d and -- btw), the shell expands the {...} first: ls -d -- *.dot *.svg *.err and then does the glob. bash like most Bourne-like shells has that ...


1

Update: Use zle-line-init (Thanks to Gilles for the hint) Not exactly profiling, but from the text in your question it seems, that you are primarily interested in gauging how much delay the plugin entails. One way to get this estimate is by utilizing the precmd hook, which is run every time just before the prompt is rendered, and the zle-line-init widget, ...


1

Try adding: setopt no_share_history unsetopt share_history to ~/.zshrc ... this should work


1

"FLA.*Image.*file.jpg" means literally FLA.*Image.*file.jpg and will not be expanded by ZSH. If you remove the " and add the parenthesis, like this m=($f/FLA.*Image.*file.jpg) the wildcards should then work. You have to explicitly surround the glob pattern with parentheses so that m is an array, otherwise m is a string and globbing is not done.


1

Don't set TERM in your shell startup files. TERM is determined by the terminal you're running, not by your shell. Your shell startup file is overriding the TERM set by tmux.



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