Some small cleanups to make lintian happy / part 1
[zsh-lovers.git] / zsh-lovers.1.txt
index 4512dc3..a7e3f79 100644 (file)
@@ -190,12 +190,44 @@ cd will never select the parent directory (e.g.: cd ../<TAB>):
 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.
 
 -------------------------------------------------------------------------------
+# 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 +236,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)
@@ -665,7 +697,32 @@ Modifiers are a powerful mechanism that let you modify the results
 returned by parameter, filename and history expansion. See zshexpn(1)
 for details.
 -------------------------------------------------------------------------------
+<<<<<<< /home/dope/download/Source/HG-Repos/zsh-lovers/zsh-lovers.1.txt.orig.432616858
+# 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 
+||||||| /tmp/zsh-lovers.1.txt~base.AvW_ZW
+# Remove a trailing pathname component, leaving the head. This works like 
+=======
 # Remove a trailing pathname component, leaving the head. This works like
+>>>>>>> /tmp/zsh-lovers.1.txt~other.vDaddL
 # `dirname'.
   $ echo =ls(:h)
   /bin
@@ -787,6 +844,10 @@ ZMV-Examples (require autoload zmv)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *Note:* '-n' means no execution (just print what would happen). At
 -------------------------------------------------------------------------------
+# 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 *
@@ -988,6 +1049,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
@@ -1440,7 +1505,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