digの結果から ANSWER SECTION のみ抜き出す

dig の出力結果は以下のような感じです。

$ dig google.com

; <<>> DiG 9.5.0-P2 <<>> google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17158
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		136	IN	A	72.14.205.100
google.com.		136	IN	A	74.125.45.100
google.com.		136	IN	A	209.85.171.100

;; Query time: 301 msec
;; SERVER: 60.254.193.158#53(60.254.193.158)
;; WHEN: Wed Jan  7 23:10:48 2009
;; MSG SIZE  rcvd: 76

pshで、このdigの結果から ANSWER SECTION のみ抜き出します

$ dig google.com | {print if/ANSWER SECTION/../^$/}q
;; ANSWER SECTION:
google.com.		36	IN	A	72.14.205.100
google.com.		36	IN	A	74.125.45.100
google.com.		36	IN	A	209.85.171.100

awkとか、perl -eも打ちたくない、ものぐさなあなたにおすすめ

ログインシェルをpshに変更

深夜高速 Ubuntuログインシェルをzshに変更する

上のサイトを参考に、ubuntuのログインシェルをpshに変更します。

~/.bashrc の下の方に、以下の記述を加えます。

if [ -x `which psh` ]; then
    echo '[switch login shell] bash -> psh'
    exec psh
fi

端末を再起動して、pshに切り替わったら成功です。

psh

pshは、perlのshellです。

適当に ~/.pshrc を書いてみた。

#!/usr/bin/perl

use strict;
use warnings;

use Psh;
use Psh::Prompt;
use Sys::Hostname;
use File::Basename;
use Term::ANSIColor;

# The maximum number of lines to save in the history file. 
# Defaults to 50.
option histsize= 100;

# ウィンドウタイトル
option window_title= sub{
    # The current working directory
    return $Psh::Prompt::prompt_vars{w}->()||0;
}

# プロンプト
option ps1= sub{
    # The username of the current user
    my $user = $Psh::Prompt::prompt_vars{u}->();
    
    # The short hostname
    # my $host = $Psh::Prompt::prompt_vars{h}->();
    my $host = hostname;
    
    # The current working directory
    my $dir  = basename $Psh::Prompt::prompt_vars{w}->();
    
    return
	color("green") 
	. $user . '@' . $host . ':' . $dir 
	. color("reset")
	. '$ ';
}

# エイリアス
alias less = 'lv';
alias ls = 'ls --color=auto'
alias ll = 'ls -l';
alias la = 'ls -a';
alias emacs = 'emacs -nw';
alias mew = 'emacs -e mew'
  • メモ

option は、変数名と = の間にスペースを入れてはいけない。

文字をエスケープするのに、バックスラッシュ(\)が二つ必要だった。

etc ...

mewでgmail

mewgmail読みたかったので、設定を行いました。

以下のサイトの通りの設定です。

http://blueskyproject.net/kde/blog/2008/03/gmailimap-with-mew.html

(3) ~/.mew.el に次の設定を書き込みます.
( someone をメールアドレスの@より前の部分の文字列に置き換えてください.)

;; Gmail (IMAP) の設定
(setq mew-proto "%")
(setq mew-user "someone")
(setq mew-mail-domain "gmail.com")

(setq mew-imap-server "imap.gmail.com")
(setq mew-imap-user "someone@gmail.com")
(setq mew-imap-auth t)
(setq mew-imap-delete nil) ;; サーバのメールを削除しない
(setq mew-imap-ssl t)
(setq mew-imap-ssl-port "993")

(setq mew-smtp-auth t)
(setq mew-smtp-ssl t)
(setq mew-smtp-ssl-port "465")
(setq mew-smtp-user "someone@gmail.com")
(setq mew-smtp-server "smtp.gmail.com")

ufw

ファイアウォールです。

$ ufw --help

Usage: ufw COMMAND

Commands:
  enable			enables the firewall
  disable			disables the firewall
  default ARG			set default policy to ALLOW or DENY
  logging ARG			set logging to ON or OFF
  allow|deny RULE		allow or deny RULE
  delete allow|deny RULE	delete the allow/deny RULE
  status			show firewall status
  version			display version information

Application profile commands:
  app list			list application profiles
  app info PROFILE		show information on PROFILE
  app update PROFILE		update PROFILE
  app default ARG		set profile policy to ALLOW, DENY or SKIP