{"id":13561586,"url":"https://github.com/tokozedg/sman","last_synced_at":"2025-04-03T17:31:14.507Z","repository":{"id":165981599,"uuid":"55048290","full_name":"tokozedg/sman","owner":"tokozedg","description":":bug: Command-line snippet manager","archived":false,"fork":false,"pushed_at":"2017-12-20T14:21:50.000Z","size":67,"stargazers_count":292,"open_issues_count":3,"forks_count":26,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-04T13:37:43.662Z","etag":null,"topics":["go","sman","snippet-manager"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tokozedg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-03-30T08:59:32.000Z","updated_at":"2024-10-22T11:08:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a27dfc0-cac4-4159-8afd-ad01ddd55491","html_url":"https://github.com/tokozedg/sman","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokozedg%2Fsman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokozedg%2Fsman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokozedg%2Fsman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokozedg%2Fsman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokozedg","download_url":"https://codeload.github.com/tokozedg/sman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247046895,"owners_count":20874736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","sman","snippet-manager"],"created_at":"2024-08-01T13:00:58.837Z","updated_at":"2025-04-03T17:31:09.498Z","avatar_url":"https://github.com/tokozedg.png","language":"Go","funding_links":[],"categories":["Go","go","Command-Line Productivity"],"sub_categories":[],"readme":"# Sman\n[![Build Status](https://travis-ci.org/tokozedg/sman.svg?branch=master)](https://travis-ci.org/tokozedg/sman)\n\n***\nA command-line snippet manager in Go\n\n[![asciicast](https://asciinema.org/a/2e04fxybyyo5ubjk42mk4yuop.png)](https://asciinema.org/a/2e04fxybyyo5ubjk42mk4yuop)\n\n## Install\n\n```shell\nbash -c \"$(curl https://raw.githubusercontent.com/tokozedg/sman/master/install.sh)\"\n```\n\n## Building\n\n* Build with Go\n```bash\ngo get -v github.com/tokozedg/sman\n```\n\n* Add to your rc:\n```bash\n[ -f $GOPATH/src/github.com/tokozedg/sman/sman.rc  ] \u0026\u0026 source $GOPATH/src/github.com/tokozedg/sman/sman.rc\n```\n\n* Optionally copy demo snippets dir or create yours:\n```bash\ncp -r $GOPATH/src/github.com/tokozedg/sman/snippets ~/\n```\n\n## Snippets Examples\n\n```yaml\n#~/snippets/shell.yml\n\nsmtp:server: # snippet name\n  do: exec # copy or exec\n  desc: smtp server in python. Prints mails to stdout\n  command: python -m smtpd -n -c DebuggingServer localhost:1025\n\n```\n\n```yaml\n#~/snippets/shell.yml\n# Sman will ask input for placeholder \u003c\u003cport\u003e\u003e\ntcpdump:port:\n  do: copy\n  desc: listen traffic on port\n  command: tcpdump -nqt -s 0 -A -i eth0 port \u003c\u003cport\u003e\u003e\n```\n\n```yaml\n#~/snippets/shell.yml\n# To execute multiline commands, separate lines by semi-colon\ncurl:upload:\n  do: exec\n  command: \u003e\n    gpg -c \u003c\u003cfile\u003e\u003e;\n    curl --upload-file \u003c\u003cfile\u003e\u003e.gpg https://transfer.sh/\u003c\u003cfile\u003e\u003e.gpg\n```\n\n* You can export command to a separate file located at: `SMAN_SNIPPET_DIR/\u003cSnippet File Name\u003e/\u003cSnippet Name\u003e`\n\n\n\n## Placeholders\n\n```\n\u003c\u003cname(option1,option2)#Description\u003e\u003e\n```\n* Include placeholder anywhere within snippet command\n* Name is the only mandatory field\n* You can have multiple placeholders with the same name. After input all of them will be replaced\n* Use `\\` to escape comma in options\n\n## Usage Examples\n\n### Run snippet\n\n```bash\ns run [-f \u003cFILE\u003e]  [-t \u003cTAG\u003e] \u003cSNIPPET\u003e [placeholder values...] [-cxyp]\n```\n```bash\n~|⇒ s run -f shell curl:upload test.tar.gz -x\n----\ngpg -c test.tar.gz; curl --upload-file test.tar.gz.gpg https://transfer.sh/test.tar.gz.gpg\n----\nExecute Snippet? [Y/n]:\n```\n\n```bash\n~|⇒ s run curl:ip\n----\ncurl canhazip.com\n----\nExecute Snippet? [Y/n]:\n```\n\n### Show snippet\n\n```bash\ns show [-f \u003cFILE\u003e] [-t \u003cTAG\u003e] \u003cSNIPPET\u003e\n```\n\n### List and search snippets\n```bash\ns ls [-f \u003cFILE\u003e] [-t \u003cTAG\u003e] [\u003cPATTERN\u003e]\n```\n\n* Pattern is matched against snippet name, command and description\n\n### List and search snippets for scripts\n\n* Use the `--porcelain` flag to produce machine-readable output for scripting.\n\n```bash\n$ s ls service:disable --porcelain\nshell\tservice:disable\tubuntu\tdisable service on ubuntu\n\n$ s ls add --porcelain | cut -f 2 | xargs echo\nvhost:add user:add alias:add sshconfig:add user:group\n```\n\n* The output is `\\t`-separated. The colums are:\n 1. Snippet file\n 2. Snippet name\n 3. Tags (`,`-separated)\n 4. Description\n\n## Fuzzy search file and snippet name:\n```bash\n# `r` is alias for `run`\n# matches file `mysql` and snippet `database:dump`\n\n~|⇒ s r -f sql dmp\n----\nmysqldump -u[user] --lock-tables=[lock] -p[pass] -h [host] [database] \u003e [database].sql\n----\n[user]:\n```\n\n## Config\n```bash\n# Append history can be useful to avoid re-entering all placeholders when you need to change single parameter.\nexport SMAN_APPEND_HISTORY=false\n# Snippet directory\nexport SMAN_SNIPPET_DIR=\"~/snippets\"\n# Ask confirmation before executing\nexport SMAN_EXEC_CONFIRM=true\n# Set shell color of groups in ls, see https://misc.flogisoft.com/bash/tip_colors_and_formatting\nexport SMAN_LS_COLOR_FILES=1,4,35\n```\n\n## vim-sman\n\nInstall vim plugin for better snippets colors:\n\n*  [Pathogen](https://github.com/tpope/vim-pathogen)\n  * `git clone https://github.com/tokozedg/vim-sman.git ~/.vim/bundle/vim-sman`\n*  [vim-plug](https://github.com/junegunn/vim-plug)\n  * `Plug 'tokozedg/vim-sman'`\n*  [NeoBundle](https://github.com/Shougo/neobundle.vim)\n  * `NeoBundle 'tokozedg/vim-sman'`\n*  [Vundle](https://github.com/VundleVim/Vundle.vim)\n  * `Plugin 'tokozedg/vim-sman'`\n\n## Contributing\n\nIf you'd like to contribute, please fork the repository and make changes as\nyou'd like. Pull requests are warmly welcome, especially if you make a good snippet file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokozedg%2Fsman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokozedg%2Fsman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokozedg%2Fsman/lists"}