commit d5ca332ad5f6fc0216b1dc3611debbe59a4305d7
parent 10da18d47d5a15c45e8ae5c3952cf1b8ebd751cc
Author: Jaromil <jaromil@dyne.org>
Date: Sun, 19 Mar 2017 22:39:37 +0100
fix edit for option_params
Diffstat:
2 files changed, 11 insertions(+), 62 deletions(-)
diff --git a/src/jaro b/src/jaro
@@ -689,7 +689,7 @@ main() {
exitcode=$?
;;
- edit|vim) edit_file ${PARAM} ;;
+ edit|vim) edit_file ${option_params} ;;
open) x_mutt -f ${PARAM} ;;
preview) preview_file ${PARAM} ;;
diff --git a/src/zlibs/helpers b/src/zlibs/helpers
@@ -186,32 +186,31 @@ jarovim() {
}
edit_file() {
- fn edit_file
- [[ "${EDITOR}" = "" ]] || { _editor="${EDITOR}" }
- [[ "${JARO_EDITOR}" = "" ]] || { _editor="$JARO_EDITOR" }
- [[ "$_editor" = "" ]] && { _editor=vim }
+ fn edit_file $*
+ _editor=${EDITOR:-vim}
+ _editor=${JARO_EDITOR:-$_editor}
req=(_editor)
ckreq || return 1
func "selected editor: $_editor"
case $_editor in
# refine settings for email
- vi|vim) jarovim "${PARAM}"; return $? ;;
- emacs) emacsclient "${PARAM}"; return $? ;;
- *) ${=_editor} "${PARAM}"; return $? ;;
+ vi|vim) jarovim "$*"; return $? ;;
+ emacs) emacsclient "$*"; return $? ;;
+ *) ${=_editor} "$*"; return $? ;;
esac
# if we are here we need to guess
case $OS in
- MAC) open -t ${=PARAM} ;;
+ MAC) open -t $* ;;
GNU)
ps ax|grep '[e]macs' > /dev/null
if [ $? = 0 ]; then
- emacsclient -a ${=PARAM}
+ emacsclient -a $*
elif command -v vim > /dev/null; then
- jarovim ${=PARAM}
+ jarovim $*
elif command -v nano > /dev/null; then
- nano -m -S -Q ">" -I -E -D -T 4 -U -W -c -i -k -r 72 ${=PARAM}
+ nano -m -S -Q ">" -I -E -D -T 4 -U -W -c -i -k -r 72 $*
else
error "No editor found, please configure the JARO_EDITOR environment variable."
fi
@@ -361,53 +360,3 @@ cert() {
notice "Done importing most common certificates."
return 0
}
-
-######################
-# obsoleted
-
-
-# opens and closes a ramdisk for temporary files
-# users can do this explicitly between session to speed up operations
-ramdisk() {
- case $OS in
- GNU)
- # TODO
- # not so urgent, since usually /dev/shm is mounted and writable
- ;;
- MAC)
- case ${PARAM[1]} in
- open)
- mount | grep 'JaroTmp' > /dev/null
- { test $? = 0 } && {
- error "A Jaro Mail ramdisk is already open"
- return 1 }
- { test -z ${PARAM[2]} } && { size=10 } || { size=${PARAM[2]} }
- act "Creating ramdisk of ${size}MB"
-
- # 2048 is a megabyte here
- devsize=$((1024*2*$size))
- devname=`hdid -nomount ram://${devsize}`
- act "Mounting ramdisk on $devname"
- diskutil eraseVolume HFS+ JaroTmp `basename $devname` > /dev/null
- { test $? != 0 } && {
- error "Error initializing ramdisk"
- hdiutil detach `basename $devname`
- return 1 }
- notice "Operation successful, ramdisk ready on /Volume/JaroTmp"
- TMPRAM=1
- ;;
- close)
- devname=`mount | awk '/JaroTmp/ {print $1}'`
- { test "$devname" = "" } && {
- error "No ramdisk seems to be open"
- return 1 }
- act "Unmounting ramdisk: $devname"
- diskutil unmount /Volumes/JaroTmp > /dev/null
- hdiutil detach `basename $devname` > /dev/null
- notice "Ramdisk succesfully detached"
- TMPRAM=0
- ;;
- esac
- ;;
- esac
-}