Coder Social home page Coder Social logo

ssam's Introduction

ssam

ssam stands for small scripts and aliases manager. it is a command line tool that helps you manage you scripts and snippets to manage aliases and scripts.

Features :

  • Fuzzy search command line interface based on skim to search through your aliases (think fzf, peco or skim).
  • Your scripts and aliases can be in version control and still be available in your bashrc.
  • Generates configuration for bash and zsh automatically.
  • Your aliases can be templated using variables and ssam will guide you and ask you to choose a value for each variable before runing your alias.

Getting started :

Run cargo run run on the root of this repository to see a demo.

Initial configuration :

Fist, you want to start by creating a repository that will hold your scripts and aliases. Ideally, we recommend it's stucture to be as follow :

├── aliases.yaml
├── scripts
│   └── fancy_ls.sh
└── vars.yaml

Once it's done, you can continue by editing a configuration file in $HOME/.ssam_rc.toml that should look as follow:

scripts_dir="./examples/oneliners/scripts"
aliases_file="./examples/oneliners/aliases.yaml"
vars_file="./examples/oneliners/vars.yaml"

Alias management:

the aliases.yaml file can look like this :

- name: list stuff
  desc: list current directory. 
  alias: cd {{directory}} && {{pager}} {{file}}

you can use the {{ variable }} syntax to refer to variables defined in your vars_file

ssam will first prompt your for a choice for each dependant variable. Once this is done, it will replace each variable with it's corresponding choice and run the resulting command.

Variables :

in your vars_file, you can define variables. variables can either have a static list of choices or can get their choices dynamically by running a command. the from_command option expects one choice per line in the output command.

- name: directory
  desc: an example variable
  choices:
    - value: /etc/default
      desc: etc default directory
    - value: /etc
      desc: etc directory

- name: pager
  desc: the pager tool to use
  choices: 
    - value: less
      desc: use less
    - value: cat
      desc: use cat


- name: file
  desc: file selection
  from_command: ls -1 {{ directory }}

Scripts management

ssam will index your scripts as follow :

  • name: will be the filename of you script.
  • description: will be the the second line of your script.

Therefore, you scripts should look as follow :

#!/bin/sh (anything other interpreter can be used here.)
# some small description
...the content of the script.

ssam's People

Contributors

r-zenine avatar

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.