Tips und Tricks:
Hinweis für Nicht-(Programmierer|Administratoren|(Linu|Uni)xer|Webdilettanten): Enter at your own risk!
HTML: Netscape "Commicaze 4.xx" / Grafiken pixelgenau plazieren:
Alle Grafiken in eine Tabelle packen, aber dann darauf achten, dass nach einem schliessenden Anker </a> oder einem Image-Tag <img.....> NIE ein Zeilenumbruch im HTML-Quelltext steht! Statt dessen sofort die nächste Zelle mit <td> beginnen.
Die restliche Formattierung spielt keine Rolle, sie kann demnach also zur besseren Lesbarkeit (wenn man diesen Begriff in Verbindung mit HTML überhaupt in den Mund nehmen darf) frei umgebrochen werden.
(Danke, Wolfgang, für den entscheidenden Tip der Quelltextformattierung! Ich hätte mir glatt den Wolf gesucht....)
PERL: Schnelles case-Konstrukt / Mehrfachschalter
Anstatt sich einen mit "if" abzuverschachteln, tut auch dieses gut:
$gesichtsfarbe =
$promille <= 0 ? 'blass' :
$promille <= 1 ? 'gesund' :
$promille <= 2 ? 'rot' : 'sternhagelblau';
Kurz gesagt, unäre Kontrukte lassen sich verschachteln.
PERL: Blockanweisung als logische Bedingung
Üblicherweise liest man in Perl sowas häufig:
open BH, "...blubber..." or die "Ich krieg' das Scheissding nicht auf!";
Womit es sich dann i.d.R. auch schon hat.
Moechte man hingegen mehr als eine Zeile als Konsequenz einer Bedingung verarbeiten, bietet sich - auch wegen der guten Übersicht - das hier an:
open REISSVERSCHLUSS, "....oh, mann!...." or do {
print "Verdammt! Abgeschlossen!\n";
goto SCHLUESSELSUCHE;
};
PERL: Einen Prozess dämonisieren (in den Hintergrund schicken)
Geht so:
fork &; exit;
close STOUT;
close STDIN;
close STDERR;
Was bedeutet, das sich der Elternprozess gabelt und sich sofort beendet.
Das Kind läuft hingegen weiter, schliesst seine I/O-Kanäle und läuft ab diesem Zeitpunkt unabhängig (auch vom kontrollierenden Terminal).
BASH: Tastenkürzel für die Kommandozeile
beginning-of-line (C-a)
Move to the start of the current line.
end-of-line (C-e)
Move to the end of the line.
forward-char (C-f)
Move forward a character.
backward-char (C-b)
Move back a character.
forward-word (M-f)
Move forward to the end of the next word. Words
are composed of alphanumeric characters (letters
and digits).
backward-word (M-b)
Move back to the start of this, or the previous,
word. Words are composed of alphanumeric charac
ters (letters and digits).
tab-insert (C-v TAB)
Insert a tab character.
transpose-chars (C-t)
Drag the character before point forward over the
character at point. Point moves forward as well.
If point is at the end of the line, then transpose
the two characters before point. Negative argu
ments don't work.
transpose-words (M-t)
Drag the word behind the cursor past the word in
front of the cursor moving the cursor over that
word as well.
upcase-word (M-u)
Uppercase the current (or following) word. With a
negative argument, uppercase the previous word, but
do not move point.
downcase-word (M-l)
Lowercase the current (or following) word. With a
negative argument, lowercase the previous word, but
do not move point.
kill-line (C-k)
Kill the text from the current cursor position to
the end of the line.
unix-line-discard (C-u)
Kill backward from point to the beginning of the
line. The killed text is saved on the kill-ring.
kill-word (M-d)
Kill from the cursor to the end of the current
word, or if between words, to the end of the next
word. Word boundaries are the same as those used
by forward-word.
backward-kill-word (M-Rubout)
Kill the word behind the cursor. Word boundaries
are the same as those used by backward-word.
unix-word-rubout (C-w)
Kill the word behind the cursor, using white space
as a word boundary. The word boundaries are dif
ferent from backward-kill-word.
yank (C-y)
Yank the top of the kill ring into the buffer at
the cursor.
yank-pop (M-y)
Rotate the kill ring, and yank the new top. Only
works following yank or yank-pop.
undo (C-_, C-x C-u)
Incremental undo, separately remembered for each
line
revert-line (M-r)
Undo all changes made to this line. This is like
executing the undo command enough times to return
the line to its initial state.
abort (C-g)
Abort the current editing command and ring the ter
minal's bell (subject to the setting of
bell-style).
BASH: Farbiger Prompt
Hier die Farbsteuertabelle der bash:
################################
# 30er Nummern: Vordergrundfarbe
# 40er Nummern: Hintergrundfarbe
# 30 = schwarz
# 31 = rot
# 32 = gruen
# 33 = gelb
# 34 = blau
# 35 = magenta
# 36 = cyan
# 37 = weiss
# 39 = standard (default)
################################
Diese Einträge sollten in die Datei "/etc/bashrc" oder ".profile":
### SuSE veraeppeln, siehe /etc/profile....
unset PROMPT_COMMAND
PS1="\n\[\033[0;30;42m\][RECHNER: \h · \w]\[\033[0;37;40m\]\n\u \\$ "
VI: Nette Tastenkürzel
# Suchen nach dem Wort, das sich gerade unter dem Cursor befindet
Von aktueller Zeilenposition mehrere in den Puffer löschen und an anderer Stelle wieder einfügen:
:.,POSd (schneidet aus bis zur mit POS angegebenen Zeilennummer und übernimmt die Zeilen in den Puffer)
Den Cursor nun auf die gewünschte Einfügezeile stellen und "p" drücken.
Die gepufferten Zeilen werden eingefügt
Blockweise ein- oder ausrücken:
:.,POS< (rückt bis zur Zeile POS eine Tabsize nach links aus
:.,POS> (rückt bis zur Zeile POS eine Tabsize nach rechts ein
20<<(rückt ab der aktuellen Zeile einen 20-Zeilen-Block aus)
20>> (rückt ab der aktuellen Zeile einen 20-Zeilen-Block ein)
Sprungbefehle:
g oder :1 (springe an den Dateibeginn)
G (springe ans Dateiende)
z ENTER (aktuelle Zeile wird in Fenstermitte zentriert)
H (High, Cursor in die oberste Zeile bringen)
M (Middle, Cursor in die Mitte des Fensters stellen)
L (Low, Cursor an den unteren Fensterrand bringen)
Diverses:
J Zieht die nachfolgende Zeile hoch auf die aktuelle Zeile
:r DATEI (liest DATEI an aktuelle Cursorposition ein)
:w DATEI (schreibt aktuelle Datei unter neuem Namen)
. (wiederholt die letzte Befehlssequenz seit ESCAPE)
ENDE DER TNT.... bis mir neues ein-, bzw. auffällt.