+++ /dev/null
-gen-shell - a generic shell based on taskshell
-
-Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-http://www.opensource.org/licenses/mit-license.php
FROM debian:buster-slim AS builder
RUN apt-get update && apt-get install -y cmake gcc g++ git libreadline-dev make
-RUN git clone --recursive --depth 1 https://codeberg.org/armaan/gen-shell.git /app
WORKDIR /app
-RUN cmake --configure .
-RUN cmake --build .
+ENTRYPOINT git clone --recursive --depth 1 https://codeberg.org/armaan/gen-shell.git /app
+CMD cmake --configure . && cmake --build .
FROM debian:buster-slim AS run
RUN apt-get update && apt-get install -y cpp libreadline7 libncurses6
--- /dev/null
+gen-shell - a generic shell based on taskshell
+
+Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+http://www.opensource.org/licenses/mit-license.php
# gen-shell
-![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fbuild.bhojwani.org%2Fjob%2Fgen-shell%2F)
A simple way to turn any command into a shell with arrow key/history support (if compiled with libreadline). Forked from [taskshell](https://github.com/GothenburgBitFactory/taskshell).
## Usage
-////////////////////////////////////////////////////////////////////////////////
-//
-// gen-shell, the generic shell
-//
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez,
-// 2020, Armaan Bhojwani
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// http://www.opensource.org/licenses/mit-license.php
-//
-////////////////////////////////////////////////////////////////////////////////
-
+// gen-shell - the generic shell
+// Copyright (c) 2020, Armaan Bhojwani <code@armaanb.net>
#include <cmake.h>
#include <iostream>
#include <../Sarge/src/sarge.h>
-#include <stdlib.h>
+#include <filesystem>
+#include <vector>
+#include <string>
#ifdef HAVE_READLINE
#include <readline/readline.h>
////////////////////////////////////////////////////////////////////////////////
using namespace std;
+using std::filesystem::exists;
const std::string getResponse(const std::string & prompt) {
std::string response {
string after_command;
sarge.getFlag("after", after_command);
+ string alias_file
+ vector<string> alias_files = {"$XDG_CONFIG_HOME/gen-shell/aliases",
+ "$HOME/.config/gen-shell/aliases"};
+ for(const auto &file : alias_files)
+ {
+ if (exists(file))
+ {
+ alias_file = file;
+ break;
+ }
+ }
+
// Do the stuffs!
while (true) {
- // Display prompt, get input
auto command = getResponse(prompt);
- // Dispatch command
if (command == "<EOF>" || command == "exit" || command == "quit" )
- // if (command == "<EOF>" || command == "exit" )
{
system (after_command.c_str ());
return 0;