zsh

Moving a word forward in z shell

In zshell how to move forward word, I can set -o vi and use vi format. Is there a way to move forward in zshell by a word ...

What does ${#${(S%%)string//(\%([KF1]|)\{*\}|\%[Bbkf])}} mean

I found this in the adam2 zsh prompt, and I have no idea what it means. Apparently it counts the length of the "string", but how it does that is beyond me. ${#${(S%%)string//(\%([KF1]|)\{*\}|\%[Bbkf])}} ...

How to limit the subset of git commands that zsh will auto-complete (with tab)?

I have a combination of: autoload -Uz compinit compinit and autoload -Uz vcs_info It actually allows for a great amount of integration between git and zsh's tab completion. Too much in fact. How do I limit the set of commands, so that git che(TAB) will expand to checkout, and not to a choice between checkout and checkout-index? ...

(zsh brace expansion | seq) for character lists - how ?

Bash allows me to write the statement, $ for i in {h..k} ; do echo $i ; done but zsh only allows number list expansion such as {8..13}. What's the best workaround? Something like seq for characters... ...

zsh make **/*.cpp **/*.cxx **/*.hpp not result in error

I have "v" aliased to "vim */.cpp */.hpp */.cxx" Problem is, if I'm in a directory without any .cxx files, zsh treats this as an error. Is there anyway to tell zsh to create the absence of */*.cxx files as "" instead of an error? ...

How to remove the file extension in a zsh completion?

I want to adjust zsh so that I can tab complete: myprog <tab> using all *.foo files in ~/somedir, but have it so that it displays them without the .foo extension. Is there any way to do this? This is what I have so far: #compdef myprog typeset -A opt_args local context state line local -a mydirs mydirs="(. ~/somedir)" _arguments -...

Can I have a shell alias evaluate a history substitution command?

I'm trying to write an alias for cd !!:1, which takes the 2nd word of the previous command, and changes to the directory of that name. For instance, if I type rails new_project cd !!:1 the second line will cd into the "new_project" directory. Since !!:1 is awkward to type (even though it's short, it requires three SHIFTed keys...

is there a way to switch bash or zsh from emacs mode to vi mode with a keystroke

I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is sometimes better, but I'm usually half-way through typing something before I realize I want I don't want to switch permanently to vi mode, because I normally prefer emacs mode on the command line, mostly because it's what I'm used to, and over the yea...

Zsh: how to see all buffers?

You can push things to buffer with ^Q and pop them with ESC-g. Alt+x vi-set-buffer changes buffer somehow. How can I see all the buffers? They are probably some files to look at. ...

ZSH: how can I run Vim-style substitute command in command line?

I forgot the array syntax while on Zsh-commandline: $ hello=[1,2,3,4] %ERR: I want to fix the problem by substitution. In Vim, I would do :.s@,@ @g. So how can I edit the current line, or let call it a current buffer, by running a command on it? ...

Autocompletion based on filenames in a directory

Hi there, I want to have a function in my zsh for faster accessing my todo-files. It should look inside the folder ~/tasks where i put my todo-lists and stuff. Now i want to type task p and when I hit tab, it should use the files in that directory for autocompletition. Can anyone point me some direction? Or share some snippet to work wi...

bind key to complete filename wherever the context is in Zsh

Sometimes I want a filename instead of what zsh guesses for me. For example, I have a PNG file without a proper .png suffix, which makes zsh think it isn't a picture and won't list it when I type Tab to complete arguments of display. I am wondering if there is a key sequence that completes for a filename wherever the context is, like ^X...

ZSH: why error using array: "illegal character: ^M"?

$ values=( 300 400 ) $ echo "scale=20; $values[1]-$values[2]" | bc (standard_in) 1: illegal character: ^M // Why does it not print -100? $ echo $values // no ^M sign found! 300 400 [Update] Why is 5E 4d 0a, ie ^M, 13th char in ASCII? Why is the ending sign 0a shown as .? . is 2E in DEC. Hex nu...

zsh: strftime command not found

I am currently learning the zsh and now I wanted to use strftime but i get: zsh: command not found: strftime I think I'm doin' something wrong, since I see people using that function all the time in their dotfiles. ...

How can I configure zsh to autocomplete branch names while using 'git checkout'?

When I say 'git checkout ' I want zsh to autocomplete names of my git branches. Is that possible? ...

zsh: command not found: ls

I'm having a rather strange problem with zsh. When I start up my shell, everything - functions, environment vars, aliases, etc. - all work fine. I've created the following function and sourced it in zsh: clean() { path=/tmp for i in ${path}/*; do echo $i done } Running clean in the terminal works as expected, i...

How to load different zshrc file via commandline option?

I used to do this with bash... /bin/bash --rcfile /home/sindhu/bin/misc_scripts/shellrc/.bashrc_1 how can I accomplish the same with zsh? Thank you.z ...

zsh alias within function

Good morning, In zshell I have an alias as follows: alias foo='echo FooBar!' Which of course works fine. I have a function wherein I'm trying to actually 'execute' the alias, where it doesn't. foo_fun () { echo "About to foo!" `$foo` $foo eval $foo eval `$foo` echo "Just food...wait what?" } I'm having a b...

git-diff in another directory

I'm currently writing a little zsh function that checks all of my git repositories to see if they're dirty or not and then prints out the ones that need a commit. Thus far, I've figured out that the quickest way to figure out a git repository's clean/dirty status is via git-diff and git-ls-files: if ! git diff --quiet || git ls-files -...

zsh behaves weird in screen

Hi there, I have zsh set up as my default shell. It works fine as long as i am not within a screen. When i start screen it looks as if some dotfiles are not loaded. For example my $PATH isn't set correctly and some directories are missing. I'm not quite sure where to start looking. Since all is fine, as long as i'm not in a screen. My ...