コンテンツにスキップ

xterm - X Window System 端末エミュレータ

xterm は X Window System の標準端末エミュレータで、多くの現代的な端末アプリケーションの基盤となっています。1984年に最初に開発されて以来、xterm は Unix 系システムで最も広く使用され、機能豊富な端末エミュレータの1つです。広範なカスタマイズオプション、Unicode サポートを提供し、端末エミュレーション標準のリファレンス実装として機能しています。

インストール

Linux (Debian/Ubuntu)

sudo apt update
sudo apt install xterm

Linux (Red Hat/CentOS/Fedora)

sudo dnf install xterm
# or on older systems:
sudo yum install xterm

Linux (Arch)

sudo pacman -S xterm

macOS (with X11)

# Install XQuartz first, then:
brew install xterm

FreeBSD

pkg install xterm

基本的な使用方法

xterm の起動

# Basic xterm window
xterm

# Start with specific title
xterm -title "My Terminal"

# Start with specific geometry
xterm -geometry 80x24+100+100

# Start with specific font
xterm -fn "fixed"

# Start in fullscreen
xterm -fullscreen

コマンドラインオプション

# Display options
xterm -display :0.0
xterm -geometry 132x43
xterm -iconic
xterm -maximized

# Font options
xterm -fn "9x15"
xterm -fa "Monospace:size=12"
xterm -fs 14

# Color options
xterm -fg white -bg black
xterm -rv  # Reverse video
xterm -cm  # Color mode

# Scrolling options
xterm -sb  # Enable scrollbar
xterm -sl 1000  # Set scrollback lines
xterm -si  # Scroll on input
xterm -sk  # Scroll on key press

# Logging options
xterm -l  # Enable logging
xterm -lf logfile.txt  # Log to specific file

キーボードショートカット

テキスト選択とクリップボード

# Text selection
Left Click + Drag          # Select text
Double Click               # Select word
Triple Click               # Select line
Shift + Left Click         # Extend selection

# Clipboard operations
Ctrl + Shift + C           # Copy (modern xterm)
Ctrl + Shift + V           # Paste (modern xterm)
Middle Click               # Paste selection (traditional)
Shift + Insert             # Paste clipboard

# Traditional X11 clipboard
Select text                # Automatically copies to primary selection
Middle Click               # Paste primary selection

ウィンドウとフォントの制御

# Font size control
Ctrl + Right Click         # Font menu
Ctrl + Plus                # Increase font size
Ctrl + Minus               # Decrease font size
Ctrl + 0                   # Reset font size

# Window operations
Alt + F4                   # Close window
Alt + F10                  # Maximize window
Alt + F9                   # Minimize window
Alt + F5                   # Restore window

スクロール

# Scrollback navigation
Shift + Page Up            # Scroll up one page
Shift + Page Down          # Scroll down one page
Shift + Home               # Scroll to top
Shift + End                # Scroll to bottom
Shift + Up Arrow           # Scroll up one line
Shift + Down Arrow         # Scroll down one line

端末制御

# Terminal reset and clear
Ctrl + L                   # Clear screen
reset                      # Reset terminal state
clear                      # Clear screen content

# Process control
Ctrl + C                   # Interrupt (SIGINT)
Ctrl + Z                   # Suspend (SIGTSTP)
Ctrl + D                   # EOF/Exit
Ctrl + \                   # Quit (SIGQUIT)

マウス操作

コンテキストメニュー

# Main menu (Ctrl + Left Click)
- New Window
- Print Window
- Redraw Window
- Send Signal
- Quit

# VT Options menu (Ctrl + Middle Click)
- Enable/Disable Scrollbar
- Enable/Disable Jump Scroll
- Enable/Disable Reverse Video
- Enable/Disable Auto Wraparound
- Enable/Disable Reverse Wraparound
- Enable/Disable Auto Linefeed
- Enable/Disable Application Cursor Keys
- Enable/Disable Application Keypad
- Scroll to Bottom on Output
- Scroll to Bottom on Key
- Allow 80/132 Column Switching
- Keep Selection
- Select to Clipboard

# VT Fonts menu (Ctrl + Right Click)
- Default Font
- Tiny Font
- Small Font
- Medium Font
- Large Font
- Huge Font
- Escape Sequence Font
- Selection Font

選択モード

# Selection types
Single Click               # Position cursor
Double Click               # Select word
Triple Click               # Select line
Quadruple Click            # Select all

# Extended selection
Shift + Click              # Extend selection
Ctrl + Click               # Rectangular selection
Alt + Click                # Line selection mode

設定

コマンドライン設定

# Resource file options
xterm -xrm "XTerm*background: black"
xterm -xrm "XTerm*foreground: white"
xterm -xrm "XTerm*font: 9x15"
xterm -xrm "XTerm*scrollBar: true"

# Multiple resources
xterm -xrm "XTerm*background: black" \
      -xrm "XTerm*foreground: green" \
      -xrm "XTerm*font: fixed"

X リソース設定 (~/.Xresources)

! Basic appearance
XTerm*background: black
XTerm*foreground: white
XTerm*cursorColor: yellow
XTerm*pointerColor: red
XTerm*borderColor: blue

! Font configuration
XTerm*font: -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
XTerm*boldFont: -misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
XTerm*faceName: Liberation Mono:size=12:antialias=false
XTerm*faceSize: 12

! Scrolling
XTerm*scrollBar: true
XTerm*scrollbar.width: 8
XTerm*rightScrollBar: true
XTerm*saveLines: 10000
XTerm*scrollTtyOutput: false
XTerm*scrollKey: true

! Bell configuration
XTerm*visualBell: true
XTerm*bellIsUrgent: true

! Selection and clipboard
XTerm*highlightSelection: true
XTerm*trimSelection: true
XTerm*cutNewline: false
XTerm*cutToBeginningOfLine: false
XTerm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48

! Terminal behavior
XTerm*loginShell: true
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*toolBar: false
XTerm*titeInhibit: false

! Color scheme (Solarized Dark example)
XTerm*color0: #073642
XTerm*color1: #dc322f
XTerm*color2: #859900
XTerm*color3: #b58900
XTerm*color4: #268bd2
XTerm*color5: #d33682
XTerm*color6: #2aa198
XTerm*color7: #eee8d5
XTerm*color8: #002b36
XTerm*color9: #cb4b16
XTerm*color10: #586e75
XTerm*color11: #657b83
XTerm*color12: #839496
XTerm*color13: #6c71c4
XTerm*color14: #93a1a1
XTerm*color15: #fdf6e3

X リソースの適用

# Load resources
xrdb -merge ~/.Xresources

# Load and replace all resources
xrdb -load ~/.Xresources

# View current resources
xrdb -query

# Remove all resources
xrdb -remove

高度な機能

Unicode と国際化

# UTF-8 support
xterm -u8

# Locale-specific startup
LC_ALL=en_US.UTF-8 xterm

# Font configuration for Unicode
XTerm*utf8: 1
XTerm*locale: true
XTerm*utf8Title: true
XTerm*fontMenu*fontdefault*Label: Default
XTerm*faceName: DejaVu Sans Mono:size=11
XTerm*faceNameDoublesize: WenQuanYi Zen Hei Mono:size=11

端末エミュレーションモード

# VT100 mode
xterm -tn vt100

# VT220 mode
xterm -tn vt220

# Linux console mode
xterm -tn linux

# Set terminal type
export TERM=xterm-256color

ログと セッション記録

Would you like me to continue with the remaining sections?```bash

Enable logging

xterm -l -lf ~/xterm.log

Logging with timestamp

xterm -l -lf ~/xterm-$(date +%Y%m%d-%H%M%S).log

Session recording with script

script -f ~/session.log

Then start xterm within the script session

```bash
# Disable dangerous features
XTerm*allowSendEvents: false
XTerm*allowWindowOps: false
XTerm*allowTitleOps: false
XTerm*allowFontOps: false

# Secure keyboard input
XTerm*secureKeyboard: true

# Disable menu access
XTerm*omitTranslation: popup-menu
```## カスタマイズの例
```bash
# Solarized Light
XTerm*background: #fdf6e3
XTerm*foreground: #657b83
XTerm*fadeColor: #fdf6e3
XTerm*cursorColor: #586e75
XTerm*pointerColorBackground: #93a1a1
XTerm*pointerColorForeground: #586e75

