Zsh - PowerPoint PPT Presentation

About This Presentation
Title:

Zsh

Description:

Title: Zsh Author: Motorola PC Last modified by: Motorola PC Created Date: 5/12/1999 11:11:50 PM Document presentation format: Overhead Company: Motorola – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 22
Provided by: Motor6
Category:
Tags: history | zero | zsh

less

Transcript and Presenter's Notes

Title: Zsh


1
Zsh
  • - Larry P. Schrof

2
Purpose
  • Spark your interest in zsh
  • To learn more about zshs capabilities
  • Expand your productivity

3
Topics Covered
  • Configuration Files
  • Prompt Tricks
  • Monitoring Logins
  • Aliases
  • The Directory Stack
  • Brace Expansion
  • History Using fc
  • History Expansion
  • Parameters Arrays and Subscripting
  • Parameters Subscript Flags
  • Parameters Expansion
  • Filename Generation
  • Filename Generation Qualifiers
  • Programmable Completion
  • Completion Items
  • Restricted Mode
  • ZLE (Zsh Command Line Editor)
  • Where to get more information.

4
Configuration Files
  • Order
  • /etc/zshenv, then /.zshenv
  • /etc/zprofile, then /.zprofile (L)
  • /etc/zshrc, then /.zshrc (I)
  • /etc/zlogin, then /.zlogin (L)
  • /etc/zlogout then/.zlogout (logout)
  • (I) Only if interactive. (L) Only if login

5
Prompt Tricks
  • Arithmetic, command, and parameter expansion
    available.
  • Escape sequences start with a (Over 40)
  • Conditional Expressions
  • (X.true-text.false-text)
  • RPROMPT for right-hand side prompt
  • Formatting and truncating available

6
Monitoring Logins
  • Event format username_at_hostline
  • rootconsole
  • schrof_at_procmail.org
  • Put events in watch parameter
  • watch(event1 event2 eventN)
  • Set the LOGCHECK parameter
  • Formatting available

7
Aliases
  • namevalue syntax
  • Global aliases! Define with alias -g
  • Functions are usually preferred

8
The Directory Stack
  • Used for managing large lists of directories
  • dirs -v to examine stack
  • popd removes a directory from stack, and cds to
    that directory
  • pushd cds to a new directory, and places OLDPWD
    on top of the stack
  • Can use expansion to reference stack entries

9
Brace Expansion
  • Alows you to quickly generate lists in two ways
  • ls -l array5d,MYd,BIG
  • touch logfile.990801..31.tmp
  • zsh is smart about zero padding

10
History Using fc
  • fc loads past commands into editor, then executes
    them
  • fc -l lists previous commands
  • fc -e EDITOR OPTIONS oldnew first
    last
  • Options n l d D r t E i m
  • fc is not as direct as history expansion, but a
    bit easier to use

11
History Expansion
  • Allows you to reference complete or partial past
    commands
  • All expansions start with
  • Use UP/DOWN arrows in emacs mode
  • CTRL-R in emacs mode is your friend.
  • oldnew trick
  • designatorwordmod1mod2...

12
Parameters Arrays and Subscripting
  • Assign name(value1 valueN)
  • Subscripts nameexpr
  • negative expr counts from end
  • Range nameexpr1,expr2
  • Replacement nameexprvalue
  • value can be an array
  • Subscripts work on strings, too!

13
Parameters Subscript Flags
  • name(X)expr,(Y)expr2
  • w splits by words
  • s splits on specified characters
  • f splits on a per-line basis
  • r treats expr as a pattern returns first item
    matching expr
  • i returns index of first match
  • R and I just like r and i, but return last match
  • n used with r, R, i, or I. Returns nth match.

14
Parameters Expansion
  • Standard ksh expansions
  • var var-word varword var?
  • Adds more expansions
  • namepattern namepattern namepattern
  • Any of above can be preceded by a for length of
    result.

15
Filename Generation
  • Set EXTENDED_GLOB variable
  • Operators include , ?, , !, , , lt-gt, ,
    , xy
  • / does recursive search
  • print -l /usr/local/src//.cho

16
Filename Generation Qualifiers
  • Surpasses most other shells
  • Limits wildcard matches
  • After wildcard, enclose list in ()s
  • Over 40 qualifiers available, including negation

17
Programmable Completion
  • Set with compctl command
  • Fully programmable. If zsh doesnt do what you
    want, you can write it yourself.
  • Customizable. (menu? Cycle through list?
    Auto-insert?)
  • zsh can complete ANYTHING!

18
Completion Items
  • Filenames
  • Built-in commands
  • External commands
  • aliases
  • global aliases
  • functions
  • Shell variables
  • Environment variables
  • reserved words
  • Zsh options
  • key bindings
  • Named directories
  • usernames (files, NIS, etc)
  • hosts
  • running jobs
  • suspended jobs
  • Anything else you can imagine.

19
Restricted Mode
  • Serves well for a guest account
  • http//www.acm.uiuc.edu/workshops/zsh/restricted.h
    tml

20
Command-line editor
  • Emacs, vi-insert, and vi-command modes provided
  • Build your own keymaps from scratch
  • 160 pre-defined widgets
  • Write your own widgets
  • Rebind any or all portions of keymaps
  • bindkey used to select and modify keymaps
  • man zshmodules for details

21
More Information
  • Workshop
  • http//www.acm.uiuc.edu/workshops/zsh
  • Homepage
  • http//www.zsh.org
  • FAQ
  • http//sunsite.auc.dk/zsh/FAQ/
Write a Comment
User Comments (0)
About PowerShow.com