emacs
emacs and XML
Problem: you have a piece of xml you want emacs to highlight.
Solution: esc-X sgml-mode
emacs and trailing white spaces
Problem: you want to see the trailing whitespaces on you code.
Solution: The showing of triling whitespaces is defined by a buffer variable
show-trailing-whitespace
. In emacs variables are change by running the command
esc-X set-variable
. you get a request for a variable name (
show-trailing-whitespace
) in this example, a value differnt form
nill
will show the trailing whitespaces
Problem: you want to clean the trailing whitespaces on you code.
Solution: esc-X delete-trailing-whitespace
Change variables in emacs
From manual: "M-x set-variable RET
var RET
value RET"
Write read-only files
Problem: you open a file that was read-only, you want to edit it, emacs complains...
Solution: esc-X toggle-read-only
, emacs will allow you to edit the file, and then it will try to save the file, success depends if you are allowed to change change permissions on the file
Indent whole buffer
From this
blog
(defun iwb ()
"indent whole buffer"
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
SHELL
Bash keyboard shortcuts
- TAB : Autocompletes from the cursor position.
- CTRL + a : moves the cursor at the beginning of the line (equivalent to the key : Home).
- CTRL + e : (end) moves the cursor at the line end (equivalent to the key : End).
- CTRL + p : (previous) recalls the previous command (equivalent to the key : Up arrow).
- CTRL + n : (next) recalls the next command (equivalent to the key : Down arrow).
- CTRL + r : (research) recalls the last command including the specified character(s) (equivalent to : vim ~/.bash_history). A 2nd CTRL + r recalls the next anterior command which corresponds to the research.
- CTRL + s : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF).
- CTRL + o : executes the found command from research.
- CTRL + l : clears the screen content (equivalent to the command : clear).
- CTRL + u : clears the line content before the cursor and copy it in the clipboard.
- CTRL + k : clears the line content after the cursor and copy it in the clipboard.
- CTRL + w : clears the word before the cursor and copy it in the clipboard.
- CTRL + y : (yank) adds the clipboard content from the cursor position.
- CTRL + d : sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command : Exit).
- CTRL + c : sends the signal SIGINT to the current task, which aborts and close it.
- CTRL + z : sends the signal SIGTSTP to the current task, which suspends it. To return to it after one can enter fg 'process name' (foreground).
- CTRL + x CTRL + x : (because x has a crossing shape) alternates the cursor with its old position.
- CTRL + x CTRL + e : (editor because it takes the $EDITOR shell variable) edits the current line in vi.
- ALT + f : (forward) moves forward the cursor of one word.
- ALT + b : (backward) moves backward the cursor of one word.
- ALT + del : cuts the word before the cursor.
- ALT + d : cuts the word after the cursor.
- ALT + u : capitalizes every character from the cursor's position to the end of the current word.
- ALT + l : lowers the case of every character from the cursor's position to the end of the current word.
- ALT + c : capitalizes the character under the cursor and moves to the end of the word.
- ALT + r : cancels the changes and put back the line as it was in the history.
X and screen
Problem: After detached and re-attached a screen connection, the X connection will not work. I traced the problem to a mismatch in the
DISPLAY
environment variable.
Solution: Change the
DISPLAY
variable attributed to the new connection.
1. ssh user@machine
2. echo $DISPLAY
3. screen -r
4. export DISPLAY=<Display in 2>
My commands
These function are defines in
.bash_functions
-
pgprfdir [file or directory]
it fills out the rest to get the stuff from the CMS path and does a remote ls
-
pgpstage-f [list of files with list of filenames]
gets the filename from file, it fills out the rest to get the stuff from the CMS path and stages the files
-
pgpstage [file]
it fills out the rest to get the stuff from the CMS path and stages the file
-
pgpstager_qry [list of files]
it fills out the rest to get the stuff from the CMS path and query the stager
-
pgpstager_qry-f [list of files with list of filenames]
gets the filename from file, fills out the rest to get the stuff from the CMS path and query the stager
Remove empty lines from a file
The command
sed '/^$/d' myFile > tt
seems to do it nicely, pick it up from the blog
http://soft.zoneo.net/Linux/remove_empty_lines.php
Delete files with find
find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;
change extension of files
for f in *.MP3; do mv "$f" "`basename "$f" .MP3`.mp3"; done;
from
http://snippets.dzone.com/posts/show/244
CASTOR
stager_qry - query the CASTOR stager for files and requests
stager_qry -M /castor/cern.ch/cms/store/relval/CMSSW_2_1_6/RelValTTbar/GEN-SIM-DIGI-RAW-HLTDEBUG-RECO/IDEAL_V9_v1/0000/
rfdir - Remote directory list
rfdir /castor/cern.ch/cms/store/relval/CMSSW_2_1_6/RelValTTbar/GEN-SIM-DIGI-RAW-HLTDEBUG-RECO/IDEAL_V9_v1/0000/
rfcp - Remote file copy
nsls - list CASTOR name server directory/file entries
Core Dumps
Core dump size is controlled by
ulimit
, use
ulimit -c unlimited
if you always want cores, and set
ulimit -c 0
if you never want cores.
Now let's chose a nice place to put our cores, the location and name of core files is configured in the file
/proc/sys/kernel/core_pattern
, the usage of the
pid
in the core file name is controlled by
/proc/sys/kernel/core_uses_pid
whose content can be
0
or
1
.
Now setting a nice file name for our cores
echo /tmp/core.%e.%p > /proc/sys/kernel/core_pattern
the result is core files in
/tmp
with the name of the executable and the pid.
CVS
Check checked-out tag
cat CVS/Tag
--
PedroParracho - 30-Apr-2010