# Matching all files which do not have a dot in filename
$
# explanation
$
ls *~*.*(.)# explanation
ls * # all files~ # except*.* # files with a dot(.) # files only , exclude possible directory with a dot# history (fc)
fc -ln -4 > /tmp/hist # no numbersfc -ln 1 | grep rsync | gvim -fc -l -5 # 5 most recent fc -l 1 5 # 5 oldest fc -l -10 -5 # 10th newest to 5 newest fc -l 1 | more # step through all fc -lir # with datestamps (reverse)alias hg='fc -l 1 | grep -i '# your own metalanguage
# the power of global aliases
# the power of global aliases
alias -g ND{1,}='*(/om[1])' # newest diralias -g ND{2,D}='*(/om[2])' # 2nd newest diralias -g NF{1,}='*(.om[1])' # newest filealias -g NF{2,F}='*(.om[2])' # 2nd newest filecp NF NDvi NF2# the = operator locates any file in any directory in $PATH
# tab completion works as well
# tab completion works as well
vi =weekcd =week(:h)/usr/local/bin# create your super-shell with global aliases.
alias -g TOD=' *(.m0)' # today's filesalias -g F=' | fmt -50 ' # formatalias -g G=' | grep -i'alias -g GV=' | grep -iv' # negative grepalias -g H=' | head 'alias -g M=' | less 'alias -g ERR=' >& /dev/null & 'gvim -p TOD# find 5 largest files in hierarchy includes: with filter by file type php,inc exclude: directories libs and tmp
~ means excludels -lS **/*.(php|inc)~(libs|tmp)/*(.OL[1,5])# useful/essential setopts
setopt interactivecomments # allows end of command line commentssetopt HIST_IGNORE_DUPSsetopt HIST_IGNORE_SPACE # dont put commands beginning with space in historysetopt # to see your current settings# Open newest image in downloads directory
alias imgd='cd ~/Downloads/ && xnview *.(jpg|jpeg|gif|png)(.om[1]) >& /dev/null &'
# using = 0 to n subdirectories
cp ../**/template.jpg .
ls /fred.jpg # standardsetopt GLOBSTARSHORT # simplify globls fred.jpg # betterls /fred.jpg # slow search from rootls /home/**fred.jpg # search from homels ../**fred.jpg # search up and down . you want thiscp ../**/template.jpg .
# single liners no 4 (a template)
# find directories that contain both "index.php" and "index.html"
# find directories that contain both "index.php" and "index.html"
ls **/*(D/e:'[[ -e $REPLY/index.php && -e $REPLY/index.html ]]':)
# zsh Special variables
echo EUID:$EUID GID:$GID EGID:$EGID USERNAME:$USERNAME fignore:$fignore mailpath:$mailpath cdpath:$cdpath
echo LINENO:$LINENO RANDOM:$RANDOM SECONDS:$SECONDS COLUMNS:$COLUMNS HISTCHARS:$HISTCHARS UID:$UID
# Append /etc/services at the end of file
# Append
foo' and bar'$ cat /etc/services >> foo >> bar
# Append
exit 1' at the end of all *.sh - files
``$ echo "exit 1" >> *.sh`# identify non-binary files
notbinary() { file --mime $REPLY | grep -iqv binary }ls **/*(.+notbinary)
# z can also cope with sub-directories
~/Pictures/vacation/spain/2018
# but what if i haven't visited 2017 yet?
# or
~/Pictures/vacation/spain/2017
z vac spa 18
~/Pictures/vacation/spain/2018
# but what if i haven't visited 2017 yet?
z vac spain ; cd 2017
# or
z vac spain ; 2017 # with autocd
~/Pictures/vacation/spain/2017
# locate completion function for a given command eg. apt-get
print $^fpath/$_comps[apt-get](N)
/home/phy1729/zsh/Completion/Debian/Command/_apt
# the power of bindkey
# now find what the default bindings are
bindkey
bindkey # which zsh widgets are already boundbindkey -v # set vi as cli editor. 'covers up' many defaultbindkey | grep -i push-line # find out which key a widget is on# now find what the default bindings are
zsh -f # zsh with zero configbindkey
# evolution/trends of tools (via RedHat post)
fgrep -> grep -f
egrep -> grep -e
nslookup OR dig
ifconfig / route --> ip
netstat -> ss
ping 8.8.8.8 # never changes LOL
fgrep -> grep -f
egrep -> grep -e
nslookup OR dig
ifconfig / route --> ip
netstat -> ss
ping 8.8.8.8 # never changes LOL
ls *.^c(.) # all files excluding c files
ls -l *.(png|jpg|gif) # images only
ls *(*) # executables only
ls /etc/**/zsh # which directories contain 'zsh'?
ls **/*(/^F) # list empty directories
ls /etc/*(@) # symlinks only
ls **/*(-@) # list dangling symlinks