From: Michael D. Lowis Date: Thu, 21 Nov 2019 04:26:38 +0000 (-0500) Subject: added wrapper script to run a shell in tide like a terminal X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=bfaed46959f939ddcbce552fac4fefa507ebc560;p=projs%2Ftide.git added wrapper script to run a shell in tide like a terminal --- diff --git a/.gitignore b/.gitignore index c229b42..87035ea 100644 --- a/.gitignore +++ b/.gitignore @@ -44,17 +44,8 @@ xedit xpick DELETEME tests/libedit -tests/term -term -xcpd tests/tide -tide -pick tests/pick -hl-cpp -pty -tctl -flaws.txt edit registrar fetch @@ -65,3 +56,5 @@ bin/anvil .rscons* build/ bin/fetchsel +pick +tide \ No newline at end of file diff --git a/bin/term b/bin/term new file mode 100755 index 0000000..cbefbd9 --- /dev/null +++ b/bin/term @@ -0,0 +1,3 @@ +#!/bin/sh +export TERM=dumb +tide -c "$SHELL" \ No newline at end of file diff --git a/src/tide.c b/src/tide.c index 281f7ae..5143166 100644 --- a/src/tide.c +++ b/src/tide.c @@ -795,7 +795,8 @@ static void usage(void) "\n -E 0,1 Enable/disable expanding tabs to spaces" "\n -N 0,1 Enable/disable dos line ending style" "\n -T str String to use for the tags region" - "\n -C str Set the shell to use for command execution\n", + "\n -C str Set the shell to use for command execution\n" + "\n -c cmd Runs command interactively in the window\n", ARGV0); exit(1); } @@ -820,6 +821,7 @@ static void edit_file(char* file, int line_num) int main(int argc, char** argv) { + char* termcmd = NULL; long int line_num = 0; #define BOOLARG() (EOPTARG(usage()), optarg_[0] == '0' ? 0 : 1) #define STRARG() (EOPTARG(usage())) @@ -832,6 +834,7 @@ int main(int argc, char** argv) case 'N': DosLineFeed = BOOLARG(); break; case 'T': TagString = STRARG(); break; case 'C': ShellCmd[0] = STRARG(); break; + case 'c': termcmd = STRARG(); break; case 'l': line_num = NUMARG(); break; default: usage(); break; } @@ -859,9 +862,17 @@ int main(int argc, char** argv) } /* set host name property */ - char host[8192]; - if (!gethostname(host, sizeof(host))) - win_prop_set("HOST", "host", host); + char buf[8192]; + if (!gethostname(buf, sizeof(buf))) + win_prop_set("HOST", "host", buf); + + /* exit */ + if (termcmd) + { + termcmd = strmcat("&", termcmd, 0); + cmd_exec(termcmd); + free(termcmd); + } /* now create the window and start the event loop */ #ifndef TEST