Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

« Newer Snippets
Older Snippets »
6 total  XML / RSS feed 


Using the command line as UI ? try to remember some of these useful commands !

# save cursor position
tput sc
# move cursor to 10th line and 20th column
tput cup 10 20
# write some text from here in standout mode
tput smso
echo "j ecris a partir de la 10eme ligne et la 20eme colonne"     
# restore cursor position
tput rc
# exit from standout mode
tput rmso

Some more advanced stuff can be done :
# save your prompt
# set the prompt to blank
# save the number of colums of the terminal
COLUMNS=$(tput cols)
# save the number of lines of the terminal
LINES=$(tput lines)
# set the message you want to display (here it's "hello I am at the center of the term")
message="coucou je suis au milieu du terminal"
# get the horizontal position to center your text
hpos=$(expr $LINES / 2)
# get the vertical position to center your text
vpos=$(expr \( $COLUMNS - $(echo "$message" | wc -c) \) / 2)
# move the cursor to that position
tput cup $hpos $vpos
# enter in reverse video mode
tput rev
# display the message
echo "$message"
# wait for 3 second to see the message
sleep 3
# recall your default prompt
# reset all terminal settings
tput sgr0
# clear the screen
tput clear

STTY Control Assignements

Using puTTY and not able to set a correct configuration for your UNIX-like system ?
Try using the "stty" command.

For example on my HP-UX 11.11 box I have added the following in my .profile :
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z"

Text field's default text

Show a default text...

<script language="javascript">
        function showtxt(thisfield, defaulttxt) {
       = '#FFFF88';
                if (thisfield.value == defaulttxt) {
               = "#000";
                        thisfield.value = "";
        function hidetxt(thisfield, defaulttxt) {
       = '#FFFFFF';
                if (thisfield.value == "") {
               = "#999";
                        thisfield.value = defaulttxt;

  onclick="showtxt(this, 'Recherchez ici...')" 
  onblur="hidetxt(this, 'Recherchez ici...')" 
  style="color:#"query"])) { echo "000"; } else { echo "999"; } ?>;" 
  value=""query"])) { echo preg_replace("/[\\\\]+/", "", trim(htmlentities($_POST["query"]))); } else { echo "Recherchez ici..."; } ?>"

Windows' command prompt : How to DEFINITELY change default codepage

Want to use WinLatin1 (1252) instead of DOSLatin1 (850, default when cmd.exe is started) ?

You want to apply the new codepage to :
- the current opened command prompt
C:\> chcp 1252

- all the opened command prompt in the future
Go to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
And change the "OEMCP" value to "1252"

You need to restart your computer to see the changes.

So you'll be able to display extended characters (such as accents and so on)


Don't know how to check the command prompt's codepage ?
C:\> chcp


Want to see the result in practice ?
Edit a codepage.txt file and type "à la bonne heure, ça marche ! (peut être)", then open a command prompt and check this out :
C:\> type codepage.txt

Using gnus (emacs' mail and news reader) : Cheatsheet

1. Launch emacs
emacs &

2. Launch gnus
M-x gnus

3. Group Buffer
3.1. Subscribe to news groups
Check the group list

Subscribe to a group (cursor above the group name)

3.2. Organise your topics
Create a new topic
T n

Assign a newsgroup to a topic
T m

3.3. Some more useful commands
RET = enter the newsgroup
g = check for new mails and news
q = quit
c = mark all unread as read (catchup)
C = mark all as read (catchup)
l = show newsgroup with unread articles
L = show all newsgroup
m = create a new mail (mails)
n = create a new post (news)

4. Summary/Article Buffer (useful commands)
RET = enter the article
n = next unread article
p = previous unread article
SPACE = scroll down
DEL = scroll up
F/f = Follow-up (with cite/whitout cite)
R/r = Reply (with cite/without cite)
m = create a new mail (mails)
a = create a new post (news)
c = mark as read (catchup)

5. Compose new mail and news
After creating a new mail or post (see above) use the following :
C-c C-c = send message
C-c C-d = save message as draft
C-c C-k = kill message
C-c C-m f = attach file
M-q = reformat paragraph

C-h i gnus

Remote file editing using emacs + ssh

Get TRAMP (Transparent Remote file Access, Multiple Protocol) :

Install it :
cd ~/.emacs.d/
tar -xvzf /your/download/folder/tramp-2.X.X.tar.gz
ln -s tramp-2.X.X tramp
cd tramp
./configure --with-contrib
sudo make install

Configure your emacs to use it :
1. Add the following in your .emacs
;; Remote file editing via ssh
(add-to-list 'load-path "~/.emacs.d/tramp/lisp/")
(require 'tramp)
(setq tramp-default-method "ssh")

2. Launch your emacs
3. C-x C-f /[email protected]:/path/to/file

Warning :
Seems it doesn't work if no password is required to login to host (using public key for example). But not sure at all...
« Newer Snippets
Older Snippets »
6 total  XML / RSS feed