Skip to content

Instantly share code, notes, and snippets.

@DiscordLinuxBot
Last active January 16, 2021 05:52
Show Gist options
  • Save DiscordLinuxBot/ef2816a9d4eb0f0ccf5c226a2289255b to your computer and use it in GitHub Desktop.
Save DiscordLinuxBot/ef2816a9d4eb0f0ccf5c226a2289255b to your computer and use it in GitHub Desktop.
bash.bbtag
{exec;libbash}
{if;{get;_bash.aliases};==;;{set;_bash.aliases;["!@#$%"]}}
{function;bashhelp;
{embed;{embedbuild;
title:Help for bash;
color:yellow;
description:__**Usage**__: `bash{if;{commandname};startswith;_autoresponse;{space}-c} <arg> <text>`
A simple bash shell-like command that allows for exporting and fetching variables in bash style syntax. Any arguments not listed below will attempt to run an existing alias. If an alias does not exist, the arguments will be executed using the Paiza API.
**Available arguments**
{repeat;`;3}bash
alias
- Set an alias to execute another tag or custom command.
- USER MUST BE STAFF TO SET ALIASES!
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} alias myalias=exec sometag'
- Output: No output unless error setting alias{//;
echo
- Return the input text and replace any bash style variables with existing values.
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} echo some text, "$VAR"'
- Output: 'some text, some thing'
exec
- Execute a command using the Rextester API.
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} exec echo "bob" | sed 's/b/d/g''
- Output: 'dod'}
export
- Set the value of a variable using bash style syntax.
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} export VAR="some thing"'
- Output: No output unless error exporting variable
env
- View all set variables.
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} env'
- Output: 'list of set variables here'
type
- Interpret how input would be used as a command name.
- Ex: 'bash{if;{commandname};startswith;_autoresponse;{space}-c} type bash'
- Output: 'bash is /bin/bash'
{repeat;`;3}{if;{length;{get;_bash.aliases}};>;1;{newline}
**Aliases**
{repeat;`;3}
{join;{sort;{slice;{get;_bash.aliases};1}};,{space}}
{repeat;`;3}};}}}
{switch;{lower;{args;0}};["export"];{output;{func.export;{args;1;n}}};
["unset"];{output;{func.export;{jget;{split;{args;1;n};=};0}=}};
["exec","test"];{output;{exec;paiza;{args;1;n}}};
["alias"];{output;{func.alias;{args;1;n}}}
{if;{get;_bash.aliases};includes;{jget;{split;{args;1};=};0};{//;do nothing};
{push;_bash.aliases;{jget;{split;{args;1};=};0}}};
["unalias"];{output;{func.alias;{jget;{split;{args;1;n};=};0}=}}
{set;_bash.aliases;{filter;~a;{get;_bash.aliases};
{if;{get;~a};==;{jget;{split;{args;1};=};0};false;true}}};
["type"];{output;{if;{func.type;{args;1}};includes;{args;1} not found;{exec;paiza;{args}};{func.type;{args;1}}}};
["help","--help","-h","helpmenow"];{output;{func.bashhelp}};
{switch;{commandname};
["help"];{func.bashhelp};
{if;{args};==;;{output;{func.bashhelp}};
{if;{func.type;{args;0}};includes;{args;0} not found;
{output;{exec;paiza;{args}}};
{output;{func.exec;{args;0};{if;{length;{argsarray}};>=;2;{args;1;n}}}}}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment