X-Git-Url: http://git.grml.org/?p=zsh-lovers.git;a=blobdiff_plain;f=zsh-lovers.1.txt;h=f17f28bf5afb7802e682e344e4df868c8726bef4;hp=4512dc3a266a22ab133928b35899101cf7eec63c;hb=HEAD;hpb=900a04e6d3a2ca006cd55d49e03a25ee35952a5c diff --git a/zsh-lovers.1.txt b/zsh-lovers.1.txt index 4512dc3..f17f28b 100644 --- a/zsh-lovers.1.txt +++ b/zsh-lovers.1.txt @@ -20,7 +20,7 @@ Most of the tricks and oneliner come from the mailinglists zsh-users, zsh-workers, google, newsgroups and from ourself. See section *LINKS* for details. -Note: This manpage (zsh-lovers(1)) is *not* an offical part of the Z shell! It's +Note: This manpage (zsh-lovers(1)) is *not* an official part of the Z shell! It's just a just for fun - manpage ;) + For comments, bugreports and feedback take a quick look at the section *BUGS*. @@ -76,7 +76,7 @@ $ alias -g C='| wc -l' $ grep alias ~/.zsh/* C 443 ---------------------- -Some more or less useful global aliases (choose whether they are useful or not +Some more or less useful global aliases (choose whether they are useful or not for you on your own): -------------------------------------------------------- @@ -180,7 +180,7 @@ zstyle ':completion:*:kill:*' force-list always --------------------------------------------------------------------------------------------------- If you end up using a directory as argument, this will remove the -trailing slash (usefull in ln) +trailing slash (useful in ln) --------------------------------------------------------------------------------------------------- zstyle ':completion:*' squeeze-slashes true --------------------------------------------------------------------------------------------------- @@ -190,12 +190,50 @@ cd will never select the parent directory (e.g.: cd ../): zstyle ':completion:*:cd:*' ignore-parents parent pwd --------------------------------------------------------------------------------------------------- +Another method for 'quick change directories'. Add this to your ~/.zshrc, then just enter +``cd ..../dir'' +--------------------------------------------------------------------------------------------------- +rationalise-dot() { + if [[ $LBUFFER = *.. ]]; then + LBUFFER+=/.. + else + LBUFFER+=. + fi +} +zle -N rationalise-dot +bindkey . rationalise-dot +--------------------------------------------------------------------------------------------------- + UNSORTED/MISC examples ~~~~~~~~~~~~~~~~~~~~~~ Hint: A list of valid glob Qualifiers can be found in zshexpn(1). See ``man 1 zshexpn | less -p'' Qualifiers for details. ------------------------------------------------------------------------------- +# Get the names of all files that *don't* match a pattern *anywhere* on the +# file (and without ``-L'' because its GNUish) + $ print -rl -- *(.^e{'grep -q pattern $REPLY'}) + # or + $ : *(.e{'grep -q pattern $REPLY || print -r -- $REPLY'}) + +# random numbers + $ echo $[${RANDOM}%1000] # random between 0-999 + $ echo $[${RANDOM}%11+10] # random between 10-20 + $ echo ${(l:3::0:)${RANDOM}} # N digits long (3 digits) + +# reverse a word + $ echo "${(j::)${(@Oa)${(s::):-hello}}}" + +# Show newest directory + $ ls -ld *(/om[1]) + +# random array element + $ FILES=( .../files/* ) + $ feh $FILES[$RANDOM%$#FILES+1] + +# cat first line in all files in this dir + $ for file (*(ND-.)) IFS= read -re < $file + # test if a parameter is numeric $ if [[ $1 == <-> ]] ; then echo numeric @@ -204,7 +242,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. fi # Show me all the .c files for which there doesn't exist a .o file. - $ c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}' + $ print *.c(e_'[[ ! -e $REPLY:r.o ]]'_) # All files in /var/ that are not owned by root $ ls -ld /var/*(^u:root) @@ -212,7 +250,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. # All files for which the owner hat read and execute permissions $ echo *(f:u+rx:) -# The same, but also others dont have execute permissions +# The same, but also others don't have execute permissions $ echo *(f:u+rx,o-x:) # brace expansion - example @@ -241,7 +279,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. # Remove zero length and .bak files in a directory $ rm -i *(.L0) *.bak(.) -# print out files that dont have extensions +# print out files that don't have extensions $ printf '%s\n' ^?*.* $ printf '%s\n' ^?*.[^.]*(D) $ ls -d -- ^?*.*(D) @@ -309,7 +347,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. # see above, but now omit executables $ ls **/*~*(${~${(j/|/)fignore}})(.^*) -# Print out files that dont have extensions (require *setopt extendedglob* +# Print out files that don't have extensions (require *setopt extendedglob* # and *setopt dotglob*) $ printf '%s\n' ^?*.* @@ -356,7 +394,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. $ print ${(r:10::0:)foo} # find the name of all the files in their home directory that have -# more than 20 characters in their file names +# 20 or more characters in their file names print -rl $HOME/${(l:20::?:)~:-}* # Save arrays @@ -435,7 +473,7 @@ See ``man 1 zshexpn | less -p'' Qualifiers for details. $ for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav} # Download with LaTeX2HTML created Files (for example the ZSH-Guide): - $ for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; do + $ for f in https://zsh.sourceforge.io/Guide/zshguide{,{01..08}}.html; do > lynx -source $f >${f:t} > done @@ -631,30 +669,30 @@ zsh-4.2.3/Doc/zsh_us.ps # Show only empty files which nor `group' or `world writable' $ ls *(L0f.go-w.) -# find - and list - the ten newest files in directories and subdirs +# Find - and list - the ten newest files in directories and subdirs. # (recursive) $ print -rl -- **/*(Dom[1,10]) -# Print only 5 lines by "ls" command (like ``ls -laS | head -n 5'') +# Print only 5 lines by "ls" command (like ``ls -laS | head -n 5''). $ ls -fl *(DOL[1,5]) -# display the 5-10 last modified files +# Display the 5-10 last modified files. $ print -rl -- /path/to/dir/**/*(D.om[5,10]) -# find all files without a valid owner +# Find all files without a valid owner. $ chmod someuser /**/*(D^u:${(j.:u:.)${(f)"$( /dev/null -# Show only files are owned from group `users' +# Show only files which are owned by group `users'. $ ls -l *(G[users]) ------------------------------------------------------------------------------- @@ -665,6 +703,25 @@ Modifiers are a powerful mechanism that let you modify the results returned by parameter, filename and history expansion. See zshexpn(1) for details. ------------------------------------------------------------------------------- +# NOTE: Zsh 4.3.4 needed! + $ autoload -U age +# files modified today + $ print *(e:age today now:) +# files modified since 5 pm + $ print *(e-age 17:00 now-) +# ... since 5 o'clock yesterda + $ print *(e-age yesterday,17:00 now-) +# ... from last Christmas before today + $ print *(e-age 2006/12/25 today-) +# ... before yesterday + $ print *(e-age 1970/01/01 yesterday-) +# all files modified between the start of those dates + $ print *(e:age 2006/10/04 2006/10/09:) +# all files modified on that date + $ print *(e:age 2006/10/04:) +# Supply times. + $ print *(e-age 2006/10/04:10:15 2006/10/04:10:45-) + # Remove a trailing pathname component, leaving the head. This works like # `dirname'. $ echo =ls(:h) @@ -725,13 +782,13 @@ for details. # convert 1st char of a word to uppercase $ foo="one two three four" - $ print -r -- "${(C)var}" + $ print -r -- "${(C)foo}" One Two Three Four ------------------------------------------------------------------------------- Redirection-Examples ~~~~~~~~~~~~~~~~~~~~ -See zshmisc(1) for more informations (or less ${^fpath}/zmv(N)) +See zshmisc(1) for more information (or less ${^fpath}/zmv(N)) ------------------------------------------------------------------------------- # Append `exit 1' at the end of all *.sh - files @@ -787,6 +844,21 @@ ZMV-Examples (require autoload zmv) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *Note:* '-n' means no execution (just print what would happen). At ------------------------------------------------------------------------------- +# Remove illegal characters in a fat32 file system. Illegal characters are +# / : ; * ? " < > | +# NOTE: ``-Q'' and (D) is to include hidden files. + $ unwanted='[:;*?\"<>|]' + $ zmv -Q "(**/)(*$~unwanted*)(D)" '$1${2//$~unwanted/}' + +# Changing part of a filename (i. e. "file-hell.name" -> "file-heaven.name") + $ zmv '(*)hell(*)' '${1}heaven${2}' + # or + $ zmv '*' '$f:s/hell/heaven/' + +# remove round bracket within filenames +# i. e. foo-(bar).avi -> foo-bar.avi + $ zmv '*' '${f//[()]/}' + # serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..) $ autoload zmv $ ls * @@ -795,7 +867,7 @@ ZMV-Examples (require autoload zmv) $ ls * 1.c 1.foo 2.foo 3.foo 4.foo foo.fnord -# Rename "file.with.many.dots.txt" by substituting dots (exept for the last +# Rename "file.with.many.dots.txt" by substituting dots (except for the last # one!) with a space $ touch {1..20}-file.with.many.dots.txt $ zmv '(*.*)(.*)' '${1//./ }$2' @@ -988,6 +1060,10 @@ zsh/datetime (require zmodload zsh/datetime) zsh/stat (require zmodload zsh/stat) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------------------------------------------------------------------- +# test if a symbolic link links to a certain file + $ zmodload -i zsh/stat + $ ! stat -LH s foo.ln || [[ $s[link] != "foo.exe" ]] || ln -sf foo.exe foo.ln + # comparing file dates $ zmodload zsh/stat $ file1=foo @@ -1096,7 +1172,7 @@ zsh/mapfile (require zmodload zsh/mapfile) # If a XML-file contains stuff like ``'' and ``'', number # this empty tags (ones ending in '/>') so if encountered in the same -# order, the preceeding tags would become ``1'' and +# order, the preceding tags would become ``1'' and # ``2'' $ zmodload zsh/mapfile $ cnt=0 @@ -1356,54 +1432,37 @@ $EUID $GID $EGID $USERNAME $fignore $mailpath $cdpath LINKS ----- Primary site:: - *http://www.zsh.org/[]* + *http://www.zsh.org/[]* +Zsh Web Pages:: + *https://zsh.sourceforge.io/[]* Project-page:: - *http://sourceforge.net/projects/zsh/[]* -Z shell page at sunsite.dk:: - *http://zsh.sunsite.dk/[]* + *http://sourceforge.net/projects/zsh/[]* From Bash to Z Shell: Conquering the Command Line - the book:: *http://www.bash2zsh.com/[]* +"Zsh - die magische Shell" (german book about Zsh) by Sven Guckes and Julius Plenz:: + *http://zshbuch.org/[]* Mailinglistarchive:: *http://www.zsh.org/mla/[]* ZSH-FAQ:: - *http://www.zsh.org/FAQ/[]* + *https://zsh.sourceforge.io/FAQ/zshfaq.html[]* Userguide:: - *http://zsh.sunsite.dk/Guide/[]* + *https://zsh.sourceforge.io/Guide/[]* ZSH-Wiki:: - *http://www.zshwiki.org/[]* -Die Zsh als interaktive Shell:: - *http://cssun.rrze.uni-erlangen.de/~sipakale/zshreferat.html[]* -A short introduction from BYU:: - *http://docs.cs.byu.edu/docs/zsh/index.php[]* + *http://zshwiki.org/home/[]* Mouse-Support ;):: *http://stchaz.free.fr/mouse.zsh[]* -Shell Corner: Zsh Suite of "keeper" Functions:: - *http://www.unixreview.com/documents/s=9513/ur0501a/ur0501a.htm[]* -The Z Shell (A Fan Page):: - *http://www.princeton.edu/~kmccarty/zsh.html[]* -Making the Transition to Zsh:: - *http://www.linux-mag.com/cgi-bin/printer.pl?issue=2002-05&article=power[]* -Curtains up: introducing the Z shell:: - *http://www-128.ibm.com/developerworks/linux/library/l-z.html?dwzone=linux[]* -ZSH-Liebhaberseite:: - *http://michael-prokop.at/computer/tools_zsh_liebhaber.html[]* -ZSH-Seite von Michael Prokop:: - *http://www.michael-prokop.at/computer/tools_zsh.html[]* -A Case for the Z Shell on *http://www.daemonnews.org/[]*:: - *http://ezine.daemonnews.org/199910/zsh.html[]* -ZSH-Section from Dotfiles.com:: - *http://www.dotfiles.com/index.php?app_id=4[]* -Writing Zsh Completion Functions:: - *http://www.linux-mag.com/2002-07/power_01.html[]* ZSH Prompt introduction:: *http://aperiodic.net/phil/prompt/[]* +ft's blog posts around zsh:: + *http://bewatermyfriend.org/tag/zsh/[]* +ft's zsh configuration:: + *https://gitlab.com/ft/etc-zsh[]* Adam's ZSH page:: *http://www.adamspiers.org/computing/zsh/[]* Zzappers Best of ZSH Tips:: *http://www.rayninfo.co.uk/tips/zshtips.html[]* Zsh Webpage by Christian Schneider:: - *http://strcat.de/wiki/zsh/[]* - *http://strcat.de/wiki/zsh-german[]* (German translation. Help needed!) + *http://www.strcat.de/zsh/[]* The zsh-lovers webpage:: *http://grml.org/zsh/[]* IRC channel:: @@ -1423,14 +1482,14 @@ In alphabetic order: ------------------------------------------------------------------------- Andrew 'zefram' Main - http://www.fysh.org/~zefram/ Barton E. Schaefer - http://www.well.com/user/barts/ -Matthias Kopfermann - http://www.infodrom.north.de/~matthi/ +Matthias Kopfermann - http://www.guckes.net/zsh/lover.html Oliver Kiddle - http://people.freenet.de/opk/ Paul Falstad - http://www.falstad.com/ Peter Stephenson - http://homepage.ntlworld.com/p.w.stephenson/ Richard Coleman Stephane Chazelas - http://stephane.chazelas.free.fr/ Sven Guckes - http://www.guckes.net/ -Sven Wischnowsky - http://w9y.de/zsh/zshrc +Sven Wischnowsky - http://w9y.de/ ------------------------------------------------------------------------- SEE ALSO @@ -1440,7 +1499,8 @@ Manpages of zsh: zsh Zsh overview zshall Tthe Z shell meta-man page zshbuiltins Zsh built-in commands - zshcompctl Zsh completion control + zshcalsys zsh calendar system + zshcompctl zsh programmable completion zshcompsys Zsh completion system zshcompwid Zsh completion widgets zshcontrib User contributions to zsh @@ -1463,9 +1523,9 @@ Also take a look at the section *LINKS* in this manpage. BUGS ---- -Probably. This manpage might be never complete. So please report bugs, -feedback and suggestions to . Thank -you! +Probably. This manpage might be never complete. +So please report bugs, feedback and suggestions via https://github.com/grml/zsh-lovers +Thank you! COPYRIGHT ---------