Snipline Docs

Examples

Every developer's workflow is different. These commands will hopefully be a source of inspiration and reference for your own snippets.

If you think you have a useful command, why not tweet us about it? 😀

General commands

Copying SSH key to clipboard (MacOS)

This command copies your public key from the .ssh directory. Set your most commonly used key to the default.

1
cat ~/.ssh/#{[Key=id_rsa.pub]} | pbcopy


Grep - Search a directory for search term

Use Grep to display files that contain a search term - optionally only output the file name (useful with cached/minified files) and filter by file type

1
grep -rnw#{[Only Display Filenames?=l]} '#{[Directory=./]}' -e '#{[Searchterm]}' #{[Include=--include \*.js]}


Curl requests

Quickly create a curl request for a specific URL and choose any request type. Optionally set headers such as Authorization Tokens, Content-Type, etc.

1
curl '#{[URL=https://]}' -X '#select{[Type=GET,POST,DELETE,PUT]}' -H 'Authorization: Bearer #{[Auth=]}'


Curl request with JSON responses

Use jq to parse JSON responses and store the response in a file with the date appended.

1
curl '#{[URL=https://]}' -X '#select{[Type=GET,POST,DELETE,PUT]}' -H 'Authorization: Bearer #{[Auth=]}' | jq > #{[File=file]}-`date '+%Y-%m-%d'`.json


If you want to create a symlink of a directory that's in the same directory e.g. public_html -> web then cd into the directory and run

1
ln -s #{[Existing=web]} #{[Shortcut=public_html]}


Find files that start with a string

1
find . -type f -name #{[String]}\*


Remove files that start with a string

Make sure to do a dry run with the above command first!

1
find . -type f -name #{[String]}\* -exec rm {} \;


PHP commands

Local server

Start a local php server with default port of 8000 and /, web/, and public_html for default public directory choices.

1
php -S localhost:#{[Port=8000]} -t #select{[Public Directory=/,web/,public_html/]}


Create a new admin in Magento 2

1
php bin/magento admin:user:create --admin-user="#{[Username=myname]}" --admin-password="#{[Password]}" --admin-email="#{[Email=your@email]}" --admin-firstname="#{[Firstname=Name]}" --admin-lastname="#{[Lastname=Name]}"


MySQL commands

Dump a database

1
mysqldump -u #{[User]} -p #{[Database]} > #{[Database]}-`date '+%Y-%m-%d'`.sql


SQL commands

Create a new database

1
CREATE DATABASE #{[DB]};create user #{[User]}; grant all on #{[DB]}.* to '#{[User]}'@'localhost' identified by '#{[Password]}';


Found an issue with our documentation? Submit an issue/pull request!