Archive

Archive for the ‘zsh’ Category

~+ Another Magical ZSH Tip

November 17th, 2012 No comments

I’ve been using zsh’s ability to cd to any of your recent directories for a long while

e.g.

> cd -<tab> which gives you a pick list of recent directories

I’ve just learnt however about the ~+ operator which allows

vi ~+<tab>
1 — /c/aaz
2 — /c/aaa
3 — /c/aax
4 — /usr/bin

I type 1-4 to pick the desired directory and then can continue completion.

remember you need the options in your .zshrc

setopt autopushd pushdignoredups # used by cd-
autoload compinit
compinit

also to remember to visit a few directories beforehand

Categories: zsh Tags:

Cygwin, zsh & rebaseall

November 7th, 2012 No comments

If you happen knowingly or unknowingly upgrade your zsh you may run into the dreaded “cannot create fork” “dll overlapping” problem not even ls will work. It happens rarely enough that when it occurs I panic thinking that my entire Cygwin environment is corrupt, but phew it just needs a rebaseall.

Now rebaseall must be run with Cygwin shutdown and here’s the kicker and Cygwin services such as sshd must be stopped in Windows services. The easiest way I know then to run the rebaseall command is directly from Windows Run box or from a Dos prompt

\cygwin\bin\dash -c ‘/usr/bin/rebaseall’

 

and hey presto your Cygwin will be fine.

Categories: Cygwin, zsh Tags:

Converting a Textified File Name back into Title Case

March 11th, 2010 No comments

This could easily be done with Perl but here is a zsh solution

I want to convert a textified string to a Title Case Phrase
>
> eg
> fred-goat-dog.jpg to Fred Goat Dog
>

% print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
Fred Goat Dog

This curiously uses a smiley face though
foo=fred-goat-dog.jpg
echo ${(C)foo:gs/-/ /:r} might be more elegant
From the zsh newsgroup (RD&MM)

and to textify a phrase

s=’Fred Goat Dog’
print ${(L)s:gs/ /-/}.jpg
or
print ${(L)s// /-}.jpg

Categories: zsh Tags: , ,