<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://www.zshwiki.org/home/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://www.zshwiki.org/home/feed.php">
        <title>ZshWiki examples</title>
        <description></description>
        <link>http://www.zshwiki.org/home/</link>
        <image rdf:resource="http://www.zshwiki.org/home/lib/images/favicon.ico" />
       <dc:date>2010-09-09T14:21:09+02:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/aliasdirs?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/aliasglobal?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/aliasnormal?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/aliassuffix?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/compctl?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/compquickstart?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/expnhistory?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/expnparam?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/functions?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/hardstatus?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/mathpath?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/start?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/zhisthack?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/zleiab?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/zlewidgets?rev=1262679647"/>
                <rdf:li rdf:resource="http://www.zshwiki.org/home/examples/zlewordchar?rev=1262679647"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://www.zshwiki.org/home/lib/images/favicon.ico">
        <title>ZshWiki</title>
        <link>http://www.zshwiki.org/home/</link>
        <url>http://www.zshwiki.org/home/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="http://www.zshwiki.org/home/examples/aliasdirs?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:aliasdirs</title>
        <link>http://www.zshwiki.org/home/examples/aliasdirs?rev=1262679647</link>
        <description>Look at this:


% zsh -f
zsh% PS1=&quot;%~%% &quot;
~% hash -d zsh=&quot;/usr/src/zsh&quot;
~% cd ~zsh
~zsh% pwd
/usr/src/zsh


Nice, isn't it?

This way you can give names to directories, that you visit often. It even looks nice in your prompt.

This isn't stricly an alias, but you can think of them as aliases.</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/aliasglobal?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:aliasglobal</title>
        <link>http://www.zshwiki.org/home/examples/aliasglobal?rev=1262679647</link>
        <description>Global aliases - Do not have to be at the beginning of the command line.

Typical use is:


alias -g H='| head'
alias -g T='| tail'
alias -g G='| grep'
alias -g L=&quot;| less&quot;
alias -g M=&quot;| most&quot;
alias -g B=&quot;&amp;|&quot;
alias -g HL=&quot;--help&quot;
alias -g LL=&quot;2&gt;&amp;1 | less&quot;
alias -g CA=&quot;2&gt;&amp;1 | cat -A&quot;
alias -g NE=&quot;2&gt; /dev/null&quot;
alias -g NUL=&quot;&gt; /dev/null 2&gt;&amp;1&quot;</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/aliasnormal?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:aliasnormal</title>
        <link>http://www.zshwiki.org/home/examples/aliasnormal?rev=1262679647</link>
        <description>Cleaning up


This is useful, if you want to remove systemwide aliases from your config:


# Clean up unwanted system aliases and start from scratch.
unhash -am '*'


Common Aliases


# fast directory change
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'

# upgrade shortcut for debian users
[ -r /etc/debian_version ] &amp;&amp; [ -x `which sudo` ] &amp;&amp; alias upgrade='sudo apt-get update &amp;&amp; sudo apt-get -u upg…</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/aliassuffix?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:aliassuffix</title>
        <link>http://www.zshwiki.org/home/examples/aliassuffix?rev=1262679647</link>
        <description>Since zsh 4.2.x its possible to make a programme alias for a given filename extension.

That means, you can assign commands to filename suffixes.


alias -s txt='less -rE'


Now every time you enter a $filename with extension .txt less -rE $filename is invoked.

If you use `*.txt' then all files with that extension will be invoked with the command less with options -r -E.</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/compctl?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:compctl</title>
        <link>http://www.zshwiki.org/home/examples/compctl?rev=1262679647</link>
        <description>The 'old' style of completion.

It's got quite a lot of fans, because it is a lot quicker than the new system.

Here are a few examples, on how you can configure this system:


# simple completions
# complete only dirs (or symlinks to dirs in some cases) for certain commands
compctl -g '*(/)' rmdir dircmp
compctl -g '*(-/)' cd chdir dirs pushd

# hosts completion for a few commands
compctl -k hosts ftp lftp ncftp ssh w3m lynx links elinks nc telnet rlogin host
compctl -k hosts -P '@' finger

# m…</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/compquickstart?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:compquickstart</title>
        <link>http://www.zshwiki.org/home/examples/compquickstart?rev=1262679647</link>
        <description>There are quite a lot of zsh users that do use the new compsys (via compinit), but do not know how much it can do.

There's a compinstall function in newer versions of the shell, that does some inititalizations if the shell can't find ~/.zshrc, which is fine, but to give new users an idea of what can be done, paste this to your .zshrc:</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/expnhistory?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:expnhistory</title>
        <link>http://www.zshwiki.org/home/examples/expnhistory?rev=1262679647</link>
        <description>^foo^bar


To retrieve the last command replacing a certain pattern once:


% mv foo.c old/ # very silly example, I know...
% ^foo^bar
% mv bar.c old/


However if you need to replace all occurences, with zsh 4.3.1 you can use:


% mv foo.c foo_archive 
% ^foo^bar:G
% mv bar.c bar_archive</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/expnparam?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:expnparam</title>
        <link>http://www.zshwiki.org/home/examples/expnparam?rev=1262679647</link>
        <description>Apart from this page, we do now have pageset that discusses parameter expansion
in more detail. Please refer to Scripting:Parameter Expansion.

Substitutions tips

1. Use a variable name as reference to other variable

1.1 Numeric content


var1=5
tmp=var1
echo $((tmp))</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/functions?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:functions</title>
        <link>http://www.zshwiki.org/home/examples/functions?rev=1262679647</link>
        <description>Extending commands/builtins

Extended cd #0


(cd path/path/file), go to the directory containing the file, no questions asked added support for cd foo bar to change from /foo/subdir to /bar/subdir (not friendly to reiserfs4's files as directories).</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/hardstatus?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:hardstatus</title>
        <link>http://www.zshwiki.org/home/examples/hardstatus?rev=1262679647</link>
        <description>Here are functions to set the title and hardstatus of an XTerm or of GNU Screen to 'zsh' and the current directory, respectively, when the prompt is displayed, and to the command name and rest of the command line, respectively, when a command is executed:</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/mathpath?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:mathpath</title>
        <link>http://www.zshwiki.org/home/examples/mathpath?rev=1262679647</link>
        <description>Simple:



mailpath=($HOME/Mail/mbox'?new mail in mbox'
HOME/Mail/tux.u-strasbg'?new mail in tux'
$HOME/Mail/lilo'?new mail in lilo'
$HOME/Mail/ldap-fr'?new mail in ldap-fr')


Dynamic:



for i in ~/Mail/Lists/*(.); do
  mailpath[$#mailpath+1]=&quot;${i}?You have new mail in ${i:t}.&quot;
done</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/start?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:start</title>
        <link>http://www.zshwiki.org/home/examples/start?rev=1262679647</link>
        <description>Sometimes, it's easier to understand solutions to a problem when you see examples for it.

Check out the examples in the subpages linked from the menu on the left or on the frontpage.</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/zhisthack?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:zhisthack</title>
        <link>http://www.zshwiki.org/home/examples/zhisthack?rev=1262679647</link>
        <description>This is an attempt at implementing the history function somewhat differently (and with a greater degree of control). There are a few reasons for this:




	*  I noticed that the &lt;elapsed seconds&gt; of EXTENDED_HISTORY is always set to zero when INC_APPEND_HISTORY or SHARED_HISTORY is set. (I would like to have them both, and would be perfectly content with having each command line written to the history when execution finishes, rather that when it begins.)
	*  I would like to re-write forced redir…</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/zleiab?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:zleiab</title>
        <link>http://www.zshwiki.org/home/examples/zleiab?rev=1262679647</link>
        <description>I saw this idea in strcat's config for the first time.


This way you can get a similar featureset as with global aliases, but without its dangers and with additional flexiblity.

The idea is, to enter unique strings that get replaced with something useful as soon as the space-key gets hit:</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/zlewidgets?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:zlewidgets</title>
        <link>http://www.zshwiki.org/home/examples/zlewidgets?rev=1262679647</link>
        <description>Just to hint you at a few widgets, that are already there...

Tetris


Someone once accused zsh of not being as complete as Emacs, because it lacks Tetris and an adventure game.

I like to use ^T (imagine that!) so in my .zshrc file I have:



autoload -U tetris
zle -N tetris
bindkey ^T tetris</description>
    </item>
    <item rdf:about="http://www.zshwiki.org/home/examples/zlewordchar?rev=1262679647">
        <dc:format>text/html</dc:format>
        <dc:date>2010-01-05T09:20:47+02:00</dc:date>
        <title>examples:zlewordchar</title>
        <link>http://www.zshwiki.org/home/examples/zlewordchar?rev=1262679647</link>
        <description>Try these widgets, if you'd like to skip or delete words, entire args, a 'level' in a path.


my_extended_wordchars='*?_-.[]~=&amp;;!#$%^(){}&lt;&gt;:@,\\';
my_extended_wordchars_space=&quot;${my_extended_wordchars} &quot;
my_extended_wordchars_slash=&quot;${my_extended_wordchars}/&quot;

# is the current position \-quoted ?
function is_quoted(){
 test &quot;${BUFFER[$CURSOR-1,CURSOR-1]}&quot; = &quot;\\&quot;
}

unquote-forward-word(){
    while is_quoted
      do zle .forward-word
    done
}

unquote-backward-word(){
    while  is_quoted
    …</description>
    </item>
</rdf:RDF>
