zsh

how provide data for zsh completion system

Is there any standard way of providing list of program switches, so it would be possible for zsh to determine possible completions? Or must it provided directly to zsh developers and only they can add completions to zsh? ...

How can I (from a script) add something to the zsh command history?

I'd like to be able to look through my command history and know the context from which I issued various commands--in other words, "what directory was I in?" There are various ways I could achieve this, but all of them (that I can think of) would require manipulating the zsh history to add (for instance) a commented line with the result ...

Saving current directory to zsh history

I wanted to achieve the same as asked here http://stackoverflow.com/questions/945288/saving-current-directory-to-bash-history but within zsh shell. I haven't done any zsh trickry before but so far I have: function precmd { hpwd=$history[$((HISTCMD-1))] if [[ $hpwd == "cd" ]]; then cwd=$OLDPWD else cwd=$PWD fi hpwd="${hpwd% ### *} ### $c...

Translate parse_git_branch function to zsh from bash (for prompt)

I am using this function in Bash function parse_git_branch { git_status="$(git status 2> /dev/null)" pattern="^# On branch ([^${IFS}]*)" if [[ ! ${git_status}} =~ "working directory clean" ]]; then state="*" fi # add an else if or two here if you want to get more specific if [[ ${git_status} =~ ${pattern} ]]; then b...

Including/Importing aliases and functions for both bash and zsh

I have a directory of functions and aliases I'd like to include for both bash and zsh terminal invocations (So I don't need to put every function and alias into every separate script and to facilitate organization/tidying of .rc files) What I've tried so far hasn't worked. Just setting this out for further suggestions. ...

Zsh command substitution

I usually work with BASH, but I'm trying to setup a cronjob from a machine and user account that is configured with zsh. When the cronjob runs, the date variable does not contain the date, just the string for the command to return the date. DATE=$(date +%Y%m%d) 55 15 * * 1-5 scp user@host:/path/to/some/file/$DATE.log /tmp I've tri...

Loading zsh as the default shell in gnu screen

Hello, Im using KUbuntu 10.04 (Lucid Lynx). I have installed zsh and screen. I have set zsh as the default shell, by setting Command to zsh in Settings->Edit Current Profile of the terminal. But,when i launch screen,the bash shell is loaded. If i run the command zsh, then zsh starts but the following message is displayed: "/home/joel/....

zsh for loop exclusion

This is somewhat of a simple question, but for the life of me, I cannot figure out how to exclude something from a zsh for loop. For instance, let's say we have this: for $package in /home/user/settings/* do # do stuff done Let's say that in /home/user/settings/, there is a particular directory ("os") that I want to ignore. Logica...

alias with parameters

If there is any possibility to use the parameters in zsh aliases? Something like this: alias ssh_nokia="ssh root@<ip_parameter>" Usage: ssh_nokia 192.168.1.2 ...

How can I get 'git status' to always use short format?

I'd like git status to always use the short format: $ git status --short M src/meck.erl M test/meck_tests.erl ?? erl_crash.dump ?? meck_test_module.coverdata There does not seem to exist a configuration option for this, and git config --global alias.status "status --short" does not work. I haven't managed to create and alias in zsh ...

Split string with zsh as in Python

In python: s = '1::3' a = s.split(':') print a[0] # '1' good print a[1] # '' good print a[2] # '3' good How can I achieve the same effect with zsh? The following attempt fails: s="1::3" a=(${(s/:/)s}) echo $a[1] # 1 echo $a[2] # 3 ?? I want an empty string, as in Python ...

side effect of zsh echo?

For some reason this script will work with all of the 'echo's at the end, but without them $wall is an empty string. This seems like really odd behaviour. #!/bin/zsh if [ ! -n "$1" ] ; then files=(~/pictures/backgrounds/*jpg) else while [ $1 ] ; do files+=(`echo $1/*jpg`) shift done fi echo $files N=${#file...

How to turn off colors in ZSH shell? Make it black and white with unicode support!!!

Once when I got my hand on openbsd I was really happy to have black and white terminal, I, somehow, orienting much more with b/w colors.. Anyway I know just one option to do it. export TERM="linux-m" and openbsd used something else like "vt8.." i don't remember. Now I have freebsd on my dedicated server, I want to have black and w...

Backward search in vi-mode.

I just discovered the possibility to use vi-mode in zsh. Pretty awesome. But I used CTRL-r in emacs-mode pretty much and really really miss it. Is there something alike or can I get that functionality in vi-mode as well? ...

Split a paragraph into lines in ZSH

How can I take a multi-line string in zsh, and split it into an array of strings that are a single line each? Specifically I want to take the output of cal June 2010 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 and turn it into (" June 2010 "...

How do I fix my zsh prompt now that I've upgraded to snow leopard?

I recently upgraded my system to snow leopard and now my prompt doesn't work properly. I have this line in my .zshrc file: PROMPT='%{$fg_no_bold[cyan]%}%n@%{$fg_no_bold[red]%}%m%{$fg_no_bold[green]%}$(git_branch)%{$reset_color%}: ' (where "git_branch" is a function that give me information about the current git branch I'm working on)...

zsh filename globbling/substitution

I am trying to create my first zsh completion script, in this case for the command netcfg. Lame as it may sound I have stuck on the first hurdle, disclaimer, I know how to do this crudely, however I seek the "ZSH WAY" to do this. I need to list the files in /etc/networking but only the files, not the directory component, so I do the f...

I have a bash-tab-completion script. Is there a simple way to use it from zsh?

I have a bash-tab-completion script for Apache's Hadoop. Normally, I use zsh as my day-to-day shell. It tends to be pretty bash-like when I need it to be, but it looks like the tab-completion systems are radically different between them. Is there a simple way to "convert" the existing bash-tab-completion definitions to work in zsh? I...

Is there a hook in Bash to find out when the cwd changes?

I am usually using zsh, which provides the chpwd() hook. That is: If the cwd is changed by the cd builtin, zsh automatically calls the method chpwd() if it exists. This allows to set up variables and aliases which depend on the cwd. Now I want to port this bit of my .zshrc to bash, but found that chpwd() is not recognized by bash. Is a ...

Zsh Package Suggestion

Hello, I've just migrated to Zsh from Bash, but I have a bit of a problem in it. In bash on an Ubuntu system, when I type the name of a command which does not exist, Bash searches the apt database for a matching command name and prints out the package names that provide that command. It's a really useful feature, so I was wondering if so...