#v1# set number of lines to display per page
HELP_LINES_PER_PAGE=20
+#v1# set location of help-zle cache file
+HELP_ZLE_CACHE_FILE=~/.cache/zsh_help_zle_lines.zsh
#f1# helper function for help-zle, actually generates the help text
help_zle_parse_keybindings()
{
#v1# choose files that help-zle will parse for keybindings
((${+HELPZLE_KEYBINDING_FILES})) || HELPZLE_KEYBINDING_FILES=( /etc/zsh/zshrc ~/.zshrc.pre ~/.zshrc ~/.zshrc.local )
+ if [[ -r $HELP_ZLE_CACHE_FILE ]]; then
+ local load_cache=0
+ for f ($KEYBINDING_FILES) [[ $f -nt $HELP_ZLE_CACHE_FILE ]] && load_cache=1
+ [[ $load_cache -eq 0 ]] && . $HELP_ZLE_CACHE_FILE && return
+ fi
+
#fill with default keybindings, possibly to be overwriten in a file later
#Note that due to zsh inconsistency on escaping assoc array keys, we encase the key in '' which we will remove later
local -A help_zle_keybindings
done
#sort lines alphabetically
help_zle_lines=("${(i)help_zle_lines[@]}")
+ [[ -d ${HELP_ZLE_CACHE_FILE:h} ]] || mkdir -p "${HELP_ZLE_CACHE_FILE:h}"
+ echo "help_zle_lines=(${(q)help_zle_lines[@]})" >| $HELP_ZLE_CACHE_FILE
+ zcompile $HELP_ZLE_CACHE_FILE
}
typeset -g help_zle_sln
typeset -g -a help_zle_lines
alias r-x='chmod 755'
# some useful aliases
-#a2# Execute \kbd{mkdir -o}
+#a2# Execute \kbd{mkdir -p}
alias md='mkdir -p'
+#a2# Remove current empty directory. Execute \kbd{cd ..; rmdir $OLDCWD}
+alias rmcdir='cd ..; rmdir $OLDPWD || cd $OLDPWD'
# console stuff
#a2# Execute \kbd{mplayer -vo fbdev}
bufwords=(${(z)LBUFFER})
iword=${#bufwords}
bufwords=(${(z)BUFFER})
- PATHTOMKDIR="$bufwords[iword]"
+ PATHTOMKDIR="${(Q)bufwords[iword]}"
fi
[[ -z "${PATHTOMKDIR}" ]] && return 1
if [[ -e "${PATHTOMKDIR}" ]]; then
emulate -L zsh
setopt extendedglob
local -a -U disks
+ local -A mountinfo
disks=( /dev/disk/by-id/*(@:A) )
+ [[ -r /proc/mounts ]] && for cline ( "${(f)$(</proc/mounts)[@]}" ) mountinfo["${cline[(w)1]:A}"]="${cline[(w)2,-1]}"
for dev in "$disks[@]"; do
print ${fg_bold[red]}${dev}${reset_color} /dev/disk/by-label/*(@e/'[[ ${REPLY:A} == $dev ]] && REPLY=${fg[blue]}LABEL=${REPLY:t}${reset_color}'/N) /dev/disk/by-uuid/*(@e/'[[ ${REPLY:A} == $dev ]] && REPLY=${fg[green]}UUID=${REPLY:t}${reset_color}'/N)
- print -f " %s\n" /dev/disk/by-id/*(@e/'[[ ${REPLY:A} == $dev ]]'/N:t)
+ [[ -n "${mountinfo["$dev"]}" ]] && print -f " Mount: %s -t %s -o %s\n" ${mountinfo["$dev"][(w)1]} ${mountinfo["$dev"][(w)2]} "${mountinfo["$dev"][(w)3,-5]}"
+ for sysdevsize ( /sys/block/${dev:t}/size(N) /sys/block/${${dev:t}%%<->}/${dev:t}/size(N) ) \
+ print -f " Size: %.3f GiB (%d Byte)\n" $(($(<$sysdevsize)/(2.0*1024.0*1024.0))) $(($(<$sysdevsize)*512))
+
+ print -f " Id: %s\n" /dev/disk/by-id/*(@e/'[[ ${REPLY:A} == $dev ]]'/N:t)
done
}
fi
elif [[ "$ARCHIVE" == (#s)(https|http|ftp)://* ]] ; then
if check_com curl; then
- WGET_CMD="curl -k -s -o -"
+ WGET_CMD="curl -L -k -s -o -"
elif check_com wget; then
WGET_CMD="wget -q -O - --no-check-certificate"
else
#f5# View all README-like files in current directory in pager
readme() {
emulate -L zsh
+ setopt extendedglob
local files
- files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
+ files=(./(#i)*(read*me|lue*m(in|)ut|lies*mich)*(NDr^/=p%))
if (($#files)) ; then
$PAGER $files
else