Skip to content

Instantly share code, notes, and snippets.

@gdisneyleugers
Created August 14, 2014 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdisneyleugers/60287590ca6deb575bae to your computer and use it in GitHub Desktop.
Save gdisneyleugers/60287590ca6deb575bae to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <ncurses.h>
/* to compile run gcc shell.c -o shell -Wformat-security -Wint-conversion -Wincompatible-pointer-types -lreadline -lgtk -lncurses */
int shell(void)
{
rl_bind_key('\t', rl_complete);
using_history ();
const char *b[4096];
initscr();
sleep(0);
const char *a = fgets("shell->", *b, 4096);
printw(a);
char *f = readline("shell-> ");
printw(f);
char ex = 'exit';
if (*f == &ex ) {
endwin();
exit(0);
}
add_history(f);
const char *d = system(f);
return(0);
}
int main(void)
{
while(1)
shell();
return(0);
if(1) {
exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment