Menu

[216589]: / rc / shell.sh  Maximize  Restore  History

Download this file

148 lines (123 with data), 2.8 kB

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