Find the answer to your Linux question:
Results 1 to 5 of 5
Hello Linuxians, Nice to be here. Does anyone know of a way to spellcheck the clipboard, with aspell or ispell for example. It would help to have a global spellcheck ...
  1. #1
    Just Joined! Agnot's Avatar
    Join Date
    Mar 2008
    Posts
    5

    [SOLVED] Spellcheck the Clipboard

    Hello Linuxians,

    Nice to be here.

    Does anyone know of a way to spellcheck the clipboard, with aspell or ispell for example. It would help to have a global spellcheck for anything that involves text.

  2. #2
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    160
    Hi Agnot,

    the xsel command gives you access to the clipboard content. You
    could use it to transfer the clipboard text to an editor, spellcheck it, and
    put it back.

    I use vim, so the following comes to my mind:
    Code:
    xsel -o -b | vim +:set\ spell -
    This will start vim with the content of the clipboard and enable spell checking.
    Once you're done, you can push the changed text back to the clipboard
    with some vi commands like these
    Code:
    ggVG:!xsel -i -b
    :q!
    This second part is not elegant yet, but with some scripting, this could
    all happen with a keystroke.

    This is just to illustrate the principle. It should work with other editors in a
    similar fashion.

    cheers, kai

  3. #3
    Just Joined! Agnot's Avatar
    Join Date
    Mar 2008
    Posts
    5
    kai,

    Thanks much for the ideas. I will see what I can do about the scripting!

  4. #4
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    160
    anytime,
    and post back if you make it work! :·)

    cheers, kai

  5. #5
    Just Joined! Agnot's Avatar
    Join Date
    Mar 2008
    Posts
    5
    Quote Originally Posted by kai12 View Post
    anytime,
    and post back if you make it work! :&#183

    cheers, kai
    I wouldn't think to do otherwise.

    Here is what I got:

    #!/usr/bin/bsh
    #Clipboard to file <-o> for out,
    #<-b>, the only clipboard section I could get to work.
    xsel -o -b > .spelchec

    #Just in case it is a long file, wait.
    wait

    #Spell check the file with Aspell.
    aspell -c .spelchec

    #Wait until Aspell is finished.
    wait

    #Page the checked file & pipe back to clipboard, <-i> for in.
    less .spelchec | xsel -i -b

    #Wait to be sure to clear pipe to clipboard.
    wait

    #chmod for security. In background to avoid conflict with past to original.
    chmod 600 .spelchec &

    #chmod could be a remove command too. For security.
    #(It is going to be making .spelchec.bak files too.)

    I named it .spell and put it in my home directory, made it executable by owner and put an alias in my .bashrc "alias spell='./.spell'" . I made a launcher on my desktop with the command "/home/my_directory/.spell" , "open in a terminal." And I made a keyboard shortcut in Gnome.

    Had to download xsel. xclip actually looks better, so maybe somebody should work with it. Used Aspell. Oh yeah, my favorite pager, less, will probably need installed if you didn't already.

    Corrected clipboard contents are easy to past back to original because the highlighted text should remain so if left alone. If you leave something uncorrected and change your mind after exiting, you can restart without recopying from original.

    Now I have a global spell checker that checks anything I can copy to clipboard. It keeps a single global word list with a history of all my additions. (The way I change programs, this is very convenient.) It is very fast. It is familiar--reducing errors. And it is Aspell, my favorite checker.

Posting Permissions

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