I'll be honest and I'll say that I'm a bit lazy sometimes. I'm one of those developers which don't like to repeat same actions again and again. There are dozen of things which I have to do while working on a project. Very often I'm covering the development of several applications and have to switch between them. It's really annoying process. I hate to have many opened tabs in my browser, many consoles or several code editors. I always try to improve my productivity by automating tasks. I think that even switching between opened applications takes too much time.
Auxilio is an extension for Google Chrome which helps me to solve some of the above problems. During the development I realize that it's much more then a tool for workflow optimization. Here is what I'm using it for:
-
interactive shell/console
-
file browser
-
front-end testing
-
real-time code editing
-
git helper
-
project manager / workflow optimization
-
profiling
-
marker
-
playing tetris :)
Before to give you more details about every of the items above, let me clarify how everything works. Auxilio has two parts. The first one is of course an extension of my favorite browser and the second one is a nodejs application, which I called auxilio-backend. The extension uses web sockets (socket.io) and connects to the node app. You can do a lot of stuff inside your browser. However, there are some tasks which are not permitted. For example you can't watch file for changes or execute shell commands. For these things I decided to use node, because:
- it's simply JavaScript and I'm able to write whatever I want
- it has a lot of modules, which I can use.
If I need to do something inside the browser I'm using the Google's APIs, while the back-end is taking care about the OS related stuff. The extension just sends commands and gets response.
First of all install NodeJS. It's pretty easy. Just go to nodejs.org and click the big green button. The back-end is distributed as node package, so you can easily install it via the node package manager.
npm install -g auxilio-backend
Once everything completes simply run it via
auxilio-backend
You should see
info - socket.io started
Auxilio back-end started.
There are two ways to use an extension for Chrome.
- Open this url and click Add to Chrome button in the upper right corner.
- Download the source code from the GitHub repo. Open chrome://extensions page and check Developer mode. After that click on Load unpacked extension and browse the /src directory.
When you open a new tab Chrome usually shows most visited pages. There are some other things like recent closed pages or installed apps, but actually I didn't use them very often. That's why I decided to customize that part of the browser. The new page shows the current date and time, good quotes made by smart developers and of course a button which points to the old page if needed.
DevTools is a great instrument for programmers. Luckily there is an API which we can use to add new tabs. It is also good that you can open the panel with shortcuts like Ctrl + J or Ctrl + I. However, there is no way to associate a shortcut to your custom tab. So, what I'm doing is to open DevTools and use Ctrl + [ or Ctrl + ] to navigation between the tools.
Follow the link above and click the green button Add to Chrome or check the steps below
-
Download the source code of the extension (you will use the content of the src folder)
-
Open Google Chrome and type the following thing in the address bar
chrome://extensions
-
Check the Developer mode option
-
Click on Load unpacked extension... and browse the src folder
npm install -g auxilio-backend
An in-depth article about the extension - link
Clearing the current console's output.
- format: clear
- returns: null
clear
In script
clear()
Compares values. (Have in mind that it works only with strings and numbers.)
- format: compare [title] [value1] [expression] [value2]
- returns: Boolean (true | false)
Command line
compare "Check those values" 10 == 20
Command line (chaining)
date true && read monthName && compare "Is it July?" July ==
In script
compare('"My title here"', 10, "==", 10, function(res) { console.log(res); })
Gets the current date.
- format: date [true | false]
- returns: String if you use just date and object if use data true
6 July 2013 14:43
Object { day: 6 hour: 14 minutes: 41 month: 6 monthName: "July" year: 2013 }
Command line
date
Command line (chaining)
date true && read monthName && info
In script
date("true", function(date) { console.log(date.year); })
Delays the next command
- format: delay [miliseconds]
- returns: null
Command line
delay 2000
Command line (chaining)
echo A && delay 2000 && echo B
In script
delay(2000, function() { console.log("hello"); })
Comparison of files (text and json) or strings.
- format: diff
diff [string1] [string2] - returns: Object containing the differences.
Opens a browse window for picking two files
diff
Comparing two strings
diff "Hello world!" "Hello world, dude!"
Command line (chaining)
date true && read monthName && diff "Current month is July"
In script
diff('"Hello world!"', '"Hello world dude!"', function(res) { console.log(res); })
Executes a given command. Accepts commands separated by &&.
- format: exec [command/s]
- returns: The result of the executed command.
Command line
exec echo "test"
Command line (chaining)
readfile showing-date.aux && exec
In script
exec("echo Hello world! && date true", function(res) { console.log(res); })
Outputs the current console's history.
- format: history
- returns: null
Command line
history
Clearing the current console's output.
- format: l
- returns: null
Just type l and press Enter
l
Shows manual page about available commands.
- format: man
man [regex | name of a command]
man exporttomarkdown - returns: Manual page/s
Command line
man
Gives you ability to place markers on the current page. screenshot command could be used after that.
- format: marker
- returns: null
Command line
marker
The command simply passes the given argument to its callback
- format: middleman [resource]
- returns: The result of the previous command in the chain.
Command line (chaining)
date && middleman && echo
Sometimes is needed to stop passing a result from one command to another. This command simply calls its callback without any arguments.
- format: pass
- returns: null
Command line (chaining)
date true && pass && echo That's a string without date.
Extracts a value from json object
- format: read [path] [json object]
- returns: Value of a property of the sent object
Command line (chaining)
date true && read day && success Today is
If you have a complex object like this one {data: { users: [10, 11, 12] }}
read data.users[1]
Sends ajax request and returns the result.
- format: request [url]
request [url] [raw (true | false)] - returns: Response of the given url or the raw output if raw parameter is passed.
Command line
request github.com && echo
Getting raw html
request github.com true && echo
In script
This command is not supported in external scripts.
Just bypasses the given arguments as string
- format: stringify [text or object]
- returns: string
Command line
date true && stringify && info
Define a variable.
- format: var [name] [value]
- returns: The value of the variable
Command line
var n 10 echo $$n is a great position
Command line (chaining)
date && var currentDate echo Current date is $$currentDate
Managing aliases.
- format: alias [name] [value]
- returns: Check the examples.
Showing current added aliases
alias
Opening an editor for adding alias
alias my-alias-name
Directly pass the content of the alias
alias my-alias-name date && echo
Clearing all aliases
alias clearallplease
Exporting all aliases
alias exportallplease
Command line (chaining)
readfile showing-date.aux && exec
In script
alias('"my-alias-name"', "date && echo", function() { console.log("Alias added."); })
Manages your current profile file. Every time when you start auxilio the extension reads the files of the given directory (recursively). It searches for files which start with function and register them as commands. If the file starts with exec. directly executes the function inside the file. Check man run for more information.
- format: profile [path]
- returns: Check examples.
Getting current profile path
profile
Setting profile
profile D:/work/auxilio/profile
Clearing profile
profile clear
Stores key-value pairs by using chrome.storage.sync API.
- format: storage [operation] [key] [value]
- returns: The result of the executed command.
Storing variable
storage put username Auxilio
Getting variable
storage get username
Removing variable
storage remove username
Get all variable
storage get
Opens an editor for editing files. Available shortcuts:
Ctrl+S - save
Esc - closing the editor
Ctrl+[ - showing previous file
Ctrl+] - showing next file
- format: editor [file]
- returns: null
Open file for editing
editor ./styles.css
Formats an output of jshint execution. The command is meant to be used together with watch.
- format: jshint [{filePath: [path], jshint: [jshint]}]
- returns: null
Watching a javascript file for changes and passing the result to jshint.
watch start ./code.js jshint
Runs jasmine tests.
- format: runjasmine [path]
- returns: null
Command line
runjasmine ./tests
Shows a text (question) with two options - YES and NO.
- format: formconfirm [question]
- returns: Boolean (true | false)
Command line
formconfirm Are you sure?
In script
formconfirm('"Are you sure?"', function(res) { console.log(res ? "yes" : "no"); });
Shows a simple form with input[type="file"] and button. Use the callback of the command to get the content of the file.
- format: formfile [title]
- returns: Content of the file
Command line
formfile Please choose a file.
In script
formfile('"Please choose a file."', function(fileContent) { console.log(fileContent); })
Shows a simple form with input and button.
- format: forminput
forminput [title]
forminput [title] [default text] - returns: string
Command line
forminput "Please type your age." 18
In script
forminput('"Please type your age."', 18, function(age) { console.log(age); });
Shows a simple form with textarea and button. Use the callback of the command to get the text submitted by the form.
- format: formtextarea
formtextarea [title]
formtextarea [title] [text] - returns: string
Command line
formtextarea "Please type your bio." "Sample text" && echo
In script
formtextarea('"Please type your bio."', '"Sample text"', function(bio) { console.log(bio); });
Tetris game.
- format: tetris
tetris [level to start from] - returns: null
Command line
tetris
Outputs message.
- format: echo [text]
- returns: string
Command line
echo Hello world!
In script
echo("Hello world!", function(res) { console.log(res); });
Outputs message in raw format. Even the html is shown as string.
- format: echoraw [text]
- returns: string
Command line
echoraw Hello world!
In script
echoraw("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: echoshell [text]
- returns: string
Command line
echoshell Hello world!
In script
echoshell("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: error [text]
- returns: string
Command line
error Hello world!
In script
error("Hello world!", function(res) { console.log(res); });
hidden
Outputs invisible content. I.e. useful when you have to add hidden html markup.
- format: hidden [text]
- returns: string
Command line
hidden <input type="hidden" name="property" />
In script
hidden("<input type="hidden" name="property" />", function(res) { console.log(res); });
Adds <hr /> tag to the console's output panel
- format: hr
- returns: null
Command line
hr
In script
hr();
Outputs message.
- format: info [text]
- returns: string
Command line
info Hello world!
In script
info("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: small [text]
- returns: string
Command line
small Hello world!
In script
small("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: success [text]
- returns: string
Command line
success Hello world!
In script
success("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: title [text]
- returns: string
Command line
title Hello world!
In script
title("Hello world!", function(res) { console.log(res); });
Outputs message.
- format: warning [text]
- returns: string
Command line
warning Hello world!
In script
warning("Hello world!", function(res) { console.log(res); });
Sometimes you need to execute a series of commands, but you want to keep the context, i.e. the current directory.
- format: block [operation]
- returns: null
Command line
block start && cd ../../ && echo Do some stuff here && block end
In script
block("start", function() { shell("cd ../../", function() { block("end"); }); });
Returns the current working directory of auxilio-backend.
- format: cwd
- returns: string
Command line
cwd
In script
cwd(function(res) { console.log(res); });
Read content of a file.
- format: readfile [file]
- returns: string
Command line
readfile ./README.md
In script
readfile("./README.md", function(content) { console.log(content); });
Register or execute commands stored in external files. The files should contain valid javascript which is actually a function definition in the following format:
function nameOfMyFunction(args) { ...Normally the content of the file is registered as a command, but if the filename starts with exec. the function is executed immediately. For example:}
run ./exec.myscript.js
- format: run [path]
- returns: Result of the function.
Importing directory
run ./files
Importing file
run ./files/myscript.js
In script
run("./myfiles", function(res) { console.log(res); });
Executes shell command. Have in mind that once you type something in the console and it doesn't match any of the auxilio's commands it is send to the shell
- format: shell [command]
- returns: string
Command line
shell ls
In script
shell("ls", function(res) { console.log(res); });
Shows a directory tree.
- format: tree
tree [regex]
tree [deep]
tree [suppressdisplay] - returns: string
Command line
tree
Showing files by type
tree \.css
Showing only two levels
tree 2
Suppress the output to the console
tree suppressdisplay
In script
tree(2, function(res) { console.log(res); });
Watch directory or file for changes.
- format: watch [operation] [id or path] [callback command]
- returns: string
Get the current watchers and their ids
watch
Start watching
watch start ./ echo
Start watching and call multiple callbacks
watch start ./ "jshint, echo"
Stop watcher
watch stop 1
Stop all watchers
watch stopall
In script
watch("start", "./", "echo", function(res) { console.log(res); });
Write content to a file.
- format: writefile [file] [content]
- returns: string
Command line
writefile ./test.txt Sample text here.
In script
writefile("./test.txt", "Sample text here", function(res) { console.log("File saved successfully."); });
Clicks an element on the page and returns the result immediately. Use filter parameter to filter the selected elements. Actually performs indexOf method agains the html markup of the selected element.
- format: pageclick [selector] [filter]
- returns: Object containing the matched elements.
Command line
pageclick "body > .my-link-class"
Filter the selected elements
pageclick "body > .my-link-class" "link label"
In script
pageclick("body > .my-link-class", function(res) { console.log("Element clicked."); });
Clicks an element on the page and waits till the page is updated. Use filter parameter to filter the selected elements. Actually performs indexOf method agains the html markup of the selected element.
- format: pageclickw [selector] [filter]
- returns: Object containing the matched elements.
Command line
pageclickw "body > .my-link-class"
Filter the selected elements
pageclickw "body > .my-link-class" "link label"
In script
pageclickw("body > .my-link-class", function() { console.log("Element clicked."); });
Checks if there is an element matching the provided selector and containing the provided text.
- format: pagecontains [selector] [text]
- returns: Boolean (true | false)
Command line
pagecontains "body > a" "my link"
In script
pagecontains("body > a", "my link", function(res) { console.log(res ? "yes" : "no"); });
Checks if there is an element matching the provided selector. Use filter parameter to filter the selected elements. Actually performs indexOf method agains the html markup of the selected element
- format: pageexpect [selector] [filter]
- returns: Object containing the matched elements.
Command line
pageexpect a.my-link-class label
In script
pageexpect("a.my-link-class", "label, function(res) { console.log(res); });
Highlights element/elements on the page. Use filter parameter to filter the selected elements. Actually performs indexOf method agains the html markup of the selected element.
- format: pagehighlight [selector] [filter]
- returns: Object containing the matched elements.
Command line
pagehighlight a
In script
pagehighlight("a", function(res) { console.log(res); });
Inserts css code in the context of the current page
- format: pageinsertcss [css code]
- returns: string
Command line
pageinsertcss body { background: #F00 !important; }
In script
pageinsertcss("body { background: #F00 !important; }", function() { console.log("CSS applied."); });
Executes javascript code in the context of the current page
- format: pageinsertjs [js code]
- returns: string
Command line
pageinsertjs "document.querySelector('body').click();"
In script
pageinsertjs("document.querySelector('body').click();", function(res) { console.log(res); });
Executes javascript code in the context of the current page and waits till the current page is updated
- format: pageinsertjsw [js code]
- returns: string
Command line
pageinsertjsw "document.querySelector('body').click();"
In script
pageinsertjsw("document.querySelector('body').click();", function(res) { console.log(res); });
Returns the number of matched elements and the elements in raw html string format. Use filter parameter to filter the selected elements. Actually performs indexOf method agains the html markup of the selected element.
- format: pagequery [selector] [filter]
- returns: Object containing the matched elements.
Command line
pagequery a "label of the link"
In script (checks if there is links on the page)
pagequery("a", function(res) { console.log(res); });
Loads another page in the current tab.
- format: load [url]
- returns: null
Command line
load github.com
In script
load("github.com", function() { console.log("new page loaded"); });
Creates a new tab.
- format: newtab
newtab [url] [active (true | false)] - returns: null
Command line
newtab github.com
In script
newtab("github.com", "false", function() { console.log("new tab loaded"); });
Refreshes the current tab's page
- format: refresh
- returns: null
Command line
refresh
In script
refresh(function() { console.log("The current page is refreshed."); });
Makes a screenshot of the current tab and loads it in a new tab.
- format: screenshot
- returns: null
Command line
screenshot
In script
screenshot(function() { console.log("The screenshot is made."); });