https://github.com/jeancarlomachado/subs
General purpose emmet written in Haskell
https://github.com/jeancarlomachado/subs
development efficiency programming-languages
Last synced: 10 months ago
JSON representation
General purpose emmet written in Haskell
- Host: GitHub
- URL: https://github.com/jeancarlomachado/subs
- Owner: jeanCarloMachado
- License: mit
- Created: 2018-04-25T11:10:42.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-12T16:10:14.000Z (about 8 years ago)
- Last Synced: 2025-07-13T16:41:53.075Z (12 months ago)
- Topics: development, efficiency, programming-languages
- Language: Shell
- Homepage:
- Size: 95.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING
- License: LICENSE
Awesome Lists containing this project
README
## subs
This project aims to reduce the amount of things we type. Specially
useful for syntax heavy languages.

[](https://gitter.im/subs-subs/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Installation:
### Linux
```sh
sudo wget -O /usr/local/bin/subs "http://jeancarlomachado.net/subs" \
&& sudo chmod +x /usr/local/bin/subs
```
### Other
You have to compile for your platform, the only requirement is Haskell stack.
```sh
git clone git@github.com:jeanCarloMachado/subs.git
cd subs
make
make install
```
Create/copy the config file into `~/.subsconfig.ini`. [This file](https://raw.githubusercontent.com/jeanCarloMachado/subs/master/EXAMPLE.subsconfig.ini) is the default
one.
## Usage
After having your config just pipe the text to stdin.
```sh
subs <<< 'cl Gandalf'
class Gandalf
{
}
```
## Integrations
The true power of subs comes when you integrate it with your tools.
### Vim
For vim, using Tim Pope's textobject integration is simply a matter of:
```vimscript
fun! s:Subs(str)
let my_filetype = &filetype
let out = system('subs -p '.my_filetype, a:str."\n")
return out
endfunc
call MapAction('Subs', 'y')
```
### Zsh
```sh
# in your .zshrc
evaluate-snippets-selection () {
if [[ $CURSOR -gt $MARK ]]; then
start=$MARK
end=$(( CURSOR + 1 ))
else
start=$(( CURSOR + 1 ))
end=$MARK
fi
BUFFER="$BUFFER[0,start]$(subs <<< $BUFFER[start+1,end])$BUFFER[end+1,-1]"
}
zle -N evaluate-snippets-selection
bindkey '^O' evaluate-snippets-selection
```
### Dmenu
```sh
#!/bin/bash
# file dmenuSnippets.sh
key=$( subs -k | rofi -levenshtein-sort -dmenu -p "snippet: ")
echo $key
value=$( echo "$key" | subs )
echo "$value"
mycopy "$value"
notify-send "Copied"
```