Page 1 of 5 123 ... LastLast
Results 1 to 10 of 49

Thread: HOWTO: Snippits for desktop-wide text replacement power!

  1. #1
    Join Date
    Jul 2006
    Beans
    809

    HOWTO: Snippits for desktop-wide text replacement power!

    Snippits is a text expansion ruby program for Linux like Texter and Textpander. This howto describes how to get it up and running on Ubuntu gutsy.

    1) install necessary packages

    Code:
    sudo apt-get install ruby ruby1.8-dev rdoc rubygems libruby-extras xautomation xsel aspell libaspell-dev aspell-en build-essential
    sudo gem install raspell
    sudo gem install snippits
    update: thanks to the raven for pointing out that raspell has some additional dependencies

    2) modify your path. NOTE: according to the lifehacker article, it looks as though this step may not be necessary. who knows, try it both ways.

    Once those are done, you need to add the gems bin folder to your path. Put the following line at the end of your ~/.profile.

    Code:
    export PATH="/var/lib/gems/1.8/bin:$PATH"
    3) logout and login

    You'll want to logout and log back in for the changes to your path to take effect.

    4) Create your snippits folder

    Create a folder called ~/.snippits

    Code:
    mkdir ~/.snippets
    Confirm everything is working

    You now have everything you need to run snippits. Make a file called test in the ~/.snippits folder.

    Code:
    gedit ~/.snippits/test
    Type any sort of text you want in there, save and close. Now open gedit again. Now we're really going to make sure everything is in place. With gedit in front of you, do the following:

    1. Press Alt+F2 to pull up the Run Command... dialog box
    2. Type 'ks test' and hit enter


    What you typed in the the ~/.snippits/test file should get typed into gedit.

    Time to make things smooth...

    Now that snippits is working, we want to make it easy to use:

    5) Create a {paste} snippit

    Code:
    gedit ~/.snippits/do
    Put the following into the file:

    Code:
    {shift}{control}{left}{shift}c{control}{paste}
    Save and close the file

    6) Map a keyboard shortcut to 'ks do'

    There are several ways to do this and it's too hard for me to describe them all. I'll cover the compiz way for now.

    Install compizconfig-settings-manager

    Code:
    sudo apt-get install compizconfig-settings-manager
    Go to System -> Preferences -> Advanced Desktop Effect Settings

    You should see something that looks similar to below:




    Click on General Settings and then the commands tab.

    Type in

    Code:
    ks do
    to command 0, then click on the actions tab and click the arrow next to the commands line item. Click on run command 0, and press a shortcut key (I used f6).

    Close Advanced Desktop Effect Settings.

    7) Test this setup

    Create another snippit, we'll call this one test2

    Code:
    gedit ~/.snippits/test2
    Put something in here, save it, and close.

    Open up gedit again, type test2 and hit your shortcut key (f6 in my case).

    If everything has gone according to plan, the text should automatically be highlighted, copied to the clipboard, and then the snippit called test2 will be expanded.

    Now all you need to do to have a shortcut that can be expanded is to name a single word file (like email) in your ~/.snippits folder. Put your email address in there. Now you can type email<f6> in just about any X program that supports the copy operation with ctrl+c to have your email address quickly expanded.

    Good luck, and happy texting.
    Last edited by peabody; February 11th, 2008 at 01:15 PM.

  2. #2
    Join Date
    Dec 2006
    Beans
    7
    Distro
    Ubuntu 6.10 Edgy

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Thank you very much for the instructive walk-through, peabody!

    Quick question though: Having a lot of trouble with installing raspell, which in turn seems to make it hard for snippits to install. Here's the code return from running "sudo gem install raspell" . Any advice?

    Code:
    Building native extensions.  This could take a while...
    ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
        ERROR: Failed to build gem native extension.
    
    ruby extconf.rb install raspell
    checking for ruby.h... yes
    checking for aspell.h... no
    checking for main() in -laspell... no
    creating Makefile
    
    make
    cc -I. -I. -I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE_RUBY_H  -fPIC -fno-strict-aliasing -g -O2  -fPIC  -c raspell.c
    In file included from raspell.c:2:
    raspell.h:6:20: error: aspell.h: No such file or directory
    raspell.c:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    ...

  3. #3
    Join Date
    Dec 2006
    Beans
    7
    Distro
    Ubuntu 6.10 Edgy

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    I found my solution! Turns out raspell requires a few more dependencies to get installed.

    Pulling from this link: http://blog.evanweaver.com/files/doc...es/README.html:

    Code:
    sudo apt-get install aspell libaspell-dev aspell-en

  4. #4
    Join Date
    Jul 2006
    Beans
    809

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Ah, thanks theraven, looks like I already had aspell installed...didn't realize it wasn't installed per default in Ubuntu. I'll see if I can update the guide.

  5. #5
    Join Date
    Dec 2005
    Location
    Somewhere far Beyond...
    Beans
    49
    Distro
    Kubuntu

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Hello, I'm trying to make this work but is just not accepted in my PATH.

    I run the export command, logout, log back in and ks still does not run by default

    I tried to just go to a terminal (Alt-F1) and do the export command and logoff/logon, but still the same.

    Any ideas?
    "It is fortunate that what is necessary, is easy to acquire and what
    is difficult to have, is not necessary"
    - Epicurus
    ---
    Personal haven | Breaking the shackles of the mind | The Wesnoth Journals

  6. #6
    Join Date
    Jul 2006
    Beans
    809

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Two things are possible. One...you aren't using bash as your shell, or Two...you have a ~/.bash_profile file. If you have one of those, put the path statement in there. Make sure it's at the bottom of the file.

    [edit]

    It also couldn't hurt to make sure that /var/lib/gems/1.8/bin is an actual folder. If it's not, something went wrong during the installation.
    Last edited by peabody; February 10th, 2008 at 12:00 PM.

  7. #7
    Join Date
    Dec 2005
    Location
    Somewhere far Beyond...
    Beans
    49
    Distro
    Kubuntu

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Alright, I put it in my .bash_profile file (without the export) and it seemed to work on the terminal login. I'm going to try and logoff now. I would have tried that sooner but I was not certain why having the path statement in your bash profile would help for the DE :-/

    EDIT: Works! Great! Thanks!

    PS: Lifehacker has an article on it which should be useful for some starting macros
    Last edited by db0; February 11th, 2008 at 12:23 PM.
    "It is fortunate that what is necessary, is easy to acquire and what
    is difficult to have, is not necessary"
    - Epicurus
    ---
    Personal haven | Breaking the shackles of the mind | The Wesnoth Journals

  8. #8
    Join Date
    Dec 2005
    Location
    Somewhere far Beyond...
    Beans
    49
    Distro
    Kubuntu

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    I'm trying to make the script paste the content of either the clipboard or X clipboad as part of the script but unfortunately I can't get it to do it as part of the process is copying your the script into the clipboard.

    For example, I want to copy a url in firefox and put it within a bbcode link

    I tried the script like so
    Code:
    [.url={c}v{c}]{cursor}[/url.]
    (without the dots in the url bbcode of course)

    But it pastes nothing in the url link position

    Any idea? I was trying to use the X-Windows clipboard and paste with a middle click but apparent keyout does not accept mouse click option (or so it seems) Any idea? Do you know of any way to paste the contents of the X-Clipboard instead of middle-clicking?
    "It is fortunate that what is necessary, is easy to acquire and what
    is difficult to have, is not necessary"
    - Epicurus
    ---
    Personal haven | Breaking the shackles of the mind | The Wesnoth Journals

  9. #9
    Join Date
    Jul 2006
    Beans
    809

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Wow, cool, glad to see lifehacker gave it attention, I know they're big text replacement tool fans.

    It looks like build-essential should be installed to have raspell install correctly, I'll update the guide.

    The clipboard thing's a definite problem. I hope Ben gets around to figuring out how to replace while you type (that's what my autokey program does, but my program's a buggy mess , his is much cleaner). Only thing I can think of is if there's a way to drive a program such as Glipper with keyboard shortcuts so that you can get it to change the contents of the clipboard.
    Last edited by peabody; February 11th, 2008 at 01:19 PM.

  10. #10
    Join Date
    Dec 2005
    Location
    Somewhere far Beyond...
    Beans
    49
    Distro
    Kubuntu

    Re: HOWTO: Snippits for desktop-wide text replacement power!

    Quote Originally Posted by peabody View Post
    The clipboard thing's a definite problem. I hope Ben gets around to figuring out how to replace while you type (that's what my autokey program does, but my program's a buggy mess , his is much cleaner).
    Yah, mee too. For now I can still use to to paste nifty stuff for wesnoth scenario scripting

    Only thing I can think of is if there's a way to drive a program such as Glipper with keyboard shortcuts so that you can get it to change the contents of the clipboard.
    I checked Glipper and unfortunately it does not have an option to change the shortcuts. It would be cool if it supported something like ctrl+1 to paste the first entry in Glipper, ctrl+2 for the second and so on :-/

    At least an option to change the shortcut for the selection clipboard instead of middle mouse click.
    "It is fortunate that what is necessary, is easy to acquire and what
    is difficult to have, is not necessary"
    - Epicurus
    ---
    Personal haven | Breaking the shackles of the mind | The Wesnoth Journals

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •