<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zInformatik</title>
	<atom:link href="http://zinformatik.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://zinformatik.de</link>
	<description>Computer, Informatik und Mikrocontroller Blog</description>
	<lastBuildDate>Mon, 22 Feb 2010 17:31:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Die Z-Shell (zsh) &#8211; Eine mächtige Alternative zur Bash</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/die-z-shell-zsh-eine-machtige-alternative-zur-bash/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/die-z-shell-zsh-eine-machtige-alternative-zur-bash/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:44:52 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Interessante Programme]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Konsole]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1668</guid>
		<description><![CDATA[Die Standardshell auf den meisten Linux-Systemen ist die Bash. Sie ist schon sehr mächtig und erlaubt es viele Aufgaben zu automatisieren. Dieser Artikel soll sich einer sehr interessanten weil noch mächtigeren Shell widmen, der Z-Shell kurz zsh.
]]></description>
			<content:encoded><![CDATA[<p>Die Standardshell auf den meisten Linux-Systemen ist die Bash. Sie ist schon sehr mächtig und erlaubt es viele Aufgaben zu automatisieren. Dieser Artikel soll sich einer sehr interessanten weil noch mächtigeren Shell widmen, der Z-Shell kurz zsh.</p>
<p>Die zsh lässt sich auf quasi allen Linuxsystemen über die Paketverwaltung installieren. Unter Ubuntu z.B. mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">zsh</span></pre></div></div>

<p>Danach kann man sie mit dem Aufruf von <code>zsh</code> ausführen. Um sie zur Standardshell zu machen genügt der Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chsh</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">zsh</span> username</pre></div></div>

<p>Wobei <code>username</code> durch den entsprechenden Usernamen ersetzt werden muss und der Pfad zu <code>zsh</code> stimmen muss. Auf manchen Systemen liegt <code>zsh</code> in <code>/bin</code>. Wo <code>zsh</code> liegt kann man mit dem folgenden Befehl heraus finden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">which</span> <span style="color: #c20cb9; font-weight: bold;">zsh</span></pre></div></div>

<p>Die zsh bedient sich Elementen der Bash, der Korn-Shell (ksh) und der TENEX-C-Shell (tcsh &#8211; eine erweiterte C-Shell). Sie ist sehr gut konfigurierbar und fast jedes Verhalten der Bash kann nachgeahmt werden so dass der Umstieg sehr leicht fällt. Bestehende Bash-Scripte können natürlich weiterhin genutzt werden, wenn der Shebang entsprechend gesetzt ist. Also in der ersten Zeile folgendes steht:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span></pre></div></div>

<p>Im Folgenden werde ich einige interessante Vorteile der zsh kurz beschreiben. Zu einzelnen Themen werde wahrscheinlich in anderen Artikel ausführlicher eingehen. Dies sollen also nur Beispiele sein, die die Mächtigkeit demonstrieren sollen. Da die zsh so viele Möglichkeiten bietet ist es nicht möglich hier alles im Detail zu erläutern. Optionen werden mit dem Befehl <code>setopt</code> gesetzt. Dies kann man auch so in die Konfigurationsdatei <code>~/.zshrc</code> schreiben.</p>
<p><strong>Autokorrektur</strong><br />
Die zsh beherrscht einen Mechanismus, der kleine Tippfehler automatisch korrigiert. Hat man in einem Ordner eine Datei <code>testfile.txt</code> und möchte diese kopieren nach <code>file2.txt</code>, so führt man in der Regel folgenden Befehl aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> testfile.txt file2.txt</pre></div></div>

<p>wie von der Bash gewohnt nutzt man dafür die Autovervollständigung mittels TAB. Bei einem Verschreiber wird dieser in der zsh automatisch korrigiert. Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> tsetf<span style="color: #000000; font-weight: bold;">&lt;</span>TAB<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>wird automatisch korrigiert und zu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> testfile.txt</pre></div></div>

<p>vervollständigt.</p>
<p>Die Autokorrektur aktiviert man mit der Option <code>correct</code></p>
<p><strong>Globale Aliase</strong><br />
Neben den normalen Aliasen für Kommandos, wie man sie aus der Bash kennt, gibt es in der zsh noch globale Aliase, die überall im Befehl genutzt werden können, nicht nur am Anfang. Zwei Beispiele verdeutlichen dies:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #660033;">-g</span> <span style="color: #007800;">G</span>=<span style="color: #ff0000;">'| grep'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #660033;">-g</span> <span style="color: #007800;">L</span>=<span style="color: #ff0000;">'| less'</span></pre></div></div>

<p>erzeugt die globalen Aliase G und L die man hinter alle möglichen Befehle schreiben kann um die Ausgabe des entsprechenden Befehls in grep oder less zu pipen. Z.B.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> G txt</pre></div></div>

<p>entspricht dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> txt</pre></div></div>

<p>oder</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-e</span> L</pre></div></div>

<p>entspricht</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-e</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">less</span></pre></div></div>

<p>Natürlich ist auch folgendes Möglich:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> G txt L</pre></div></div>

<p>was folgendem Befehl entspricht:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">less</span></pre></div></div>

<p><strong>Suffix Aliase</strong><br />
Mit Suffixaliasen kann man Programme festlegen, mit denen bestimmte Dateitypen (anhand ihrer Endung) geöffnet werden sollen. Man braucht dann nur noch den Namen der Datei eingeben und sie wird mit dem entsprechenden Programm geöffnet. Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">pdf</span>=evince</pre></div></div>

<p>legt einen Alias für pdf Dateien an. Sie sollen mit evince geöffnet werden. Danach reicht die Eingabe von</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dokument.pdf</pre></div></div>

<p>und die Datei <code>dokument.pdf</code> wird mit evince geöffnet.</p>
<p><strong>Aliase für Verzeichnisse: Hashes</strong><br />
Mit sogenannten Hashes lassen sich Aliase für beliebige Verzeichnisse anlegen. Auf diese kann dann sehr einfach zugegriffen werden. Mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">hash</span> <span style="color: #660033;">-d</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">perl</span></span>=~<span style="color: #000000; font-weight: bold;">/</span>developement<span style="color: #000000; font-weight: bold;">/</span>scripting<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span></pre></div></div>

<p>legt man einen Hash namens <code>perl</code> für das Verzeichnis <code>~/developement/scripting/perl</code> an. Auf dieses Verzeichnis kann man jetzt mit <code>~perl</code> zugreifen. Auch innerhalb eines Befehls wie folgendes Beispiel zeigt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> testscript.pl ~<span style="color: #c20cb9; font-weight: bold;">perl</span></pre></div></div>

<p>Dieser Befehl kopiert die Datei <code>testscript.pl</code> in das Verzeichnis <code>~/developement/scripting/perl</code>.</p>
<p><strong>Auto-CD</strong><br />
Mit der Option <code>autocd</code> kann man zum Wechseln in ein Verzeichnis einfach den Namen eines Verzeichnisses eingeben und das Kommando <code>cd</code> davor einfach weglassen. Wenn es keinen Befehl gibt, der so heißt wie das Verzeichnis, so wird in das Verzeichnis gewechselt.</p>
<p><strong>Kurze for-Schleifen</strong><br />
Statt einem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.eps; <span style="color: #000000; font-weight: bold;">do</span> epstopdf <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>um alle eps-Dateien in einem Verzeichnis in pdf-Dateien umzuwandeln genügt unter zsh die kürzere Form</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">*</span>.eps<span style="color: #7a0874; font-weight: bold;">&#41;</span> epstopdf <span style="color: #007800;">$i</span></pre></div></div>

<p><strong>Globale History</strong><br />
Die History, die man mit der Pfeil-auf Taste durchgehen kann, kann man in der zsh so einstellen, dass sie in jeder zsh-Instanz gleich ist. Das heißt man hat nicht mehr für jedes Fenster seine eigene History sondern kann mit der Pfeil-auf Taste auch Befehle raussuchen, die in anderen Fenstern eingegeben wurden. Die History wird jedoch nur nach jedem Befehl geupdated, das heißt man muss ggf. einmal Return drücken, damit die Befehle aus einem anderen Fenster verfügbar sind.</p>
<p>Dieses Verhalten kann mit der Option <code>share_history</code> aktiviert werden.</p>
<p><strong>Directory Stack</strong><br />
Wie Bash, hat die zsh auch einen Directory stack. Mit dem Befehl <code>pushd</code> kann man das aktuelle Verzeichnis auf den Stack legen und mit <code>popd</code> das jeweils letzte Verzeichnis vom Stack nehmen und dorthin springen. Mit der Option <code>auto_pushd</code> legt die zsh automatisch jedes Verzeichnis auf den Directorystack, aus welchem man in ein anderes Verzeichnis wechselt. So hat man immer eine History der Verzeichnisse in denen man war und kann mit <code>popd</code> sehr einfach wieder in Verzeichnisse welchseln, die man vorher besucht hatte.</p>
<p><strong>Globbing</strong><br />
Die Nutzung von Wildcards &#8211; unter zsh globbing genannt &#8211; ist bei der Z-Shell wesentlich mächtiger als in der Bash. Zunächst gibt es rekursives Globbing (gibts in der Bash in neueren Versionen wohl auch). So kann man mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">**/*</span>.html</pre></div></div>

<p>alle HTML-Dateien im aktuellen Verzeichnis und allen Unterverzeichnissen auflisten lassen.</p>
<p>Es gibt jedoch auch noch Qualifier um Dateien mit bestimmten Eigenschaften auszuwählen. Diese schreibt man in runde Klammern. So kann man mit <code>.</code> normale Dateien, mit <code>/</code> Verzeichnisse und mit <code>@</code> Symbolische Links matchen. Praktisch ist das z.B. wenn man allen Verzeichnissen ab einem bestimmten Verzeichnis die Rechte 755 und allen Dateien 644 vergeben möchte. Dies kann man mit den folgenden zwei Befehlen bewerkstelligen statt mit <code>find</code> und <code>exec</code> zu arbeiten.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">**/*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> <span style="color: #000000; font-weight: bold;">**/*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Zusätzlich gibt es auch Qualifier für verschiedenste Dateirechte. Folgender Befehl listet alle Dateien auf, die von allen beschrieben werden können:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">**/*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.W<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Auch nach der Dateigröße lässt sich suchen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">print <span style="color: #000000; font-weight: bold;">**/*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>L0<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>listet alle leeren Dateien auf.</p>
<p>Auch die Sortierung lässt sich beliebig anpassen. Mit dem Befehl:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">print <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>oL<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Listet alle Dateien der Größe nach von klein nach groß auf. Mit großem O wird die Sortierung umgekehrt.</p>
<p>Somit lässt sich mittels globbing in der zsh das Kommando <code>find</code> quasi komplett ersetzen. Die hier gezeigten Beispiele sehen auf den ersten Blick recht kompliziert und kryptisch aus. Wenn man das Prinzip aber einmal verstanden hat und die wichtigsten Qualifier kennt ist es aber ganz einfach und sehr praktisch.</p>
<p>Es gibt noch jede Menge weiterer Qualifier und Möglichkeiten für das Globbing (z.B. nur das erste oder eine bestimmte Anzahl von Elementen auszuwählen), die ich hier gar nicht alle erwähnen kann. Im zsh-Manual gibt es jedoch eine Liste der <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#SEC87" title="zsh-Manual - Glob-Qualifier" target="_blank" class="liexternal">Glob-Qualifier</a>.</p>
<p>Um alle Möglichkeiten nutzen zu können sollte die Option <code>extended_glob</code> gesetzt werden.</p>
<p><strong>Vervollständigung</strong><br />
Die zsh hat wie die Bash einen Vervollständigungsmechanismus, so dass man mit der TAB-Taste Kommandos, Dateinamen und vieles mehr vervollständigen kann. In der zsh ist dieser Mechanismus jedoch extrem gut konfigurierbar und programierbar. So kann man z.B. beim <code>scp</code> Befehl (der Dateien über ssh kopiert) die <a href="http://blog.pimpmyshell.de/2007/01/21/ssh-completion-mit-zsh/" title="ssh completion mit zsh" target="_blank" class="liexternal">Verzeichnisse auf dem entfernten Rechner vervollständigen</a> und genau definieren welche Programme mit welchen Dateitypen zusammen arbeiten können. Für sehr viele Programme ist dies schon vorgefertigt, so dass ein</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">latex doku<span style="color: #000000; font-weight: bold;">&lt;</span>TAB<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>automatisch zu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> latex dokument.tex</pre></div></div>

<p>vervollständigt wird. Dies beherrscht die Bash zum Teil auch. Jedoch ist es in der zsh wesentlich besser konfigurierbar und anpassbar.</p>
<p>Sehr praktisch finde ich auch die Menüfunktion. So wird beim ersten Druck auf die TAB-Taste wie in der Bash soweit vervollständigt, bis nicht mehr entschieden werden kann welche Datei (bzw. welcher Befehl) gemeint ist. Ein weiterer Druck auf die TAB-Taste listet alle weiteren Möglichkeiten auf und jeder weitere Druck geht diese Möglichkeiten durch. Wenn ich also drei Dateien habe: <code>test.txt</code>, <code>testfile1.txt</code> und <code>testfile2.txt</code> und gebe folgendes ein:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> te<span style="color: #000000; font-weight: bold;">&lt;</span>TAB<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>so wird zuerst auf <code>test</code> vervollständigt. Ein weiterer Druck gibt mir alle Möglichkeiten aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">testfile1.txt  testfile2.txt  test.txt</pre></div></div>

<p>und ein dritter Druck auf die Tab-Taste vervollständigt den Befehl zu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> testfile1.txt</pre></div></div>

<p>Das ist viel schneller als erst ein <code>f</code> einzugeben um erneut TAB zu drücken und dann die <code>1</code> einzugeben um wiederum TAB zu drücken bis der Dateiname endgültig vervollständigt wird.</p>
<p>Ein weiterer Druck auf TAB nimmt dann die nächste Möglichkeit. In diesem Beispiel also</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> testfile2.txt</pre></div></div>

<p>und so weiter.</p>
<p><strong>Expansion</strong><br />
Mit der TAB-Taste kann man in der zsh nicht nur Kommandos, Dateinamen, &#8230; vervollständigen, sondern auch Variablen expandieren. Viele kennen ja die spezielle Variable <code>!!</code>, die den zuletzt ausgeführten Befehl enthält. In der zsh kann man nun folgendes eingeben:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">!!&lt;</span>TAB<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>und die Variable <code>!!</code> wird automatisch zum zuletzt ausgeführten Befehl expandiert. Genauso kann man auch jede andere Variable expandieren:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">&lt;</span>TAB<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>wird zu <code>/home/zimon/developement</code> (vorrausgesetzt ich befinde mich zum Zeitpunkt der expansion in diesem Verzeichnis).</p>
<p><strong>History Kontrolle</strong><br />
Wie bei der Bash auch, kann man in der zsh die History durchsuchen. Die zsh geht jedoch so weit, dass man auch nach bestimmten Parametern suchen kann. Ein Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>perl<span style="color: #000000; font-weight: bold;">/</span>foo.pl ~<span style="color: #000000; font-weight: bold;">/</span>developement<span style="color: #000000; font-weight: bold;">/</span>projektordner</pre></div></div>

<p>Danach kommen ein paar andere Kommandos. Möchte nun eine andere Datei in den gleichen Projektordner kopieren reicht folgende Eingabe:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>perl<span style="color: #000000; font-weight: bold;">/</span>bar.pl <span style="color: #000000; font-weight: bold;">!</span>?proj?:<span style="color: #000000;">3</span></pre></div></div>

<p>Mit !? wird nach einem vorherigen Befehl gesucht. Das <code>proj</code> ist ein String der in diesem Befehl vorkam. Mit dem <code>?:3</code> wird das dritte Argument genutzt. Durch die Expansion kann manmit durch einen Druck auf TAB diesen Ausdruck auch noch expandieren um sicher zu gehen, dass das richtige Argument ausgewählt wurde. Man kann zwar mit Alt+. wie in der Bash die jeweils letzten Argumente durchgehen, auf diese Weise kann man aber auch das zweite von drei Argumenten suchen.</p>
<p>Es gibt noch wesentlich mehr Möglichkeiten die History zu durchsuchen und zu verwenden.</p>
<p><strong>Hochkonfigurierbarer Prompt</strong><br />
In der Z-Shell kann man nicht nur die linke Seite des Prompts sondern auch die rechte Seite konfigurieren. Als Beispiel hier mal mein aktueller Prompt:</p>
<div id="attachment_1679" class="wp-caption aligncenter" style="width: 643px"><a href="http://zinformatik.de/wp-content/uploads/2010/01/zsh_prompt.png" ><img class="size-full wp-image-1679" title="zsh Prompt" src="http://zinformatik.de/wp-content/uploads/2010/01/zsh_prompt.png" alt="zsh Prompt" width="633" height="37" /></a><p class="wp-caption-text">Mein aktueller zsh-Prompt</p></div>
<p>Ich finde die Anzeige der Uhrzeit inklusive Sekunden recht praktisch, da man daran sieht wie lange ein Befehl gedauert hat oder wann man ihn ausgeführt hat. Es gibt jedoch auch die Möglichkeit automatisch die Ausgabe von <code>time</code> bei der Beendigung eines Befehls ausgeben zu lassen, der länger als eine vorher definierte Zeit benötigt hat.</p>
<p>Der Prompt ist eine abgeänderte Version von <a href="http://aperiodic.net/phil/prompt/" title="Phil!s ZSH Prompt" target="_blank" class="liexternal">Phil!s ZSH Prompt</a>.</p>
<p><strong>[UPDATE]</strong> Auf Anfrage hin ist hier noch der Code für die von mir abgeänderte Version des Prompts:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">setprompt <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># Need this so the prompt will work.</span>
&nbsp;
    setopt prompt_subst
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># See if we can use colors.</span>
&nbsp;
    autoload colors zsh<span style="color: #000000; font-weight: bold;">/</span>terminfo
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$terminfo</span>[colors]&quot;</span> <span style="color: #660033;">-ge</span> <span style="color: #000000;">8</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	colors
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">for</span> color <span style="color: #000000; font-weight: bold;">in</span> RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #7a0874; font-weight: bold;">eval</span> PR_<span style="color: #007800;">$color</span>=<span style="color: #ff0000;">'%{$terminfo[bold]$fg[${(L)color}]%}'</span>
	<span style="color: #7a0874; font-weight: bold;">eval</span> PR_LIGHT_<span style="color: #007800;">$color</span>=<span style="color: #ff0000;">'%{$fg[${(L)color}]%}'</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> count = <span style="color: #007800;">$count</span> + <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #007800;">PR_NO_COLOUR</span>=<span style="color: #ff0000;">&quot;%{<span style="color: #007800;">$terminfo</span>[sgr0]%}&quot;</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># See if we can use extended characters to look nicer.</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">typeset</span> <span style="color: #660033;">-A</span> altchar
    <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> altchar <span style="color: #800000;">${(s..)terminfo[acsc]}</span>
    <span style="color: #007800;">PR_SET_CHARSET</span>=<span style="color: #ff0000;">&quot;%{<span style="color: #007800;">$terminfo</span>[enacs]%}&quot;</span>
    <span style="color: #007800;">PR_SHIFT_IN</span>=<span style="color: #ff0000;">&quot;%{<span style="color: #007800;">$terminfo</span>[smacs]%}&quot;</span>
    <span style="color: #007800;">PR_SHIFT_OUT</span>=<span style="color: #ff0000;">&quot;%{<span style="color: #007800;">$terminfo</span>[rmacs]%}&quot;</span>
    <span style="color: #007800;">PR_HBAR</span>=<span style="color: #800000;">${altchar[q]:--}</span>
    <span style="color: #007800;">PR_ULCORNER</span>=<span style="color: #800000;">${altchar[l]:--}</span>
    <span style="color: #007800;">PR_LLCORNER</span>=<span style="color: #800000;">${altchar[m]:--}</span>
    <span style="color: #007800;">PR_LRCORNER</span>=<span style="color: #800000;">${altchar[j]:--}</span>
    <span style="color: #007800;">PR_URCORNER</span>=<span style="color: #800000;">${altchar[k]:--}</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> == <span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">PR_HBAR</span>=-
     	<span style="color: #007800;">PR_ULCORNER</span>=--
    	<span style="color: #007800;">PR_LLCORNER</span>=--
    	<span style="color: #007800;">PR_LRCORNER</span>=--
    	<span style="color: #007800;">PR_URCORNER</span>=-
   <span style="color: #000000; font-weight: bold;">fi</span> 
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># Decide if we need to set titlebar text.</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$TERM</span> <span style="color: #000000; font-weight: bold;">in</span>
	xterm<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	    <span style="color: #007800;">PR_TITLEBAR</span>=$<span style="color: #ff0000;">'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'</span>
	    <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #c20cb9; font-weight: bold;">screen</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	    <span style="color: #007800;">PR_TITLEBAR</span>=$<span style="color: #ff0000;">'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'</span>
	    <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	    <span style="color: #007800;">PR_TITLEBAR</span>=<span style="color: #ff0000;">''</span>
	    <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># Decide whether to set a screen title</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> == <span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">PR_STITLE</span>=$<span style="color: #ff0000;">'%{\ekzsh\e\\%}'</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #007800;">PR_STITLE</span>=<span style="color: #ff0000;">''</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">###</span>
    <span style="color: #666666; font-style: italic;"># Finally, the prompt.</span>
&nbsp;
    <span style="color: #007800;">PROMPT</span>=<span style="color: #ff0000;">'$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
$PR_RED$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_GREEN%(!.%SROOT%s.%n)$PR_GREEN@%m:%l\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_RED$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_MAGENTA%$PR_PWDLEN&lt;...&lt;%~%&lt;&lt;\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_RED$PR_URCORNER$PR_SHIFT_OUT\
&nbsp;
$PR_RED$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
${(e)PR_APM}$PR_YELLOW%D{%H:%M:%S}\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_RED$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_NO_COLOUR '</span>
&nbsp;
    <span style="color: #007800;">RPROMPT</span>=<span style="color: #ff0000;">' $PR_RED$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_RED$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'</span>
&nbsp;
    <span style="color: #007800;">PS2</span>=<span style="color: #ff0000;">'$PR_RED$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_RED$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
setprompt</pre></div></div>

<p><strong>[/UPDATE]</strong></p>
<p><strong>ZLE-Widgets</strong><br />
Der Z-Line-Editor (ZLE) ist quasi die Eingabezeile in der zsh. Dafür kann man sich kleine Programme schreiben, die einem das Leben vereinfachen. Ein Beispiel wäre ein Programm, dass bei der Eingabe von <code>...</code> diese zu <code>../..</code> umwandelt. Jeder weitere Punkt wird wieder umgewandelt. So kann man recht einfach folgendes eingeben:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ....<span style="color: #000000; font-weight: bold;">/</span>directory</pre></div></div>

<p>Auf dem Bildschirm erscheint jedoch folgendes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>directory</pre></div></div>

<p>Dieses Widget ist kein Standard bei der Z-Shell. Man kann es aber durch folgenden Code in der Konfigurationsdatei <code>~/.zshrc</code> erzeugen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rationalise-dot<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$LBUFFER</span> = <span style="color: #000000; font-weight: bold;">*</span>.. <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        LBUFFER+=<span style="color: #000000; font-weight: bold;">/</span>..
    <span style="color: #000000; font-weight: bold;">else</span>
        LBUFFER+=.
            <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
zle <span style="color: #660033;">-N</span> rationalise-dot
bindkey . rationalise-dot</pre></div></div>

<p><strong>Automatisches tee-ing</strong><br />
In der Z-Shell kann man die Ausgabe eines Kommandos recht einfach in mehrere verschiedene Dateien umleiten. Statt wie in der Bash</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #660033;">-a</span> all <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> actual</pre></div></div>

<p>zu schreiben, kann man in der zsh einfach</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span>all <span style="color: #000000; font-weight: bold;">&gt;</span>actual</pre></div></div>

<p>eingeben. Beide Befehle führen ls aus und hängen die Ausgabe an die Datei <code>all</code> an und schreiben sie in die Datei <code>actual</code> wobei der inhalt jeweils überschrieben wird.<br />
Möchte man die Ausgabe wie beim original <code>tee</code> Befehl auch auf dem Bildschirm sehen, so leitet man sie auch noch auf STDOUT um:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span>all <span style="color: #000000; font-weight: bold;">&gt;</span>actual <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p><strong>Verzeichnisse durch Ersetzung wechseln</strong><br />
Ein Beispiel sollte dies am besten Erklären. Man nehme an man hat zwei Verzeichnisse: <code>~/developement/scripting/perl/modules</code> und <code>~/developement/scripting/python/modules</code> und man befindet sich in <code>~/developement/scripting/perl/modules</code>, so kann man durch den Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> python</pre></div></div>

<p>in das Verzeichnis <code>~/developement/scripting/python/modules</code> wechseln. Bei einem <code>cd</code> Kommando mit zwei Parametern wird im aktuellen Verzeichnis-String das erste Wort durch das zweite ersetzt. Hier also <code>perl</code> durch <code>python</code>.</p>
<p><strong>Fazit</strong><br />
Ich bin jetzt nicht 100% sicher, dass alles hier beschriebene nicht auch in der Bash möglich ist. Es zeigt aber auf jeden Fall, dass die Z-Shell jede Menge interessante Möglichkeiten bietet und man viele Dinge einfacher und schneller erledigen kann als in der Bash. Die oben gezeigten Features sind meist nur angerissen und nur eine kleine Auswahl von dem was die Z-Shell bietet. Darüber hinaus besitzt die Z-Shell eine ganze Reihe Module z.B. für Matheoperationen oder einen eigenen FTP-Client, die man bei Bedarf laden kann.</p>
<p>Sehr schön ist auch die Möglichkeit den <a href="http://zinformatik.de/linux/titel-von-screen-fenstern-automatisch-von-vim-bash-und-zsh-setzen/" title="Titel von Screen Fenstern automatisch von vim, Bash und zsh setzen" target="_self" class="liinternal">Screen-Title von der zsh aus zu setzen</a>.</p>
<p>Es lohnt sich auf jeden Fall, diese Shell etwas genauer zu betrachten. Bei mir hat sie mittlerweile die Bash fast vollständig ersetzt (vorhandene Scripte habe ich nicht umgeschrieben).</p>
<p><strong>Links</strong></p>
<ul>
<li><a href="http://zsh.sourceforge.net/" title="Offizielle zsh Projektseite" target="_blank" class="liexternal">Offizielle zsh Projektseite</a> (englisch)</li>
<li><a href="http://zsh.sourceforge.net/Doc/Release/zsh_toc.html" title="zsh Manual" target="_blank" class="liexternal">zsh Manual</a> (englisch)</li>
<li><a href="http://zsh.sourceforge.net/Guide/zshguide.html" title="zsh Users Guide" target="_blank" class="liexternal">zsh User&#8217;s Guide</a> (englisch)</li>
<li><a href="http://michael-prokop.at/computer/tools_zsh.html" title="zsh generell" target="_blank" class="liexternal">Michael Prokops zsh Seite</a> &#8211; Seite mit Features und Beispielen wo zsh mit Bash verglichen wird</li>
<li><a href="http://michael-prokop.at/computer/tools_zsh_liebhaber.html" title="zsh liebhaber" target="_blank" class="liexternal">Michael Prokops zsh Liebhaberseite</a> &#8211; Viele gute Beispiele und zsh Tricks angelehnt an das zsh-lovers Projekt.</li>
<li><a href="http://zshwiki.org" title="zsh wiki" target="_blank" class="liexternal">zsh wiki</a> &#8211; Wiki über zsh (englisch)</li>
<li><a href="http://grml.org/zsh/zsh-lovers.html" title="zsh-lovers" target="_blank" class="liexternal">zsh-lovers</a> &#8211; Sammlung von Tipps, Tricks und Beispielen (englisch)</li>
<li><a href="http://grml.org/zsh/" target="_blank" class="liexternal">grml zsh Seite</a> &#8211; Seite mit sehr großer zsh-Konfigurationsdatei, Referenzkarte und anderen zsh Infos. Die grml-Linuxdistribution hat zsh als Standardshell. (englisch)</li>
<li><a href="http://www.strcat.de/zsh/" title="stcats zsh Page" target="_blank" class="liexternal">strcat.de/zsh/</a> &#8211; Seite mit Auflistung vieler Features und Tipps (englisch)</li>
<li><a href="http://rayninfo.co.uk/tips/zshtips.html" title="Best of zsh Tips" target="_blank" class="liexternal">Zzappers Best of ZSH Tips</a> &#8211; Viele zsh Tipps (englisch)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/die-z-shell-zsh-eine-machtige-alternative-zur-bash/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Gimp 2.7 mit Single-Window-Mode installieren</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/gimp-2-7-mit-single-window-mode-installieren/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/gimp-2-7-mit-single-window-mode-installieren/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 17:33:11 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Interessante Programme]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[Single-Window-Mode]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1644</guid>
		<description><![CDATA[<p>Ab der nächsten Version von Gimp (2.8) gibt es endlich auch die Möglichkeit des Einfenster-Betriebs. <div id="attachment_1645" class="wp-caption alignright" style="width: 310px"><a href="http://zinformatik.de/wp-content/uploads/2009/12/gimp_screen.png" ><img class="size-medium wp-image-1645" title="gimp_screenshot" src="http://zinformatik.de/wp-content/uploads/2009/12/gimp_screen-300x215.png" alt="Screenshot des Single-Window Modus von Gimp 2.7" width="300" height="215" /></a><p class="wp-caption-text">Screenshot des Single-Window Modus von Gimp 2.7</p></div><br />
Im Moment gibt es in Gimp je ein Fenster für jedes geöffnete Bild und zusätzlich ein Fenster mit den Werkzeugen (Werkzeugkasten) sowie bei Bedarf auch Dialogfenster für Ebenen, Pfade, &#8230; Der Umgang mit&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Ab der nächsten Version von Gimp (2.8) gibt es endlich auch die Möglichkeit des Einfenster-Betriebs. <div id="attachment_1645" class="wp-caption alignright" style="width: 310px"><a href="http://zinformatik.de/wp-content/uploads/2009/12/gimp_screen.png" ><img class="size-medium wp-image-1645" title="gimp_screenshot" src="http://zinformatik.de/wp-content/uploads/2009/12/gimp_screen-300x215.png" alt="Screenshot des Single-Window Modus von Gimp 2.7" width="300" height="215" /></a><p class="wp-caption-text">Screenshot des Single-Window Modus von Gimp 2.7</p></div><br />
Im Moment gibt es in Gimp je ein Fenster für jedes geöffnete Bild und zusätzlich ein Fenster mit den Werkzeugen (Werkzeugkasten) sowie bei Bedarf auch Dialogfenster für Ebenen, Pfade, &#8230; Der Umgang mit so vielen Fenstern ist auf kleinen Bildschirmen recht umständlich, da oft ein Fenster im Weg steht und man es zuerst weg schieben muss. Daher freuen sich schon viele Nutzer auf den Einfenster Modus, bei dem Bilder als Tabs angezeigt werden und die restlichen Fenster links und rechts neben dem Bild angeordnet werden. Dialogfenster können jedoch immer noch heraus gezogen und als eigenes Fenster angezeigt werden.</p>
<p>Es gibt jedoch auch Beführworter des Multi-Window Modus, da man mehrere Fenster leichter auf verschiedene Bildschirme verteilen kann.</p>
<p>Ich habe mir mal die Entwicklerversion (2.7) installiert und (vor allem den Single-Window Modus <img src='http://zinformatik.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) angesehen.</p>
<p><strong>Installation</strong></p>
<p>Zuerst müssend die <code>build-utils</code>, <code>git</code> sowie einige Abhängigkeiten installiert werden. Unter Ubuntu kann man dies mit dem folgenden Befehl erreichen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> build-dep <span style="color: #c20cb9; font-weight: bold;">gimp</span> libtool ruby git-core git-doc git-email</pre></div></div>

<p>Als nächstes wird git konfiguriert. Dafür die folgenden beiden Befehle ausführen, wobei beim ersten Befehl der Name eingegeben wird und beim zweiten die Emailadresse:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git config <span style="color: #660033;">--global</span> user.name <span style="color: #ff0000;">&quot;Your Name&quot;</span>
git config <span style="color: #660033;">--global</span> user.email you<span style="color: #000000; font-weight: bold;">@</span>host</pre></div></div>

<p>Nun werden die aktuellen Entwickerversionen von babl, gegl und gimp ausgecheckt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git clone git:<span style="color: #000000; font-weight: bold;">//</span>git.gnome.org<span style="color: #000000; font-weight: bold;">/</span>babl
git clone git:<span style="color: #000000; font-weight: bold;">//</span>git.gnome.org<span style="color: #000000; font-weight: bold;">/</span>gegl
git clone git:<span style="color: #000000; font-weight: bold;">//</span>git.gnome.org<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">gimp</span></pre></div></div>

<p>Um eine bereits installiertes Gimp weiter benutzen zu können, wird die Entwicklerversion in das Verzeichnis <code>/usr/local/gimp-git</code> installiert.<br />
Dafür wird dieses Verzeichnis angelegt und dort ein Verzeichnis share erstellt. Nun legt man die Datei <code>/usr/local/gimp-git/share/config.site</code> mit folgendem Inhalt an:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PKG_CONFIG_PATH</span>=<span style="color: #ff0000;">&quot;/usr/local/gimp-git/lib/pkgconfig:<span style="color: #007800;">$PKG_CONFIG_PATH</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #ff0000;">&quot;/usr/local/gimp-git/lib:<span style="color: #007800;">$LD_LIBRARY_PATH</span>&quot;</span></pre></div></div>

<p>Wenn es Probleme gibt, dass die neueste babl-Version nicht gefunden werden kann, können die beiden Befehle auch nochmal in der aktuellen Shell ausgeführt werden.</p>
<p>Die Leserechte müssen auch noch entsprechend gesetzt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> oug+rx <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git
<span style="color: #c20cb9; font-weight: bold;">chmod</span> oug-x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>config.site</pre></div></div>

<p>Nun werden babl, gegl und schließlich gimp selbst kompiliert und installiert:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> babl
.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>gegl
.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #c20cb9; font-weight: bold;">gimp</span>
.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git <span style="color: #660033;">--disable-gtk-doc</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Nun kann man gimp-2.7 mit folgendem Befehl starten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>gimp-git<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gimp-<span style="color: #000000;">2.7</span></pre></div></div>

<p>Ein Alias in der <code>~/.bashrc</code> erleichtert den Aufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> gimp-git=<span style="color: #ff0000;">'/usr/local/gimp-git/bin/gimp-2.7'</span></pre></div></div>

<p><b>Single-Window-Mode</b></p>
<p>Nachdem ich alle Menüs in den Einstellungen durchforstet habe und auch in einige Konfigurationsdateien geschaut habe, habe ich die Funktion für den Single-Window-Mode schließlich unter dem Menüpunkt &#8220;Fenster&#8221; gefunden.</p>
<p>Es sieht schon ziemlich schick aus. Auch wenn viele Kleinigkeiten noch nicht so richtig Funktionieren. Wenn die Dialoge an der Seite sind, reagieren sie manchmal nicht (oder nur teilweise). Abhilfe schaft auch manchmal den Modus wieder zurück zu wechseln und erneut in den Single-Window Modus zu wechseln. Versucht man einen Dialog unter den Werkzeugkasten (oder an eine andere Stelle an der Seite) zu platzieren, stürzt das ganze Programm mit einem segmentation fault ab. </p>
<p>Im Moment ist es noch sehr emfehlenswert, bei der Version 2.6 zu bleiben und die Entwicklerversion nur zum Ausprobieren zu nutzen. Dies gilt besonders für den Single-Window Modus, da dieser noch nicht sehr stabil läuft. Das wird sich aber sicherlich in der nächsten Zeit noch ändern.</p>
<p><strong>[UPDATE]</strong>Mittlerweile funktioniert der Single-Window Modus recht gut und stabil, so dass man ihn nun verwenden kann. Man sollte jedoch im Hinterkopf behalten, dass sich das Programm noch im Entwicklungsstadium befindet und Fehler auftreten können.</p>
<p>Übrigens soll Gimp 2.8 frühestens Ende des Jahres (2010) erscheinen, wie man der <a href="http://www.mail-archive.com/gimp-developer@lists.xcf.berkeley.edu/msg19390.html" target="_blank" title="Gimp 2.8 Schedule" class="liexternal">Developer-Mailingliste</a> entnehmen kann.<strong>[/UPDATE]</strong></p>
<p>Den Screenshot in voller Auflösung habe ich <a href="http://zinformatik.de/gimp_screen_big.png" class="liinternal">hier</a> verlinkt (am besten in einem nuen Tab oder Fenster öffnen).</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/gimp-2-7-mit-single-window-mode-installieren/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Erinnerungen mit at und zenity</title>
		<link>http://zinformatik.de/linux/erinnerungen-mit-at-und-zenity/</link>
		<comments>http://zinformatik.de/linux/erinnerungen-mit-at-und-zenity/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 17:59:53 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[at]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Erinnerung]]></category>
		<category><![CDATA[Konsole]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[zenity]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1619</guid>
		<description><![CDATA[<p>Wenn man am PC sitzt vergisst man schnell die Zeit. Wenn man noch etwas erledigen muss wäre es daher vorteilhaft, wenn man daran erinnert werden würde. </p>
<p>Ein solches &#8220;Erinnerungsprogramm&#8221; kann man sich recht leicht selber basteln. Ich habe dafür  das Linuxtool <code>at</code> mit dem Programm <a href="http://wiki.ubuntuusers.de/Zenity" target="_blank" title="zenity - Darstellung von Dialogen" class="liuu"><code>zenity</code></a>, welches Dialoge darstellen kann, kombiniert.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Wenn man am PC sitzt vergisst man schnell die Zeit. Wenn man noch etwas erledigen muss wäre es daher vorteilhaft, wenn man daran erinnert werden würde. </p>
<p>Ein solches &#8220;Erinnerungsprogramm&#8221; kann man sich recht leicht selber basteln. Ich habe dafür  das Linuxtool <code>at</code> mit dem Programm <a href="http://wiki.ubuntuusers.de/Zenity" target="_blank" title="zenity - Darstellung von Dialogen" class="liuu"><code>zenity</code></a>, welches Dialoge darstellen kann, kombiniert.</p>
<p><code>at</code> (bzw. der at-Daemon <code>atd</code>) ist auf den meisten Linuxdistributionen bereits vorhanden, kann sonst aber auch über die Paketverwaltung installiert werden. Zenity sollte bei den meisten Distributionen ebenfalls über die Paketverwaltung installierbar sein.<br />
Unter Ubuntu installiert man <code>zenity</code> mit dem Befehl:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> zenity</pre></div></div>

<p>Mit <code>at</code> können Befehle zu einem festgelegten Zeitpunkt ausgeführt werden. Eine sehr schöne Einführung gibt es in der <a href="http://www.freiesmagazin.de/mobil/freiesMagazin-2008-10-bilder.html#08_10_at" target="_blank" title="freiesMagazin 10/2008 - at" class="liexternal">Ausgabe 10/2008 von freiesMagazin</a> (eine Fortsetzung ist in der <a href="http://www.freiesmagazin.de/mobil/freiesMagazin-2008-11-bilder.html#08_11_at-beispiele" target="_blank" class="liexternal">nachfolgenden Ausgabe</a> enthalten, welche mich auch zu diesem &#8220;Programm&#8221; inspirierte, weil ich mit den dort vorgestellten Erinnerungs-Lösungen nicht zufrieden war).</p>
<p>Um mit <code>zenity</code> einen Dialog anzuzeigen kann man folgenden Befehl nutzen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zenity <span style="color: #660033;">--info</span> <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Titel des Dialogs&quot;</span> <span style="color: #660033;">--text</span> <span style="color: #ff0000;">&quot;Text, der angezeigt werden soll&quot;</span></pre></div></div>

<p>Damit dies von <code>at</code> angezeigt werden kann muss noch das Display angegeben werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zenity <span style="color: #660033;">--info</span> <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Titel des Dialogs&quot;</span> <span style="color: #660033;">--text</span> <span style="color: #ff0000;">&quot;Text, der angezeigt werden soll&quot;</span> <span style="color: #660033;">--display</span>=:<span style="color: #000000;">0</span></pre></div></div>

<p>Diesen Befehl kann man nun in ein Bash- oder Perl-Script einfügen, wobei der Titel fest sein kann und der Text als Argument übergeben wird. Ich habe mich für Perl entschieden:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;zenity --info --title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Erinnerung<span style="color: #000099; font-weight: bold;">\&quot;</span> --text <span style="color: #000099; font-weight: bold;">\&quot;</span>@ARGV<span style="color: #000099; font-weight: bold;">\&quot;</span> --display=:0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Dieses Script habe ich unter dem Namen <code>r</code> (für &#8220;remember&#8221;) im bin-Ordner meines Homeverzeichnisses gespeichert. Dieses muss natürlich im Pfad liegen, was durch folgende Zeile in der Datei <code>~/.bashrc</code> erreicht werden kann:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p>&#8220;user&#8221; muss natürlich durch den entsprechenden Usernamen ersetzt werden. Nachdem man die <code>~/.bashrc</code> mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">. ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc</pre></div></div>

<p>neu &#8220;geladen&#8221; hat kann man sich nun an Termine oder andere Dinge erinnern lassen.</p>
<p><strong>Beispiele:</strong><br />
Um 14:30 Termin bei FooBar. Also um 14:15 erinnern:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">at 14:15
r Termin bei FooBar in 15 Minuten
Strg+d</pre></div></div>

<p>In einer halben Stunde ist eine Besprechung (5 min vorher erinnern):</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">at now +25min
r Besprechung
Strg+d</pre></div></div>

<p>Es öffnet sich zur angegebenen Zeit ein Dialogfenster (egal, was man gerade macht &#8211; solange man sich in X befindet. Bei Spielen im Fullscreen habe ich es jedoch nicht getestet.), welches den Titel &#8220;Erinnerung&#8221; enthält und den angegebenen Text ausgibt. Das Fenster kann durch einen Klick auf &#8220;OK&#8221; wieder geschlossen werden.</p>
<p><code>at</code> bietet noch viele weitere Möglichkeiten eine Zeit anzugeben. Diese werden im (ersten) oben verlinkten freiesMagazin-Artikel beschrieben.</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/erinnerungen-mit-at-und-zenity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Titel von Screen-Fenstern automatisch von Vim, Bash und zsh setzen</title>
		<link>http://zinformatik.de/linux/titel-von-screen-fenstern-automatisch-von-vim-bash-und-zsh-setzen/</link>
		<comments>http://zinformatik.de/linux/titel-von-screen-fenstern-automatisch-von-vim-bash-und-zsh-setzen/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 09:34:51 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[vim Tipps]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Konsole]]></category>
		<category><![CDATA[Screen]]></category>
		<category><![CDATA[Titel]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1605</guid>
		<description><![CDATA[<p>Wenn man unter <a href="http://zinformatik.de/tipps-tricks/interessante-programme/einfuhrung-in-screen/" title="Einführung in Screen" target="_blank" class="liinternal">Screen</a> die Statusleiste nutzt, ist es oft mühsam jedes mal die Titel zu setzen. Auch wenn man diese fest in der <code>~/.screenrc</code> definiert, kann man manchmal durcheinander kommen.</p>
<p>Unter Vim gibt es die Möglichkeit, den Namen der aktuellen Datei als Titel für das Screenfenster zu benutzen.<br />
Dafür braucht man nur&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Wenn man unter <a href="http://zinformatik.de/tipps-tricks/interessante-programme/einfuhrung-in-screen/" title="Einführung in Screen" target="_blank" class="liinternal">Screen</a> die Statusleiste nutzt, ist es oft mühsam jedes mal die Titel zu setzen. Auch wenn man diese fest in der <code>~/.screenrc</code> definiert, kann man manchmal durcheinander kommen.</p>
<p>Unter Vim gibt es die Möglichkeit, den Namen der aktuellen Datei als Titel für das Screenfenster zu benutzen.<br />
Dafür braucht man nur die folgenden Zeilen zur <code>~/.vimrc</code> hinzufügen:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">if</span> <span style="color: #25BB4D;">expand</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'$TERM'</span><span style="color: #000000;">&#41;</span> == <span style="color: #C5A22D;">'screen'</span>
augroup vim_screen
  <span style="color: #668080;">autocmd</span><span style="color: #000000;">!</span>
  <span style="color: #668080;">autocmd</span> VimEnter,BufWinEnter,WinEnter <span style="color: #000000;">*</span>
    \ <span style="color: #804040;">exec</span> <span style="color: #C5A22D;">&quot;silent! !echo -ne '<span style="">\\</span>ek&quot;</span> <span style="color: #000000;">.</span> <span style="color: #25BB4D;">expand</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'%:t'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">.</span> <span style="color: #C5A22D;">&quot;<span style="">\\</span>e<span style="">\\</span><span style="">\\</span>'&quot;</span>
augroup END
<span style="color: #804040;">endif</span></pre></div></div>

<p><strong>[UPDATE]</strong>Auf dem <a href="http://blog.256bit.org/archives/451-Vim-in-Screen.html" title="Vim in Screen" target="_blank" class="liexternal">256bit Blog</a> beschreibt Christian Brabandt, wie man den Screen-Titel von Vim aus ohne autocommands und mit sehr vielen Einstellungen setzen kann.<strong>[/UPDATE]</strong></p>
<p>Ansonsten finde ich es sehr praktisch, wenn in der Statusleiste das aktuelle Verzeichnis steht. Da der komplette Pfad meist sehr lang ist, können mit einem regulären Ausdruck alle Verzeichnisse bis auf das letzte jeweils mit ihren Anfangsbuchstaben abgekürzt werden:</p>
<p><code>s/(\w).*?\//$1\//g</code></p>
<p>So wird <code>/home/zimon/.vim/plugin</code> zu <code>/h/z/.v/plugin</code> abgekürzt.</p>
<p>Wem das immer noch zu lang ist, der kann aus dem Namen des letzten Verzeichnisses auch noch die Vokale heraus nehmen (ähnlich wie es dillo in seinen Tabs macht):</p>
<p><code>s/(\w).*?\//$1\//g; my $end; $x=~s/\/(.)(?:[aeiou]|([^aeiou\/])(?{$end.=$^N}))*\s*$/\/$1$end/</code></p>
<p>Damit wird <code>/home/zimon/.vim/plugin</code> zu <code>/h/z/.v/plgn</code></p>
<p>Um in der Bash den Screen-Titel automatisch zu setzen, kann man folgenden Code zu seiner <code>~/.bashrc</code> hinzufügen. Hier wurde der erste reguläre Ausdruck genutzt (man kann ihn natürlich auch durch den anderen Ausdruck ersetzen, wenn man möchte):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> precmd <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        <span style="color: #c20cb9; font-weight: bold;">screen</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">wd</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'$x=shift; $x=~ s/(\w).*?\//$1\//g; print $x;'</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PWD</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;\033k<span style="color: #007800;">$wd</span>\033\<span style="color: #000099; font-weight: bold;">\&quot;</span>
        ;;
    esac
}
PROMPT_COMMAND=precmd</span></pre></div></div>

<p>Für zsh User gibt es hier den Code für die <code>~/.zshrc</code>. In diesem Beispiel wurde der zweite reguläre Ausdruck genutzt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> precmd <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> == <span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">wd</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'$x=shift; $ x=~ s/(\w).*?\//$1\//g; my $end; $x=~s/\/(.)(?:[aeiou]|([^aeiou\/])(?{$end.=$^N}))*\s*$/\/$1$end/; print $x;'</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PWD</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">PR_STITLE</span>=$<span style="color: #ff0000;">'%{\ek'</span><span style="color: #007800;">$wd</span>$<span style="color: #ff0000;">'\e\\%}'</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Vielen Dank an <a href="http://zinformatik.de/author/ploppor/" target="_self" class="liinternal">Ploppor</a> für den zsh Code und sonstige zahlreiche Unterstützung in letzter Zeit.</p>
<p>Es tut mir leid, dass ich in letzter Zeit nichts geschrieben habe, aber meine Diplomarbeit lässt mir einfach keine Zeit.</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/titel-von-screen-fenstern-automatisch-von-vim-bash-und-zsh-setzen/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Vim Plugin &#8211; VCSCommand zur Versionsverwaltung mittels SVN und CVS</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-vcscommand-zur-versionsverwaltung-mittels-svn-und-cvs/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-vcscommand-zur-versionsverwaltung-mittels-svn-und-cvs/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 10:24:51 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Plugins und Erweiterungen]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[vim Tipps]]></category>
		<category><![CDATA[CVS]]></category>
		<category><![CDATA[Repository]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Versionsverwaltung]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1585</guid>
		<description><![CDATA[<p>Mit dem Plugin <a href="http://www.vim.org/scripts/script.php?script_id=90" title="Vim Plugin - VCSCommand" target="_blank" class="liexternal">VCSCommand</a> kann man Dateien und Verzeichnisse direkt von Vim aus über ein SVN- oder CVS-Repository verwalten. Ich werde hier jedoch nur SVN behandeln, da ich momentan nur dieses System nutze.</p>
<p>Nachdem man die Dateien des Plugins nach <code>~/.vim/plugin/</code> kopiert hat, kann man die Befehle <code>:VCSUpdate</code> und <code>:VCSCommit</code>nutzen um die aktuelle&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Mit dem Plugin <a href="http://www.vim.org/scripts/script.php?script_id=90" title="Vim Plugin - VCSCommand" target="_blank" class="liexternal">VCSCommand</a> kann man Dateien und Verzeichnisse direkt von Vim aus über ein SVN- oder CVS-Repository verwalten. Ich werde hier jedoch nur SVN behandeln, da ich momentan nur dieses System nutze.</p>
<p>Nachdem man die Dateien des Plugins nach <code>~/.vim/plugin/</code> kopiert hat, kann man die Befehle <code>:VCSUpdate</code> und <code>:VCSCommit</code>nutzen um die aktuelle Datei zu Updaten bzw. seine Änderungen zu committen. Dafür muss die Datei jedoch bereits unter Versionskontrolle stehen.<br />
Beim Commit öffnet sich ein <a href="http://zinformatik.de/tipps-tricks/vim-tipps/unter-vim-mit-splitscreens-arbeiten/" title="Unter vim mit Splitscreens arbeiten" target="_self" class="liinternal">Splitscreen</a>, in den man die Logmessage eintragen kann. Mittels <code>:wq</code> oder <code>\cc</code> wird diese übernommen. Um ohne Logmessage zu Committen, kann man das Kommando mit einem Ausrufezeichen aufrufen: <code>:VCSCommit!</code>. </p>
<p>Es gibt auch Abkürzungen für die Kommandos. So kann man statt <code>:VCSCommit</code> auch den Befehl <code>\cc</code> nutzen, der das gleiche bewirkt. Genauso kann man mit <code>\cu</code> updaten.</p>
<p>Auch die anderen Kommandos sind im Prinzip die SVN Kommandos mit vorrangestelltem <em>VCS</em>. In Klammern steht jeweils die Kurzvariante:</p>
<ul>
<li><code>:VCSAdd</code> &#8211; (<code>\ca</code>) zum Hinzufügen von Dateien zum Repository</li>
<li><code>:VCSDelete</code> &#8211; (<code>\cD</code>) zum Löschen</li>
<li><code>:VCSStatus</code> &#8211; (<code>\cs</code>) um den Status der Datei anzuzeigen</li>
<li><code>:VCSDiff</code> &#8211; (<code>\cd</code>) um den Unterschied zur letzten Version anzuzgeigen</li>
<li><code>:VCSLog</code> &#8211; (<code>\cl</code>) zeigt die bereits getätigten commits mit ihren Logmessages an</li>
</ul>
<p>Statt <code>:VCSDiff</code> kann man auch <code>:VCSVimDiff</code> (<code>\cv</code>) nutzen um die Unterschiede mittels <a title="" href="" target="_self">Vimdiff</a> zu betrachten.</p>
<p>Um ganze Verzeichnisse mit dem CVSCommand-Plugin zu verwalten, kann man die <a href="http://zinformatik.de/tipps-tricks/vim-tipps/vim-als-dateibrowser-und-sftp-client/" titel="vim als Dateibrowser und (S)FTP-Client" target="_self" class="liinternal">Dateibrower-Funktion</a> des Vim nutzen und die entsprechenden Kommandos bei einem geöffneten Verzeichnis ausführen.</p>
<p>Es gibt natürlich noch weitere Kommandos und Einstellungsmöglichkeiten. Diese sind in der Hilfe näher beschrieben, die man mittels <code>:h vcscommand</code> aufrufen kann.</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-vcscommand-zur-versionsverwaltung-mittels-svn-und-cvs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scenariogenerator für VNUML</title>
		<link>http://zinformatik.de/linux/scenariogenerator-fur-vnuml/</link>
		<comments>http://zinformatik.de/linux/scenariogenerator-fur-vnuml/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 11:41:20 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[Generator]]></category>
		<category><![CDATA[Netzwerk]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[VNUML]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1558</guid>
		<description><![CDATA[<p>Vor einiger Zeit habe ich mal einen Scenariogenerator für <a href="http://zinformatik.de/tipps-tricks/interessante-programme/vnuml-ein-netzwerksimulator-mit-user-mode-linux/" title="VNUML - Ein Netzwerksimulator mit User-Mode-Linux" target="_self" class="liinternal">VNUML</a> geschrieben um schnell und einfach Scenariodateien für verschiedene Topologien erstellen zu können.</p>
<p>Dafür habe ich mir überlegt, was die wesentlichen Informationen sind um eine Netzwerktopologie zu beschreiben. Dies sind die existierenden Netze, die existierenden Router und welche Router an welche Netze&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Vor einiger Zeit habe ich mal einen Scenariogenerator für <a href="http://zinformatik.de/tipps-tricks/interessante-programme/vnuml-ein-netzwerksimulator-mit-user-mode-linux/" title="VNUML - Ein Netzwerksimulator mit User-Mode-Linux" target="_self" class="liinternal">VNUML</a> geschrieben um schnell und einfach Scenariodateien für verschiedene Topologien erstellen zu können.</p>
<p>Dafür habe ich mir überlegt, was die wesentlichen Informationen sind um eine Netzwerktopologie zu beschreiben. Dies sind die existierenden Netze, die existierenden Router und welche Router an welche Netze angeschlossen sind.<br />
Dem Generatorscript wird eine Datei mit diesen Informationen übergeben und erstellt daraus die VNUML-Scenariodatei. Über Variablen im Script kann gesteuert werden, welcher Kernel und welches Dateisystem verwendet werden soll und wie die einzelnen Router/Rechner-Definitionen aussehen sollen.</p>
<p><strong>Syntax</strong><br />
Die Syntax der übergebenen Dateien, die die Endung .zvf tragen müssen ist folgendermaßen:<br />
Leerzeilen sowie Zeilen, die mit <code>#</code> beginnen werden ignoriert.<br />
In der ersten Zeile stehen die Netze mit Komma getrennt (Leerzeichen sind nicht erlaubt)<br />
In den darauf folgenden Zeilen werden die Router definiert und angegeben, mit welchen Netzen sie verbunden sind. Am Anfang einer solchen Zeile steht jeweils zuerst der Name des Routers gefolgt von einem Leerzeichen. Danach werden alle angeschlossenen Netze mit Komma getrennt aufgelistet (Leerzeichen sind darin nicht erlaubt).</p>
<p><strong>Beispiel</strong><br />
Das folgende Beispiel definiert ein Scenario mit 3 Routern (r1, r2 und r3), die über 3 Netze (net1,net2 und net3) zu einem Dreieck verbunden sind:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;"># beispiel.zvf
net1,net2,net3
&nbsp;
r1 net1,net2
r2 net2,net3
r3 net3,net1</pre></div></div>

<p>Die Namenskonvention (<code>/net[0-9]+/</code> für Netze und <code>/r[0-9]+/</code> für Router) muss eingehalten werden, damit das Script funktioniert.<br />
Da keine Fehlerbehandlung implementiert ist, muss die Syntax exakt eingehalten werden.</p>
<p>Wenn man das Script mit <code>chmod a+x createscenario.pl</code> ausführbar gemacht hat, kann man die Scenariodatei <code>beispiel.xml</code> durch folgenden Aufruf erstellen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>createscenario.pl beispiel.zvf</pre></div></div>

<p><strong>Download</strong><br />
Hier das Perlscript zum downloaden:</p>
<p><a href="http://zinformatik.de/wp-content/uploads/2009/07/createscenario.txt" class="liinternal">createscenario.pl</a></p>
<p>Irgendwie gibt es Probleme, wenn ich eine .pl Datei direkt verlinke. Daher habe ich sie in <code>createscenario.txt</code> umbenannt. Nach dem Download sollte die Datei also mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> createscenatio.txt createscenatio.pl</pre></div></div>

<p>umbenannt werden.</p>
<p>Es können Maximal 254 Netze und 254 Router erstellt werden. Die IP-Adressen werden nach folgendem Schema vergeben:<br />
10.0.NETZNUMMER.ROUTERNUMMER wobei ROUTERNUMMER pro Netz hoch gezählt wird und nicht der Nummer des Routernamens entspricht (die Netznummer hingegen ist auch die Nummer aus dem Namen des Netzes).</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/scenariogenerator-fur-vnuml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vim &#8211; Buffer statt Tabs benutzen</title>
		<link>http://zinformatik.de/tipps-tricks/vim-tipps/vim-buffer-statt-tabs-benutzen/</link>
		<comments>http://zinformatik.de/tipps-tricks/vim-tipps/vim-buffer-statt-tabs-benutzen/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 18:50:13 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[vim Tipps]]></category>
		<category><![CDATA[Buffer]]></category>
		<category><![CDATA[Tabs]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1545</guid>
		<description><![CDATA[<p>Das Buffer-Konzept von Vim ist ein wenig gewöhnungsbedürftig. Unter vim wird jede Datei in einem Buffer geöffnet. Man kann auch mehrere Dateien in verschiedenen Buffern öffnen und zwischen diesen Buffern hin- und herschalten. Die einzelnen geöffneten Buffer müssen dabei nicht sichtbar sein.</p>
<p>Das Problem bei <a href="http://zinformatik.de/tipps-tricks/vim-tipps/mit-tabs-arbeiten-unter-vim/" title="Mit Tabs arbeiten unter vim" target="_self" class="liinternal">Tabs</a> ist, dass wenn man z.B. Dateiübergreifende&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Das Buffer-Konzept von Vim ist ein wenig gewöhnungsbedürftig. Unter vim wird jede Datei in einem Buffer geöffnet. Man kann auch mehrere Dateien in verschiedenen Buffern öffnen und zwischen diesen Buffern hin- und herschalten. Die einzelnen geöffneten Buffer müssen dabei nicht sichtbar sein.</p>
<p>Das Problem bei <a href="http://zinformatik.de/tipps-tricks/vim-tipps/mit-tabs-arbeiten-unter-vim/" title="Mit Tabs arbeiten unter vim" target="_self" class="liinternal">Tabs</a> ist, dass wenn man z.B. Dateiübergreifende <a href="http://zinformatik.de/tipps-tricks/vim-tipps/markierungen-mit-vim-schnell-zu-beliebigen-stellen-einer-datei-springen/" title="Markierungen mit vim - schnell zu beliebigen Stellen einer Datei springen" target="_self" class="liinternal">Markierungen</a> nutzt der Sprung in eine andere Datei den entsprechenden Buffer im aktuellen Tab geöffnet wird. Selbst wenn die Datei in einem anderen Tab bereits geöffnet ist wird nicht zum Tab gesprungen. Wenn man hingegen nur mit Buffern statt Tabs arbeitet ist dieses Verhalten gewünscht.<br />
Auch bei <a href="http://zinformatik.de/tipps-tricks/vim-tipps/unter-vim-mit-splitscreens-arbeiten/" title="Unter vim mit Splitscreens arbeiten" target="_self" class="liinternal">Splitscreens</a> werden die Dateien in verschiedenen Buffern geladen. </p>
<p>Einen neuen Buffer öffnet man mit <code>:n &lt;DATEINAME&gt;</code>. Um den Buffer zu wechseln kann man entweder <code>:bn</code> (Buffer Next) und <code>:bp</code> (Buffer Previous) oder <code>:b&lt;NUMMER&gt;</code> nutzen, wobei NUMMER die Nummer des Buffers angibt. <strong>[UPDATE]</strong>Mit <code>:b#</code> (alternativ Strg+^) welchselt man zum zuletzt editierten Buffer. <strong>[/UPDATE]</strong> Alle geöffneten Buffer kann man sich mit <code>:ls</code> anzeigen lassen.</p>
<p>Etwas gewöhnungsbedürftig ist, dass man einen Buffer nur dann wechseln kann, wenn der aktuelle Buffer keine Änderungen enthält. Man muss also immer speichern, bevor man den Buffer wechseln kann. Um diese Restriktion zu umgehen kann man die entsprechenden Kommandos mit Ausrufezeichen verwenden. z.B. <code>:bn!</code>.<strong>[UPDATE]</strong>Statt dessen kann man auch die Option <code>set hidden</code> setzen (z.B. indem man dieses als eine Zeile in die <code>~/.vimrc</code> schreibt). (Danke an b23 für den Tipp.)<strong>[/UPDATE]</strong><br />
Auch das ein Buffer nicht automatisch durch ein :q geschlossen wird ist ungewohnt. Dafür nutzt man den Befehl <code>:bd</code> (Buffer Delete).</p>
<p>Da das Konzept der Tabs recht praktisch ist und man auch mit Buffern oft eine permanente Übersicht über die offenen Dateien haben möchte gibt es das Plugin <a href="http://www.vim.org/scripts/script.php?script_id=159" title="Vim Plugin - MiniBufExplorer" target="_blank" class="liexternal">MiniBufExplorer</a>. Dieses Plugin zeigt in einem einzeiligen horizontalen Splitscreen alle geöffneten Buffer an. Das Plugin bietet auch einige Funktionen an um die Buffer zu wechseln, doch ich empfinde es als einfacher, sich eigene Mappings zu definieren.</p>
<p><strong>[UPTDATE]</strong>Ein weiteres praktisches Plugin ist <a href="http://www.vim.org/scripts/script.php?script_id=42" title="Vim Plugin - bufexplorer" target=_blank" class="liexternal">bufexplorer</a>, welches keinen Splitscreen öffnet. Statt dessen kann man sich die Buffer mit <code>\be</code> anzeigen lassen und einen aussuchen (mit <code>\bs</code> werden die Buffer in einem Splitscreen angezeigt, mit <code>\bv</code> in einem vertikalen splitscreen). Wenn man (ohne dass die Option <em>hidden</em> gesetzt ist) von einem ungespeicherten Buffer wechseln möchte, so wird automatisch ein Splittscreen geöffnet (bei <code>\bv</code> ein Vertikaler) in dem der Buffer angezeigt wird, zu dem gewechselt wurde. (Danke an b23 für den Hinweis)<strong>[/UPDATE]</strong></p>
<p>Wenn man (wie ich) daran gewohnt ist, die Tabs mit Strg+n durchzugehen, ist es ganz praktisch, die selbe Tastenkombination zum wechseln der Buffer zu verwenden. Dafür fügt man folgende Zeile in die <code>~/.vimrc</code> ein oder ändert die entsprechende Zeile, wenn man Strg+n schon für Tabs definiert hat:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #25BB4D;">map</span> <span style="color: #000000;">&lt;</span>C<span style="color: #000000;">-</span>n<span style="color: #000000;">&gt;</span> <span style="color: #000000;">:</span>bn<span style="color: #000000;">!&lt;</span>CR<span style="color: #000000;">&gt;</span></pre></div></div>

<p>Alles in allem haben beide Systeme ihre Vor- und Nachteile. Tabs sind intuitiver und man braucht kein Plugin um sie anzuzeigen. Bei Buffern hat man mit dem MiniBufExplorer-Plugin immer einen horizontalen Splitscreen geöffnet, der manchmal störend sein kann. Dafür sieht man bei Buffern genau, welche Dateien geöffnet sind. Wenn man nur mit Tabs arbeitet sind nach einiger Zeit viele Dateien in Buffern geöffnet ohne das man davon weiß. Es gibt auch einige Plugins, die sich mit Buffern besser nutzen lassen als mit Tabs.</p>
<p>Ich denke man sollte mit beiden Systemen vertraut sein und das jeweils geeignetere nutzen je nachdem, was man vor hat.<br />
Wenn man z.B. standardmäßig mit Tabs arbeitet, kann man in einem geöffneten Splitscreen mit Bufferkommandos zwischen den Dateien wechseln.</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/vim-tipps/vim-buffer-statt-tabs-benutzen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vim Plugin &#8211; Surround umschließt Text mit Klammern, Anführungszeichen und HTML-Tags</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-surround-umschliest-text-mit-klammern-anfuhrungszeichen-und-html-tags/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-surround-umschliest-text-mit-klammern-anfuhrungszeichen-und-html-tags/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 16:32:30 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Plugins und Erweiterungen]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[vim Tipps]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Klammern]]></category>
		<category><![CDATA[Sourround]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1528</guid>
		<description><![CDATA[<p>Für Vim gibt es ein sehr praktisches Plugin namens <a href="http://www.vim.org/scripts/script.php?script_id=1697" title="Vim Plugin - Surround" target="_blank" class="liexternal">Surround</a>, welches es einem ermöglicht Wörter, Sätze, Absätze, Zeilen,&#8230; mit Klammern, Anführungszeichen oder XML-Tags zu umschließen. Solche Umschließungen können auch geändert oder gelöscht werden.</p>
<p>Zur Installation wird das Archiv surround.zip im Verzeichnis <code>~/.vim</code> entpackt.</p>
<p>Grundsätzlich lehnt sich die Bedienung an das Konzept an, den&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Für Vim gibt es ein sehr praktisches Plugin namens <a href="http://www.vim.org/scripts/script.php?script_id=1697" title="Vim Plugin - Surround" target="_blank" class="liexternal">Surround</a>, welches es einem ermöglicht Wörter, Sätze, Absätze, Zeilen,&#8230; mit Klammern, Anführungszeichen oder XML-Tags zu umschließen. Solche Umschließungen können auch geändert oder gelöscht werden.</p>
<p>Zur Installation wird das Archiv surround.zip im Verzeichnis <code>~/.vim</code> entpackt.</p>
<p>Grundsätzlich lehnt sich die Bedienung an das Konzept an, den Text zwischen Klammern, Anführungszeichen,&#8230; zu ändern so wie es im Artikel <a href="http://zinformatik.de/tipps-tricks/vim-tipps/vim-bewegungskommandos/" title="vim Bewegungskommandos" target="_self" class="liinternal">Vim Bewegungskommandos</a> im Abschnitt &#8220;Spezielle Bewegungskommandos&#8221; beschrieben ist. </p>
<p><strong>Text Umschließen</strong><br />
Die Syntax zum Umschließen von Text ist:<br />
<code>ys&lt;BEWEGUNG&gt;&lt;ZEICHEN&gt;</code></p>
<p>Beispiele:</p>
<ul>
<li><code>ysis"</code> &#8211; der aktuelle Satz wird mit doppelten Anführungszeichen umschlossen.</li>
<li><code>ysiw&lt;b&gt;</code> &#8211; versieht das aktuelle Wort mit mit dem HTML-Tag <code>b</code>, so dass es fett angezeigt wird.</li>
<li><code>yss)</code> &#8211; umschließt die aktuelle Zeile mit runden Klammern.</li>
<li><code>ysi)"</code> &#8211; umschließt den Text zwischen den Klammern mit doppelten Anführungszeichen.</li>
<li><code>ysa")</code> &#8211; umschließt den den Text zwischen den doppelten Anführungszeichen und die Anführungszeichen selbst mit runden Klammern.</li>
</ul>
<p>Statt den Bewegungskommandos kann man auch im visuellen Modus den gewünschten Text markieren. Dann drückt man <code>s</code> gefolgt vom gewünschten Zeichen.<br />
Beispiel: <code>s"</code> um den markierten Text mit doppelten Anführungszeichen zu umschließen.</p>
<p>Damit man es sich besser vorstellen kann hier ein konkretes Beispiel. Die folgende Zeile:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">Dies ist eine Beispielzeile</pre></div></div>

<p>wird durch <code>yss"</code> zu</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">&quot;Dies ist eine Beispielzeile&quot;</pre></div></div>

<p>Liegt der Cursor auf dem Wort &#8220;eine&#8221;, so kann man mit <code>ysiw)</code> das Wort mit Klammern umschließen:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">&quot;Dies ist (eine) Beispielzeile&quot;</pre></div></div>

<p><strong>Umschließung ändern</strong><br />
Um die Umschließung von Text zu ändern nutzt man folgende Syntax:<br />
<code>cs&lt;AKTUELLES_ZEICHEN&gt;&lt;NEUES_ZEICHEN&gt;</code></p>
<p>Beispiele:</p>
<ul>
<li><code>cst"</code> &#8211; ändert das XML/HTML-Tag zu doppelten Anführungszeichen.</li>
<li><code>cs"'</code> &#8211; ändert doppelte in einfache Anführungszeichen.</li>
<li><code>cs)}</code> &#8211; ändert runde in geschweifte Klammern.</li>
</ul>
<p><strong>Umschließung löschen</strong><br />
Die Syntax um eine Umschließung zu löschen ist:<br />
<code>ds&lt;ZEICHEN&gt;</code></p>
<p>Beispiele:</p>
<ul>
<li><code>ds]</code> &#8211; löscht eckige Klammern.</li>
<li><code>ds'</code> &#8211; löscht einfache Anführungszeichen.</li>
<li><code>dst</code> &#8211; löscht XML/HTML-Tags.</li>
</ul>
<p><strong>Wiederholen</strong><br />
Leider funktioniert das Wiederholen des letzten Kommandos mit Punkt nicht mit dem Surround-Plugin. Jedoch kann man es mit dem Plugin <a href="http://www.vim.org/scripts/script.php?script_id=2136" title="Vim Plugin - repeat" target="_blank" class="liexternal">repeat</a> zum funktionieren bringen.<br />
Dafür kopiert man die Datei <code>repeat.vim</code> in das Verzeichnis <code>~/.vim/autoload/</code>. Nachdem man <code>.</code> (Punkt) gedrückt hat muss man jedoch das Zeichen, welches eingefügt werden soll wiederholen.</p>
<p>Abhilfe schafft ansonsten auch die Nutzung von <a href="http://zinformatik.de/tipps-tricks/vim-tipps/makros-aufzeichnen-mit-vim/" title="Makros aufzeichnen mit vim" target="_self" class="liinternal">Makros</a>. Dabei können häufig genutzte Surroundings auch als Makro in die <code>~/.vimrc</code> gespeichert werden.<br />
Folgende Zeile definiert das Register k so, dass beim Aufruf des Makros k mittels <code>@k</code> das aktuelle Wort in runde Klammern eingeschlossen wird:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">let</span> <span style="color: #000000;">@</span>k=<span style="color: #C5A22D;">&quot;ysiw)&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/vim-plugin-surround-umschliest-text-mit-klammern-anfuhrungszeichen-und-html-tags/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Whois Plugin für den zBot</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/whois-plugin-fur-den-zbot/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/whois-plugin-fur-den-zbot/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 16:59:53 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Plugins und Erweiterungen]]></category>
		<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[Bot]]></category>
		<category><![CDATA[Jabber]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1516</guid>
		<description><![CDATA[<p>Vor einiger Zeit habe ich ein Whois-Plugin für meinen Jabber Bot <a href="http://zinformatik.de/tipps-tricks/interessante-programme/zbot-ein-jabber-bot-in-perl/" title="zBot - ein Jabber Bot in Perl" target="_self" class="liinternal">zBot</a> geschrieben. Aus irgendeinem Grund habe ich es nie online gestellt. Dies möchte ich hiermit nachholen. Ich habe den Code noch ein wenig verschönert. </p>
<p>Fauchi95 hat mich gefragt, ob man nicht ein Whois-Plugin schreiben könnte, da ist es&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Vor einiger Zeit habe ich ein Whois-Plugin für meinen Jabber Bot <a href="http://zinformatik.de/tipps-tricks/interessante-programme/zbot-ein-jabber-bot-in-perl/" title="zBot - ein Jabber Bot in Perl" target="_self" class="liinternal">zBot</a> geschrieben. Aus irgendeinem Grund habe ich es nie online gestellt. Dies möchte ich hiermit nachholen. Ich habe den Code noch ein wenig verschönert. </p>
<p>Fauchi95 hat mich gefragt, ob man nicht ein Whois-Plugin schreiben könnte, da ist es mir wieder eingefallen <img src='http://zinformatik.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>Die Bedienung ist so wie man es sich denkt. Man sendet dem Bot ein <code>whois</code> gefolgt von der gewünschten Domain und bekommt das Ergebnis zurück gesendet.</p>
<p><strong>Beispiel:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">whois zinformatik.de</pre></div></div>

<p>Zum Installieren des Plugins kopiert man die Datei <code>Whois.pm</code> in das Verzeichnis <code>plugins</code> im Hauptverzeichnis des zBot und startet dann den Bot neu.</p>
<p><strong>Download:</strong><br />
<a href="http://zinformatik.de/wp-content/uploads/2009/07/Whois.pm" class="liinternal">Whois.pm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/plugins-erweiterungen/whois-plugin-fur-den-zbot/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>VNUML &#8211; Ein Netzwerksimulator mit User-Mode-Linux</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/vnuml-ein-netzwerksimulator-mit-user-mode-linux/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/vnuml-ein-netzwerksimulator-mit-user-mode-linux/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 12:26:44 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Interessante Programme]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[Netzwerk]]></category>
		<category><![CDATA[Routing]]></category>
		<category><![CDATA[Simulation]]></category>
		<category><![CDATA[User-Mode-Linux]]></category>
		<category><![CDATA[VNUML]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1468</guid>
		<description><![CDATA[<p><div id="attachment_1486" class="wp-caption alignright" style="width: 310px"><a href="http://zinformatik.de/wp-content/uploads/2009/07/switch-ethernet-connection.jpg" ><img src="http://zinformatik.de/wp-content/uploads/2009/07/switch-ethernet-connection.jpg" alt="Foto: Ben Stanfield" title="Foto: Ben Stanfield" width="300" height="179" class="size-full wp-image-1486" /></a><p class="wp-caption-text">Foto: Ben Stanfield</p></div><a href="http://www.dit.upm.es/vnumlwiki/index.php/Main_Page" title="Offizielle VNUML Homepage" target="_blank" class="liexternal">VNUML</a> (Virtual Network User-Mode-Linux) ist ein Programm um Netzwerke zu simulieren. Dabei werden die beteiligten Rechner nicht nur simuliert, sondern als virtuelle Maschinen gestartet, wodurch sie mit echten Protokollen miteinander kommunizieren. Daher eignet sich dieses Tool sehr gut zum Testen und Lernen z.B von Routingprotokollen. Man kann damit jedoch auch Paketfiltering mittels <a href="http://de.wikipedia.org/wiki/Iptables" title="Wikipedia - iptables" target="_blank"&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_1486" class="wp-caption alignright" style="width: 310px"><a href="http://zinformatik.de/wp-content/uploads/2009/07/switch-ethernet-connection.jpg" ><img src="http://zinformatik.de/wp-content/uploads/2009/07/switch-ethernet-connection.jpg" alt="Foto: Ben Stanfield" title="Foto: Ben Stanfield" width="300" height="179" class="size-full wp-image-1486" /></a><p class="wp-caption-text">Foto: Ben Stanfield</p></div><a href="http://www.dit.upm.es/vnumlwiki/index.php/Main_Page" title="Offizielle VNUML Homepage" target="_blank" class="liexternal">VNUML</a> (Virtual Network User-Mode-Linux) ist ein Programm um Netzwerke zu simulieren. Dabei werden die beteiligten Rechner nicht nur simuliert, sondern als virtuelle Maschinen gestartet, wodurch sie mit echten Protokollen miteinander kommunizieren. Daher eignet sich dieses Tool sehr gut zum Testen und Lernen z.B von Routingprotokollen. Man kann damit jedoch auch Paketfiltering mittels <a href="http://de.wikipedia.org/wiki/Iptables" title="Wikipedia - iptables" target="_blank" rel="nofollow" class="liwikipedia"><code>iptables</code></a> sowie andere Dienste wie <a href="http://de.wikipedia.org/wiki/Address_Resolution_Protocol" title="Wikipedia - ARP" target="_blank" rel="nofollow" class="liwikipedia"><em>ARP</em></a>, <a href="http://de.wikipedia.org/wiki/Domain_Name_System" title="Wikipedia - DNS" target="_blank" rel="nofollow" class="liwikipedia"><em>DNS</em></a> oder <a href="http://de.wikipedia.org/wiki/ICMP" title="Wikipedia - ICMP" target="_blank" rel="nofollow" class="liwikipedia"><em>ICMP</em></a> ausprobieren. Auch eigene Entwicklungen können so getestet werden.<br />
Da für jeden Rechner ein <a href="http://www.user-mode-linux.org/" title="User-Mode-Linux Homepage" target="_blank" class="liexternal">User-Mode-Linux System</a> (englisch) &#8211; welches über einen echten Kernel und ein eigenes Dateisystem verfügt &#8211; gestartet wird, ist die Simulation sehr realitätsnah und die Rechner verhalten sich wie echte autonome Maschinen.<br />
Für diesen Artikel ist es vorteilhaft, wenn man grundlegende Kenntnisse über Netzwerke besitzt (es wird z.B. vorausgesetzt, dass man weiß was <a href="http://de.wikipedia.org/wiki/IP-Adresse" title="Wikipedia - IP-Adresse" target="_blank" rel="nofollow" class="liwikipedia">IP-Adressen</a>, <a href="http://de.wikipedia.org/wiki/IP-Adresse#Netzwerkteil_und_Ger.C3.A4teteil" title="Wikipedia - IP-Adressen: Netzwerkteil und Geräteteil" target="_blank" rel="nofollow" class="liwikipedia">Netze und Netzmasken</a> sowie <a href="http://de.wikipedia.org/wiki/Router" title="Wikipedia - Router" target="_blank" rel="nofollow" class="liwikipedia">Router</a> sind)</p>
<p><strong>UPDATE:</strong> Artikel nochmal überarbeitet</p>
<p><strong>Installation</strong><br />
Für Debian basierte Distributionen gibt es ein .deb Paket, welches zumindest unter Ubuntu problemlos installiert werden kann. Ansonsten kann man sich den Quelltext herunter laden. Eine englische <a href="http://www.dit.upm.es/vnumlwiki/index.php/Installation" title="VNUML - Installation" target="_blank" class="liexternal">Installationsanleitung</a> ist auch verfügbar.<br />
Ist VNUML installiert, braucht man noch ein Dateisystem. Auf der Projektseite gibt es 2 verschiedene zum <a href="http://www.dit.upm.es/vnumlwiki/index.php/Download" title="VNUML - Dateisysteme Download" target="_blank" class="liexternal">downloaden</a>. Ein größeres, welches mehr Programme beinhaltet und ein sehr abgespecktes, welches nützlich ist um größere Netzwerke zu generieren, da für jeden virtuellen Rechner ein Dateisystem im Arbeitsspeicher liegt.<br />
Man kopiert das gewählte Dateisystem nach <code>/usr/share/vnuml/filesystems/filesystem.img</code>. Für die Beispiele in diesem Artikel reicht das kleine, welches man als <code>mini_fs</code> speichern kann. Dafür können die folgenden Befehle benutzt werden, nachdem man die Datei n3vlr-0.11-vnuml-v0.1.tar.gz herunter geladen hat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> n3vlr-<span style="color: #000000;">0.11</span>-vnuml-v0.1.tar.gz
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> n3vlr-<span style="color: #000000;">0.11</span>-vnuml-v0.1.img <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vnuml<span style="color: #000000; font-weight: bold;">/</span>filesystems<span style="color: #000000; font-weight: bold;">/</span>mini_fs</pre></div></div>

<p>Möchte man das Dateisystem ändern um z.B. neue Programme hinzuzufügen oder unbenötigte Dateien zu löschen, kann man dieses mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>vnuml
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vnuml<span style="color: #000000; font-weight: bold;">/</span>filesystems<span style="color: #000000; font-weight: bold;">/</span>filesystem.img <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>vnuml</pre></div></div>

<p>einhängen. Nun kann man im Ordner <code>/mnt/vnunml</code> alle gewünschten Änderungen vornehmen und das Dateisystem danach mit <code>sudo umount /mnt/vnuml</code> wieder aushängen.</p>
<p><strong>Scenariodatei erstellen</strong><br />
Die Netzwerktopologie wird in einer XML-Datei beschrieben. In dieser werden zuerst die globalen Einstellungen festgelegt, in denen unter anderem angegeben wird, wo das zu nutzende Dateisystem liegt und welchen ssh-Key man nutzen möchte um auf die virtuellen Rechner zuzugreifen.<br />
Danach folgen die Definitionen der Netze gefolgt von den Rechnern.<br />
Im folgenden eine minimale Beispielkonfiguration, die zwei Rechner beschreibt, die über ein Netz miteinander verbunden sind. Zuerst der globale Teil, in dem die VNUML-Version, der Name des Scenarios und weitere Einstellungen definiert werden. Dort wird auch das Management-Netz (192.168.0.0/24) definiert, über das man vom eigenen Rechner auf die verschiedenen virtualisierten Maschinen zugreifen kann.<br />
Existiert noch kein öffentlicher ssh-key, so sollte man sich mit folgendem Kommando einen anlegen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span></pre></div></div>

<p>Bei der Frage nach einem Passwort drückt man einfach Enter ohne ein Passwort einzugeben. Der vorgeschlagene Pfad sollte stimmen, kann also beibehalten werden.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE vnuml SYSTEM &quot;/usr/share/xml/vnuml/vnuml.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vnuml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;simulation_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>beispiel<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/simulation_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ssh_version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ssh_version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ssh_key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/root/.ssh/id_rsa.pub<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ssh_key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;automac</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm_mgmt</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;private&quot;</span> <span style="color: #000066;">network</span>=<span style="color: #ff0000;">&quot;192.168.0.0&quot;</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;24&quot;</span> <span style="color: #000066;">offset</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;host_mapping</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm_mgmt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm_defaults</span> <span style="color: #000066;">exec_mode</span>=<span style="color: #ff0000;">&quot;mconsole&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filesystem</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cow&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/share/vnuml/filesystems/mini_fs<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filesystem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;kernel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/vnuml/kernels/linux<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/kernel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm_defaults<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Als nächstes werden die Netze definiert. In diesem Beispiel gibt es nur ein Netz, da man sich sonst um das Routing kümmern müsste (dazu später mehr).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;net</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;net1&quot;</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;virtual_bridge&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Im Modus &#8220;virtual_bridge&#8221; werden die Interfaces aller virtuellen Rechner sowie alle Netze über Bridges ans Hostsystem (den eigenen Rechner) gekoppelt, so dass man sie mit einem <code>ifconfig</code> sehen und mittels <a href="http://de.wikipedia.org/wiki/Tcpdump" title="Wikipedia - tcpdump" target="_blank" rel="nofollow" class="liwikipedia"><code>tcpdump</code></a> oder <a href="http://de.wikipedia.org/wiki/Wireshark" title="Wikipedia - Wireshark" target="_blank" rel="nofollow" class="liwikipedia">Wireshark</a> überwachen kann. Dafür wird jedoch das Paket &#8220;bridge-utils&#8221; benötigt. Alternativ kann man statt dessen auch &#8220;uml_switch&#8221; benutzen.</p>
<p>Nun folgen die Definitionen der virtuellen Rechner. Bei beiden Rechnern wird ein Interface definiert (es können aber auch mehrere sein, z.B. für Router).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;rechner1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.1.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;r2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.1.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vnuml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Es empfiehlt sich die Datei genauso wie das Scenario (die globale Eigenschaft <code>simulation_name</code>) zu benennen. In diesem Fall also <code>beispiel.xml</code></p>
<p><strong>Scenario starten und zu den Rechnern verbinden</strong><br />
Um das Scenario zu starten genügt der folgende Aufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> vnumlparser.pl <span style="color: #660033;">-t</span> beispiel.xml</pre></div></div>

<p>Nachdem das Scenario gestartet ist, kann man sich auf einen der Rechner einloggen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> rechner1</pre></div></div>

<p>Durch die Angabe des öffentlichen ssh-Keys sollte es keine Passwortabfrage geben. Ansonsten ist das Passwort per default <code>xxxx</code>. Nun kann man alles mögliche Testen. Man kann einen Ping versenden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ping</span> 10.0.1.2</pre></div></div>

<p>oder ein Interface überwachen.<br />
Dafür loggt man sich am besten in einer anderen Konsole auf dem 2. Rechner ein:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> rechner2</pre></div></div>

<p>und startet dort einen TCP-Dump:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tcpdump <span style="color: #660033;">-i</span> eth1</pre></div></div>

<p>Der Ping sollte die ganze Zeit weiter laufen, damit man auch etwas sehen kann. Danach kann man ihn mit Strg+c stoppen.<br />
Mit <code>exit</code> kann man einen Rechner wieder verlassen.<br />
Da man häufiger auf mehreren Rechnern gleichzeitig eingeloggt sein möchte wenn man mit VNUML arbeitet, bietet es sich an <a href="http://zinformatik.de/tipps-tricks/interessante-programme/einfuhrung-in-screen/" title="Einführung in Screen" target="_self" class="liinternal">Screen</a> zu benutzen.<br />
Um die Simulation zu beenden führt man folgenden Befehl aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> vnumlparser.pl <span style="color: #660033;">-P</span> beispiel.xml</pre></div></div>

<p><strong>Dienste starten</strong><br />
Wie bereits erwähnt eignet sich VNUML besonders gut zum ausprobieren und Testen von Routingprotokollen. Daher sind auch die Quagga-Implementationen der bekanntesten Routingprotokolle <em>RIP</em>, <em>OSPF</em> und <em>BGP</em> bereits installiert und können recht einfach genutzt werden. Ich werde in diesem Artikel jedoch nur eine Minimalkonfiguration für <em>RIP</em> und <em>OSPF</em> angeben. Eine Einführung in diese Protokolle und deren Konfiguration würde an dieser Stelle zu weit führen.<br />
Um das Routing grundsätzlich zu aktivieren wird das Tag</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forwarding</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ipv4&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>genutzt. Weitere Tags binden ein Konfigurationsverzeichnis <code>conf</code> ein (welches im gleichen Verzeichnis, wie die xml-Datei des Scenarios liegt) und starten die verschiedenen Daemons.<br />
Im Verzeichnis <code>conf</code> sollten dann die folgenden Dateien vorhanden sein:</p>
<p><code>zebra.conf</code></p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">!
hostname zebra
!
password xxxx
enable password xxxx</pre></div></div>

<p><code>ripd.conf</code></p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">!
hostname ripd
password xxxx
!
router rip
network 10.0.0.0/8</pre></div></div>

<p><code>ospfd.conf</code></p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">!
hostname ospfd
password xxxx
!
router ospf
network 10.0.0.0/8 area 0</pre></div></div>

<p>Weitere Infos zu den Quagga-Routingprotokollen gibt es unter <a href="http://www.quagga.net/" title="Quagga Homepage" target="_blank" class="liexternal">http://www.quagga.net</a>.<br />
Ein Scenario, welches der Einfachheit halber nur aus Routern besteht, auf denen man wahlweise <em>OSPF</em> oder <em>RIP</em> starten kann wird im folgenden Beispiel definiert:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE vnuml SYSTEM &quot;/usr/share/xml/vnuml/vnuml.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vnuml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;simulation_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mini<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/simulation_name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ssh_version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ssh_version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ssh_key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/root/.ssh/id_rsa.pub<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ssh_key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;automac</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm_mgmt</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;private&quot;</span> <span style="color: #000066;">network</span>=<span style="color: #ff0000;">&quot;192.168.0.0&quot;</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;24&quot;</span> <span style="color: #000066;">offset</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;host_mapping</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm_mgmt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm_defaults</span> <span style="color: #000066;">exec_mode</span>=<span style="color: #ff0000;">&quot;mconsole&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filesystem</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cow&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/share/vnuml/filesystems/mini_fs<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filesystem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;kernel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/vnuml/kernels/linux<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/kernel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm_defaults<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/global<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;net</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;net1&quot;</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;virtual_bridge&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;net</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;net2&quot;</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;virtual_bridge&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;r1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.1.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forwarding</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ipv4&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filetree</span> <span style="color: #000066;">root</span>=<span style="color: #ff0000;">&quot;/etc/quagga&quot;</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>conf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filetree<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>sysctl -w net.ipv4.conf.all.rp_filter=0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/zebra -f /etc/quagga/zebra.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rip&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ripd -f /etc/quagga/ripd.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;ospf&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ospfd -f /etc/quagga/ospfd.conf -d -P 2604<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall zebra<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ripd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ospfd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rpfilter&quot;</span> <span style="color: #000066;">type</span>= <span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 &gt; $f; done
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;r2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.1.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.2.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forwarding</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ipv4&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filetree</span> <span style="color: #000066;">root</span>=<span style="color: #ff0000;">&quot;/etc/quagga&quot;</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>conf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filetree<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>sysctl -w net.ipv4.conf.all.rp_filter=0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/zebra -f /etc/quagga/zebra.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rip&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ripd -f /etc/quagga/ripd.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;ospf&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ospfd -f /etc/quagga/ospfd.conf -d -P 2604<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall zebra<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ripd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ospfd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rpfilter&quot;</span> <span style="color: #000066;">type</span>= <span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 &gt; $f; done
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;r3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;if</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">net</span>=<span style="color: #ff0000;">&quot;net2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipv4</span> <span style="color: #000066;">mask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10.0.2.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipv4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forwarding</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ipv4&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filetree</span> <span style="color: #000066;">root</span>=<span style="color: #ff0000;">&quot;/etc/quagga&quot;</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>conf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filetree<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>sysctl -w net.ipv4.conf.all.rp_filter=0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/zebra -f /etc/quagga/zebra.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rip&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ripd -f /etc/quagga/ripd.conf -d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;ospf&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/usr/lib/quagga/ospfd -f /etc/quagga/ospfd.conf -d -P 2604<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hostname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall zebra<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ripd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>killall ospfd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">seq</span>=<span style="color: #ff0000;">&quot;rpfilter&quot;</span> <span style="color: #000066;">type</span>= <span style="color: #ff0000;">&quot;verbatim&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 &gt; $f; done
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vnuml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><div id="attachment_1493" class="wp-caption alignright" style="width: 310px"><a href="http://zinformatik.de/wp-content/uploads/2009/06/mini.png" ><img src="http://zinformatik.de/wp-content/uploads/2009/07/mini-300x53.png" alt="Die Topologie des Beispielscenarios mini.xml" title="Die Topologie des Beispielscenarios mini.xml" width="300" height="53" class="size-medium wp-image-1493" /></a><p class="wp-caption-text">Die Topologie des Beispielscenarios mini.xml</p></div>Dieses Beispiel besteht aus 3 Routern, die mit zwei Netzen zu einer &#8220;Kette&#8221; verbunden sind (siehe Abbildung rechts). Startet man dieses Scenario, so kann man nicht von r1 (10.0.1.1) nach r3 (10.0.2.2) pingen, da die Routingdaemons noch nicht gestartet sind und r1 noch nichts von net2 weiß:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> vnumlparser.pl <span style="color: #660033;">-t</span> mini.xml
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> root<span style="color: #000000; font-weight: bold;">@</span>r1
<span style="color: #c20cb9; font-weight: bold;">ping</span> 10.0.2.2</pre></div></div>

<p>Wie man sieht, kommen die Pings nicht bei r3 an.  Mit <code>exit</code> verläst man den Router r1 wieder.<br />
Es gibt nun 4 Sequenzen, die ausgeführt werden können: <em>start</em>, <em>stop</em>, <em>rip</em> und <em>ospf</em>. Dabei wird durch ausführen der Sequenz <em>start</em> der Hostname gesetzt und der zebra-Daemon gestartet. Mit <em>rip</em> oder <em>ospf</em> wird der entsprechende Routingdaemon gestartet und <em>stop</em> beendet alle Routingprozesse.<br />
Man startet nun also z.B. den <em>RIP</em>-Daemon mit den folgenden Befehlen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> vnumlparser.pl <span style="color: #660033;">-x</span> start<span style="color: #000000; font-weight: bold;">@</span>mini.xml
<span style="color: #c20cb9; font-weight: bold;">sudo</span> vnumlparser.pl <span style="color: #660033;">-x</span> rip<span style="color: #000000; font-weight: bold;">@</span>mini.xml</pre></div></div>

<p>Nun kann man testen, ob das Routing auch funktioniert, indem man den Ping, der vorher fehlschlug wiederholt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> root<span style="color: #000000; font-weight: bold;">@</span>r1
<span style="color: #c20cb9; font-weight: bold;">ping</span> 10.0.2.2</pre></div></div>

<p>Jetzt sollte der Ping funktionierten. Bei größeren Scenarien kann es einige Sekunden dauern bis alle Router über die notwendigen Informationen verfügen (also bis das Scenario <em>konvergent</em> ist).</p>
<p>Natürlich gibt es noch viele weitere Optionen und Möglichkeiten, die VNUML zur Verfügung stellt. Dies soll nur eine kleine Einführung sein, um die ersten Schritte mit diesem System zu machen. </p>
<p><strong>Links</strong></p>
<ul>
<li><a href="http://www.dit.upm.es/vnumlwiki/index.php/Main_Page" title="Offizielle VNUML Seite" target="_blank" class="liexternal">http://www.dit.upm.es/vnumlwiki/index.php/Main_Page</a> (englisch) &#8211; Offizielle VNUML Seite mit Downloadmöglichkeit und Dokumentation</li>
<li><a href="http://www.uni-koblenz.de/~vnuml/index.de.php" title="Deutsche VNUML Seite der Universität Koblenz" target="_blank" class="liexternal">http://www.uni-koblenz.de/~vnuml/index.de.php</a> &#8211; VNUML Seiten der Universität Koblenz</li>
<li><a href="http://de.wikipedia.org/wiki/VNUML" title="Wikipedia - VNUML" target="_blank" rel="nofollow" class="liwikipedia">http://de.wikipedia.org/wiki/VNUML</a> &#8211; Wikipedia Artikel zu VNUML</li>
<li><a href="http://www.quagga.net/" title="Quagga Homepage" target="_blank" class="liexternal">http://www.quagga.net</a> (englisch) &#8211; Offizielle Quagga Seite</li>
<li><a href="http://de.wikipedia.org/wiki/Quagga_(Software)" title="Wikipedia - Quagga" target="_blank" rel="nofollow" class="liwikipedia">http://de.wikipedia.org/wiki/Quagga_(Software)</a> &#8211; Wikipedia Artikel zu Quagga</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/vnuml-ein-netzwerksimulator-mit-user-mode-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
