1# Aliases for sh/dash/ash/bash/ksh/zsh in JOE shell window 2 3joehelp () { 4 echo "clear - erase buffer" 5 echo "joe - edit file" 6 echo "math 1+2 - calculator" 7 echo "pop - dismiss shell" 8 echo "parse [cmd] - grep parse command" 9 echo "parserr [cmd] - compile parse command" 10 echo "release - drop parsed messages" 11 echo "markb - mark beginning of region" 12 echo "markk - mark end of region" 13 echo "mark cmd - mark output of command" 14} 15 16# Clear edit buffer 17joe_clear () { 18 echo -n '{'shell_clear'}' 19} 20 21# Release errors 22joe_release () { 23 echo -n '{'shell_release'}' 24} 25 26# Set marked region beginning 27joe_markb () { 28 echo -n '{'shell_markb'}' 29} 30 31# Set marked region end 32joe_markk () { 33 echo -n '{'shell_markk'}' 34} 35 36 37# Mark command result 38joe_mark () { 39 joe_markb 40 $* 41 joe_markk 42} 43 44# Parse command result (or whole buffer if no arg) 45joe_parse () { 46 if [ "$1" = "" ]; then 47 echo -n '{'shell_gparse'}' 48 else 49 joe_markb 50 $* 51 joe_markk 52 echo '{'shell_gparse'}' 53 fi 54} 55 56# Parse command result (or whole buffer if no arg) 57joe_parserr () { 58 if [ "$1" = "" ]; then 59 echo '{'shell_parse'}' 60 else 61 joe_markb 62 $* 63 joe_markk 64 echo '{'shell_parse'}' 65 fi 66} 67 68# Use JOE's calculator 69joe_math () { 70 echo -n '{'shell_math,'"'$1'"',shell_rtn!,shell_typemath'}' 71 cat >/dev/null 72} 73 74# Edit a file 75joe_edit () { 76 echo -n '{'shell_edit,'"'$1'"',shell_rtn'}' 77} 78 79# Pop shell window 80joe_pop () { 81 echo -n '{'shell_pop'}' 82} 83 84unalias cd 2>/dev/null 85 86# Change directory 87joe_cd () { 88 # cd $1 - does not work for directories with spaces in their names 89 # cd "$1" - breaks cd with no args (it's supposed to go to home directory) 90 # So we have do this... 91 if [ "$1" = "" ]; then 92 cd 93 else 94 cd "$1" 95 fi 96 # Tell JOE our new directory 97 echo -n '{'shell_cd,shell_dellin!,'"'`pwd`/'"',shell_rtn'}' 98} 99 100alias clear=joe_clear 101alias math=joe_math 102alias edit=joe_edit 103alias joe=joe_edit 104alias pop=joe_pop 105alias cd=joe_cd 106alias parse=joe_parse 107alias parserr=joe_parserr 108alias release=joe_release 109alias markb=joe_markb 110alias markk=joe_markk 111alias mark=joe_mark 112 113# Code to automatically mark and parse output from each command 114# - This is bash specific code 115 116#joe_markb_pre () { 117# joe_markb 118# MARK_FLAG=1 119#} 120 121#joe_markk_post () { 122# if [ "$MARK_FLAG" = "1" ]; then 123# joe_markk 124# MARK_FLAG=0 125# joe_parse 126# fi 127#} 128 129#preexec () { :; } 130 131#preexec_invoke_exec () { 132# [ -n "$COMP_LINE" ] && return # do nothing if completing 133# [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND 134# local this_command=`HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//"`; 135# joe_markb_pre 136# preexec "$this_command" 137#} 138 139#trap 'preexec_invoke_exec' DEBUG 140 141#PROMPT_COMMAND=joe_markk_post 142 143joe_clear 144 145echo 146echo Type joehelp for editor shell commands 147echo 148