# Monokai
XTerm*background: #272822
XTerm*foreground: #f8f8f2
XTerm*cursorColor: #f8f8f0
XTerm*color0: #272822
XTerm*color1: #f92672
XTerm*color2: #a6e22e
XTerm*color3: #f4bf75
XTerm*color4: #66d9ef
XTerm*color5: #ae81ff
XTerm*color6: #a1efe4
XTerm*color7: #f8f8f2

# Gruvbox Dark
XTerm*background: #282828
XTerm*foreground: #ebdbb2
XTerm*color0: #282828
XTerm*color1: #cc241d
XTerm*color2: #98971a
XTerm*color3: #d79921
XTerm*color4: #458588
XTerm*color5: #b16286
XTerm*color6: #689d6a
XTerm*color7: #a89984
```### カラースキーム
```bash
# Bitmap fonts
XTerm*font: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
XTerm*boldFont: -misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1

# TrueType fonts
XTerm*faceName: Inconsolata:size=12
XTerm*faceSize: 12
XTerm*renderFont: true

# Multiple font sizes
XTerm*faceSize1: 8
XTerm*faceSize2: 10
XTerm*faceSize3: 12
XTerm*faceSize4: 14
XTerm*faceSize5: 16
XTerm*faceSize6: 18
```### フォント設定
```bash
# Window class and name
XTerm*iconName: Terminal
XTerm*title: xterm
XTerm*geometry: 80x24+0+0

# Window manager hints
XTerm*allowWindowOps: true
XTerm*disallowedWindowOps: 1,2,3,4,5,6,7,8,9,11,13,18,19

# Session management
XTerm*sessionMgt: true
```### ウィンドウマネージャ統合
```bash
# Font problems
xlsfonts|grep fixed          # List available fonts
xterm -fn fixed                # Use basic fixed font
fc-list : family|grep Mono   # List monospace fonts

# Color issues
echo $TERM                     # Check terminal type
tput colors                    # Check color support
xterm -tn xterm-256color       # Force 256 color mode

# Clipboard problems
xclip -version                 # Check if xclip is installed
xsel --version                 # Check if xsel is installed
echo $DISPLAY                  # Verify X11 display

# Locale issues
locale                         # Check current locale
xterm -u8                      # Enable UTF-8 mode
export LANG=en_US.UTF-8        # Set UTF-8 locale
```## トラブルシューティング
```bash
# Disable unnecessary features
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*fastScroll: true

# Reduce resource usage
XTerm*saveLines: 1000          # Limit scrollback
XTerm*visualBell: false        # Disable visual bell
XTerm*toolBar: false           # Disable toolbar

# Font rendering optimization
XTerm*renderFont: true
XTerm*antialias: true
XTerm*faceSize: 11
```### 一般的な問題
```bash
# Debug mode
xterm -debug 1

# Verbose output
xterm -verbose

# Check resources
xrdb -query|grep -i xterm

# Test configuration
xterm -xrm "XTerm*background: red" -geometry 40x10
```### パフォーマンス最適化
```bash
# With tmux
xterm -e tmux

# With screen
xterm -e screen

# With specific session
xterm -e "tmux attach-session -t main"
```### デバッグ
```bash
# Specific shell
xterm -e bash
xterm -e zsh
xterm -e fish

# Login shell
xterm -ls

# Execute command and exit
xterm -e "ls -la; read"
```## 他のツールとの統合
```bash
#!/bin/bash
# Launch multiple xterm windows
xterm -geometry 80x24+0+0 -title "Main" &
xterm -geometry 80x24+400+0 -title "Logs" -e "tail -f /var/log/syslog" &
xterm -geometry 80x24+0+300 -title "Monitor" -e "htop" &
```### ターミナルマルチプレクサ
```bash
# Use version control for configs
cd ~
git init
git add .Xresources
git commit -m "Initial xterm configuration"

# Backup configurations
cp ~/.Xresources ~/.Xresources.backup
```### シェル統合
```bash
# Disable dangerous operations
XTerm*allowSendEvents: false
XTerm*allowWindowOps: false
XTerm*allowTitleOps: false

# Use secure keyboard mode
XTerm*secureKeyboard: true

# Limit font operations
XTerm*allowFontOps: false
```### ウィンドウマネージャスクリプト
```bash
# Optimize for speed
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*fastScroll: true

# Limit resource usage
XTerm*saveLines: 2000
XTerm*buffered: true
```## ベストプラクティス