slide1
Download
Skip this Video
Download Presentation
Zsh

Loading in 2 Seconds...

play fullscreen
1 / 21

Zsh - PowerPoint PPT Presentation


  • 138 Views
  • Uploaded on

Zsh. - Larry P. Schrof. Purpose. Spark your interest in zsh To learn more about zsh’s capabilities Expand your productivity. Configuration Files Prompt Tricks Monitoring Logins Aliases The Directory Stack Brace Expansion History: Using fc History Expansion

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Zsh' - luke


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

Zsh

- Larry P. Schrof

purpose
Purpose
  • Spark your interest in zsh
  • To learn more about zsh’s capabilities
  • Expand your productivity
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.

Topics Covered
configuration files
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
prompt tricks
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
monitoring logins
Monitoring Logins
aliases
Aliases
  • name=value syntax
  • Global aliases! Define with alias -g
  • Functions are usually preferred
the directory stack
The Directory Stack
  • Used for managing large lists of directories
  • dirs -v to examine stack
  • popd removes a directory from stack, and cd’s to that directory
  • pushd cd’s to a new directory, and places $OLDPWD on top of the stack
  • Can use ~ expansion to reference stack entries
brace expansion
Brace Expansion
  • Alows you to quickly generate lists in two ways
    • ls -l array{5d,MYd,BIG}
    • touch logfile.9908{01..31}.tmp
      • zsh is smart about zero padding
history using fc
History: Using fc
  • fc loads past commands into editor, then executes them
  • fc -l lists previous commands
  • fc [ -e EDITOR ] [OPTIONS] [old=new …] [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
history expansion
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.
  • ^old^new trick
  • designator[:word][:mod1:mod2...]
parameters arrays and subscripting
Parameters: Arrays and Subscripting
  • Assign: name=(value1 … valueN)
  • Subscripts: name[expr]
    • negative expr counts from end
  • Range: name[expr1,expr2]
  • Replacement: name[expr]=value
    • value can be an array
  • Subscripts work on strings, too!
parameters subscript flags
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.
parameters expansion
Parameters: Expansion
  • Standard ksh expansions
    • ${+var} ${var:-word} ${var:=word} ${var:?}
  • Adds more expansions
    • ${name#pattern} ${name%pattern} ${name:#pattern}
  • Any of above can be preceded by a # for length of result.
filename generation
Filename Generation
  • Set EXTENDED_GLOB variable
  • Operators include *, ?, [], [!], #, ##, <->, |, ^, x~y
  • **/ does recursive search
    • print -l /usr/local/src/**/*.[cho]
filename generation qualifiers
Filename Generation: Qualifiers
  • Surpasses most other shells
  • Limits wildcard matches
  • After wildcard, enclose list in ()’s
  • Over 40 qualifiers available, including negation
programmable completion
Programmable Completion
  • Set with compctl command
  • Fully programmable. If zsh doesn’t do what you want, you can write it yourself.
  • Customizable. (menu? Cycle through list? Auto-insert?)
  • zsh can complete ANYTHING!
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.

Completion Items
restricted mode
Restricted Mode
  • Serves well for a guest account
  • http://www.acm.uiuc.edu/workshops/zsh/restricted.html
command line editor
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
more information
More Information
  • Workshop
    • http://www.acm.uiuc.edu/workshops/zsh
  • Homepage
    • http://www.zsh.org
  • FAQ:
    • http://sunsite.auc.dk/zsh/FAQ/
ad