GithubHelp home page GithubHelp logo

tokozedg / sman Goto Github PK

View Code? Open in Web Editor NEW
290.0 8.0 26.0 67 KB

:bug: Command-line snippet manager

License: GNU General Public License v3.0

Go 85.96% Makefile 2.69% Shell 11.35%
snippet-manager sman go

sman's People

Contributors

antham avatar dhhyi avatar ickc avatar readmecritic avatar ryanschulze avatar tokozedg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sman's Issues

placeholder value with space: `panic: runtime error: index out of range`

System info:

  • macOS 10.12.6
  • sman installed via bash -c "$(curl https://raw.githubusercontent.com/tokozedg/sman/master/install.sh)"
# s run -f shell sed:replace 'a d' b c
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/tokozedg/sman/lib.(*Snippet).SetInputs(0xc8200efbb8, 0xc82006ab00, 0x4, 0x6)
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/lib/snippet.go:36 +0x112
github.com/tokozedg/sman/lib.run(0x7fff5fbff5f2, 0xb, 0xc82006ab00, 0x4, 0x6)
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/lib/run.go:87 +0x29f
github.com/tokozedg/sman/lib.glob.func2(0x50ace0, 0xc82006aaf0, 0x5, 0x7)
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/lib/run.go:135 +0x178
github.com/spf13/cobra.(*Command).execute(0x50ace0, 0xc82006aa80, 0x7, 0x7, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:569 +0x869
github.com/spf13/cobra.(*Command).ExecuteC(0x50aae0, 0x50ace0, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:656 +0x56b
github.com/spf13/cobra.(*Command).Execute(0x50aae0, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:615 +0x2d
main.main()
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/main.go:8 +0x23

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1

Notes:

  • command runs fine if there's no space in value

Is it possible to configure colors?

I really like sman, but I would really like to change the color of the categories in the output. The default blue color is very dark in my terminal and very difficult to read on a black background.

Is there a way to configure this color?

Unsure about command options

I'm unsure how | and >- are used on the command line of a snippet file, further documentation would be priceless ๐Ÿ˜„

sman ls doesn't show snippets if the command is located in a separate file

When typing s ls snippets that have commands located in a different files are not shown. For example, taken from the example snippets:

$ s ls
shell:
   alias:add             [----]                   Add Alias And Reload Rc
   curl:ip               [----]                   My External Ip
   curl:upload           [----]                   Encrypt File And Upload To Transfer.Sh
   mount:ram             [----]                   Mount Ram As File System
   ngrep:port            [----]                   Ngrep To Port
   sed:replace           [----]                   Replace String In All Files
   service:disable       [Ubuntu]                 Disable Service On Ubuntu
   service:status        [Centos]                 List All Services
   smtp:server           [----]                   Smtp Server In Python. Prints Mails To Stdout
   tar:file              [----]                   Create A Gzipped Archive
   tcpdump:port          [----]                   Listen Traffic On Port
   user:group            [----]                   Add User To Group

The commands for:file and sshconfig:add are not shown even though exist:

# shell.yml:22
 sshconfig:add:
   do: exec
   desc: add new machine to ssh config

# shell.yml:64
for:file:
  do: exec
  desc: recursive for file loop

Problem resides in sman/lib/snippet.go line 83:
c, _ := ioutil.ReadFile(dir + s.File + "/" + s.Name)

Between dir and s.File there is no slash, resulting that with the default parameters you get (example from my machine):

/home/vagrant/snippetsshell/for:file instead of /home/vagrant/snippets/shell/for:file

adding a / in line 83 solves the problem:

c, _ := ioutil.ReadFile(dir + "/" + s.File + "/" + s.Name)

$ s ls
shell:
   alias:add             [----]                   Add Alias And Reload Rc
   curl:ip               [----]                   My External Ip
   curl:upload           [----]                   Encrypt File And Upload To Transfer.Sh
   for:file              [----]                   Recursive For File Loop
   mount:ram             [----]                   Mount Ram As File System
   ngrep:port            [----]                   Ngrep To Port
   sed:replace           [----]                   Replace String In All Files
   service:disable       [Ubuntu]                 Disable Service On Ubuntu
   service:status        [Centos]                 List All Services
   smtp:server           [----]                   Smtp Server In Python. Prints Mails To Stdout
   sshconfig:add         [----]                   Add New Machine To Ssh Config
   tar:file              [----]                   Create A Gzipped Archive
   tcpdump:port          [----]                   Listen Traffic On Port
   user:group            [----]                   Add User To Group

fatal error: unexpected signal during runtime execution

Hi,

I just installed sman (by bash -c "$(curl https://raw.githubusercontent.com/tokozedg/sman/master/install.sh)") and the installation seemed to work fine, however, when I run s ls after the installation I got the following error:

โฏ s ls
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x395880f3e42a pc=0x1be230]

goroutine 1 [running]:
runtime.throw(0x3ca0c0, 0x2a)
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/panic.go:527 +0x90 fp=0xc820103988 sp=0xc820103970
runtime.sigpanic()
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/sigpanic_unix.go:12 +0x5a fp=0xc8201039d8 sp=0xc820103988
sync.(*Pool).Get(0x50f940, 0x0, 0x0)
	/usr/local/Cellar/go/1.5.3/libexec/src/sync/pool.go:101 +0x40 fp=0xc820103a28 sp=0xc8201039d8
fmt.newPrinter(0xc820064ec0)
	/usr/local/Cellar/go/1.5.3/libexec/src/fmt/print.go:133 +0x27 fp=0xc820103a68 sp=0xc820103a28
fmt.Sprintln(0xc820103bb8, 0x3, 0x3, 0x0, 0x0)
	/usr/local/Cellar/go/1.5.3/libexec/src/fmt/print.go:270 +0x28 fp=0xc820103ab8 sp=0xc820103a68
log.(*Logger).Println(0xc82007c230, 0xc820103bb8, 0x3, 0x3)
	/usr/local/Cellar/go/1.5.3/libexec/src/log/log.go:182 +0x35 fp=0xc820103b00 sp=0xc820103ab8
github.com/spf13/viper.(*Viper).AddConfigPath(0xc8200fa0e0, 0x35d158, 0x5)
	/Users/Tornike/gocode/src/github.com/spf13/viper/viper.go:323 +0x23a fp=0xc820103bf0 sp=0xc820103b00
github.com/spf13/viper.AddConfigPath(0x35d158, 0x5)
	/Users/Tornike/gocode/src/github.com/spf13/viper/viper.go:319 +0x37 fp=0xc820103c10 sp=0xc820103bf0
github.com/tokozedg/sman/lib.initConfig()
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/lib/root.go:46 +0xc8 fp=0xc820103c98 sp=0xc820103c10
github.com/spf13/cobra.(*Command).preRun(0x50a8e0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:595 +0x5b fp=0xc820103cd0 sp=0xc820103c98
github.com/spf13/cobra.(*Command).execute(0x50a8e0, 0x533be8, 0x0, 0x0, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:542 +0x478 fp=0xc820103de8 sp=0xc820103cd0
github.com/spf13/cobra.(*Command).ExecuteC(0x50aae0, 0x50a8e0, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:656 +0x56b fp=0xc820103ef8 sp=0xc820103de8
github.com/spf13/cobra.(*Command).Execute(0x50aae0, 0x0, 0x0)
	/Users/Tornike/gocode/src/github.com/spf13/cobra/command.go:615 +0x2d fp=0xc820103f20 sp=0xc820103ef8
main.main()
	/Users/Tornike/gocode/src/github.com/tokozedg/sman/main.go:8 +0x23 fp=0xc820103f40 sp=0xc820103f20
runtime.main()
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/proc.go:111 +0x2b0 fp=0xc820103f90 sp=0xc820103f40
runtime.goexit()
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1 fp=0xc820103f98 sp=0xc820103f90

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1

I'm on Mac OS 10.13 (high sierra). I'm I missing something? Thanks!

[Feature] Defaults for placeholders

Great repo! Would love to be able to have defaults for placeholders if possible. Maybe something like <<name(option1,option2)#Description%default>> for the syntax

is it possible config confirmation on command basis ?

some command don't need any arguments. I just want to exec it with out confirmation. but most of time, I need confirmation globally.

so is it possible to config confirmation on command level. e.g.:

xrandr:ls:
  do: exec
  desc: xrandr list monitors with highlight
  confiram: false
  command: xrandr | ack -o '.*connected( primary)?' | awk '{print $1,$2,$3}' | ack --passthru --color '\bconnected' | ack --passthru --color --color-match red 'primary'

Providing platform binaries

Hi,
it could be nice to provide binaries for most common platforms, it's easy with gox for instance, lot of people don't have go and don't want to install it. You would reach a wider audience doing so.

Feature Request: Add a flag for autofilling default placeholder values

I like to use sman in conjunction with other tooling, so something like s r my-snippet placeholder1 placeholder2 | awk ....

If I use a default for a placeholder value, but I do not specify a value for that placeholder, it then hangs on waiting for user input (because sman is checking if I want to use the default or override at execution time). It would really great if I could pass a flag to s r to tell it "just use the default for any placeholder I don't override."

install script is broken

It's unable to download the various releases due to the url being wrong.

version is v1.0.0 and in the script it's set to 1.0.0

Using sman with fzf

Hi there

Nice tool you have there, I really like it. ๐Ÿ‘
I just wanted to add how I started to use sman togheter with fzf (https://github.com/junegunn/fzf):

.zshrc

#sman
alias s=sman
function sman_show() {
    sman ls | fzf --reverse --ansi --bind 'enter:execute(snippet=$(echo {} | awk '\''{print $1}'\'' ); echo $snippet ;sman run $snippet)+abort'
    zle redisplay
}

zle -N sman_show
bindkey '^q' sman_show

this allows one to use the keyboard-shortcut (ctrl-q here) to do the following:

Maybe it is of help. I could make a pr for the readme, but the readme is something a bit more personal to the original author, which is why I assume if you would like to add it, you could phrase it in your own words.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.