This project aims to reduce the amount of things we type. Specially useful for syntax heavy languages.
sudo wget -O /usr/local/bin/subs "http://jeancarlomachado.net/subs" \
&& sudo chmod +x /usr/local/bin/subs
You have to compile for your platform, the only requirement is Haskell stack.
git clone git@github.com:jeanCarloMachado/subs.git
cd subs
make
make install
Create/copy the config file into ~/.subsconfig.ini
. This file is the default
one.
After having your config just pipe the text to stdin.
subs <<< 'cl Gandalf'
class Gandalf
{
}
The true power of subs comes when you integrate it with your tools.
For vim, using Tim Pope's textobject integration is simply a matter of:
fun! s:Subs(str)
let my_filetype = &filetype
let out = system('subs -p '.my_filetype, a:str."\n")
return out
endfunc
call MapAction('Subs', '<leader>y')
# 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
#!/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"