查看当前操作系统内核信息 # uname -a Linux redcat 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686 GNU/Linux 查看当前操作系统发行版信息 #cat /etc/issue 查看cpu型号 # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 查看物理cpu颗数 # cat /proc/cpuinfo | grep physical | uniq -c 2 physical id : 0(说明实际上是1颗2核的CPU) 查看cpu运行模式 # getconf LONG_BIT 32 (说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit) 查看cpu是否支持64bit # cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l 2 (结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit) 查看cpu信息概要(昨天看aix的时候刚发现的,在ubuntu上竟然也有~): #lscpu Architecture: i686 #架构686 最后来个大而全的: #cat /proc/cpuinfo processor : 0 |
lundi 31 mai 2010
Linux下如何查看CPU信息, 包括位数和多核信息
.bashrc 20100531
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
#Renote Desktop Viewer
alias i11m='rdesktop -g 90% -a 16 -u "ma wei" -0 156.18.40.219'
alias i11b='rdesktop -g 90% -a 16 -u "MA" -0 156.18.40,236'
alias iorn='ssh -X fang@hurricane.mecaflu.ec-lyon.fr'
alias jma='ssh -X mawei@156.18.38.239'
#
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
#tecplot
alias tecplot='tec360 -mesa'
#veusz
alias veusz='veusz_main.py'
#emacs for chinese input
alias emacs='LANG=zh_CN.UTF-8 emacs'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
#export PS1="\[\033[0;37;44m\u@\033[0;32;43m\h:\033[0;33;41m\w$\033[0m\]"
BLUE=`tput setf 1`
GREEN=`tput setf 2`
CYAN=`tput setf 3`
RED=`tput setf 4`
MAGENTA=`tput setf 5`
YELLOW=`tput setf 6`
WHITE=`tput setf 7`
PS1='\[$GREEN\]\u@\h \[$BLUE\]\w\[$GREEN\] \$\[$WHITE\] '
export PATH=/opt/tecplot/bin:$PATH
export PATH=/opt/intel/Compiler/11.1/064/bin/ia32:$PATH
export PATH=/opt/fluent/Fluent.Inc/bin:$PATH
export PATH=/opt/veusz-1.6:$PATH
export PATH=/opt/matlab/bin:$PATH
#begin NUMECA configuration
PATH=/usr/local/numeca/bin:${PATH}
export PATH
#end NUMECA configuration
jeudi 20 mai 2010
dimanche 9 mai 2010
.emacs 20100509
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;-----------------------------------------------------------------------------
;; to enable highlighting when searching
(setq search-highlight t)
;;to highlight matches when using serch-and-replace
(setq query-replace-highlight t)
;;用win+space为set-mark键,留出ctrl+space热键作为输入法
(global-set-key (kbd "C-SPC") 'nil)
(global-set-key (kbd "s-SPC") 'set-mark-command)
;;设置字体大小
(set-default-font "DejaVu Sans Mono-8")
;;在窗口左侧显示行号
(global-linum-mode t)
;;在状态栏(mode line)上显示行号
(setq column-number-mode t)
(setq line-number-mode t)
;;鼠标自动避开指针,如当你输入的时候,指针到了鼠标的位置,鼠标有点挡住视线了
(mouse-avoidance-mode 'animate)
;;指针不要闪
(blink-cursor-mode -1)
(transient-mark-mode 1)
;;当指针到一个括号时,自动显示所匹配的另一个括号
(show-paren-mode 1)
;;去掉烦人的警告铃声
(setq visible-bell nil)
;;去掉Emacs和gnus启动时的引导界面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;; 显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;当前行高亮
(require 'hl-line)
(global-hl-line-mode t)
;;滚动条在窗口右侧
'(scroll-bar-mode (quote right))
;;在窗口的标题栏上显示文件名称
(setq frame-title-format "%n%F/%b")
;;允许emacs和外部其他程序的粘
(setq x-select-enable-clipboard t)
;;支持中键粘贴
(setq mouse-yank-at-point t)
;;所有的问题用y/n方式,不用yes/no方式
(fset 'yes-or-no-p 'y-or-n-p)
;;go-line快捷键
(global-set-key (kbd "M-g") 'goto-line)
;; 在行首 C-k 时,同时删除该行。
(setq-default kill-whole-line t)
;;保存前,删除当前buffer中行尾空格和TAB等whitespace
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;;(setq ansi-color-for-comint-mode t)使用shell,shell中没有乱码
(ansi-color-for-comint-mode-on)
;;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;; Add the directories to your load path
(add-to-list 'load-path "~/.emacs.d/")
;;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;;------------------------------------------------------------------------------
;; 启动时的屏幕大小
;;第一种方法,需要根据不同的电脑屏幕大小进行修正
;;第二种方法,思路很好,但是垂直方向(vert)超过了显示范围,需要修正
;;------------------------------------------------------------------------------
;;第一种方法
(setq default-frame-alist
(append '((top . 0)(left . 0)(width . 175)(height . 45))
default-frame-alist))
;;第二种方法
;(defun my-maximized-horz ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
;(defun my-maximized-vert ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(defun my-maximized ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(my-maximized)
;;-----------------------------------------------------------------------------
;; cursor-chg.el
;;-----------------------------------------------------------------------------
(require 'cursor-chg) ; Load this library
(change-cursor-mode 1) ; On for overwrite/read-only/input mode
(toggle-cursor-type-when-idle 1) ; On when idle
;;-----------------------------------------------------------------------------
;;调用smart-compile
;;-----------------------------------------------------------------------------
(require 'smart-compile)
(global-set-key [f7] 'smart-compile)
;;-----------------------------------------------------------------------------
;; add emacs-wiki
;;-----------------------------------------------------------------------------
;; Add the directories to your load path
;(add-to-list 'load-path "~/.emacs.d/emacs-wiki-2.72")
;;调用emacs-wiki
;(require 'emacs-wiki)
;(require 'emacs-wiki-menu)
;(load "emacs-wiki")
;;----------------------------------------------------------------------------
;; 调用tabbar,在head中显示打开文件列表
;;-----------------------------------------------------------------------------
(require 'tabbar)
(tabbar-mode t)
;;全部分在同一组
(setq tabbar-buffer-groups-function
(lambda ()
(list "All")))
;;----------------------------------------------------------------
;; add a buffer modification state indicator in the tab label,
;; and place a space around the label to make it looks less crowd
;;----------------------------------------------------------------
(defadvice tabbar-buffer-tab-label (after fixup_tab_label_space_and_flag activate)
(setq ad-return-value
(if (and (buffer-modified-p (tabbar-tab-value tab))
(buffer-file-name (tabbar-tab-value tab)))
(concat " + " (concat ad-return-value " "))
(concat " " (concat ad-return-value " ")))))
;; called each time the modification state of the buffer changed
(defun ztl-modification-state-change ()
(tabbar-set-template tabbar-current-tabset nil)
(tabbar-display-update))
;; first-change-hook is called BEFORE the change is made
(defun ztl-on-buffer-modification ()
(set-buffer-modified-p t)
(ztl-modification-state-change))
(add-hook 'after-save-hook 'ztl-modification-state-change)
;; this doesn't work for revert, I don't know
;;(add-hook 'after-revert-hook 'ztl-modification-state-change)
(add-hook 'first-change-hook 'ztl-on-buffer-modification)
;;----------------------------------------------------------------------------
;; 使用一个简单的 Elisp 函数
;;:如果选定了区域,那么按 M-w 就复制这个区域;如果没有选定区域,那么 M-w 就复制一行
;;-----------------------------------------------------------------------------
(defun huangq-kill-ring-save (&optional n)
"If region is active, copy region. Otherwise, copy line."
(interactive "p")
(if mark-active
(kill-ring-save (region-beginning) (region-end))
(if (> n 0)
(kill-ring-save (line-beginning-position) (line-end-position n))
(kill-ring-save (line-beginning-position n) (line-end-position)))))
(global-set-key (kbd "M-w") 'huangq-kill-ring-save)
;;-----------------------------------------------------------------------------
;;备份设置
;;-----------------------------------------------------------------------------
;;emacs还有一个自动保存功能,默认在~/.emacs.d/auto-save-list里,
;;这个非常有用,具体可以参见Sams teach yourself emacs in 24hours(我简称为sams24)
;;启用版本控制,即可以备份多次
(setq version-control t)
;;备份最原始的版本两次,记第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;;备份最新的版本五次,理解同上
(setq kept-new-versions 5)
;;删掉不属于以上7中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路径
(setq backup-directory-alist '(("." . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
(setq backup-by-copying t)
;;-----------------------------------------------------------------------------
;; 快速在另外一个buffer中打开shell并cd 到当前 buffer 所在的目录
;;-----------------------------------------------------------------------------
(defun kid-switch-to-shell ()
(interactive)
(when (null (cdr (window-list)))
(split-window-horizontally))
(let ((file buffer-file-name))
(other-window 1)
(shell)
(when file
(end-of-buffer)
(when (looking-back shell-prompt-pattern)
(insert "cd " (file-name-directory file))
(call-interactively 'comint-send-input)))))
(global-set-key (kbd "") 'kid-switch-to-shell)
;;-----------------------------------------------------------------------------
;; occur
;;-----------------------------------------------------------------------------
(defun occur-fortran ()
(interactive )
(setq mawei "\\(?:\\\\|\\\\|\\
(occur mawei)
;(occur (regexp-opt '("program""subroutine""function""call")))
)
(global-set-key (kbd "") 'occur-fortran)
;;-----------------------------------------------------------------------------
;; 每当我在 M-x shell启动shell,然后执行 exit 退出 shell 之后,buffer 并不自动关闭,很不爽,
;; 下面的指令,可以让其自动关闭。
;;-----------------------------------------------------------------------------
(add-hook 'shell-mode-hook 'wcy-shell-mode-hook-func)
(defun wcy-shell-mode-hook-func ()
(set-process-sentinel (get-buffer-process (current-buffer))
#'wcy-shell-mode-kill-buffer-on-exit)
)
(defun wcy-shell-mode-kill-buffer-on-exit (process state)
(message "%s" state)
(if (or
(string-match "exited abnormally with code.*" state)
(string-match "finished" state))
;(kill-buffer (current-buffer))))
(kill-buffer-and-window )))
;;-----------------------------------------------------------------------------
;; 当前buffer的文件名,前加“./”,后去掉后面4位数字,输入到minibuffer
;;-----------------------------------------------------------------------------
;(define-key minibuffer-local-map [f8]
;(lambda ()
;(interactive)
;(insert (concat "./") )
;(insert (substring (buffer-name (current-buffer-not-mini)) 0 -4 ))
;(insert (concat ".exe") )
;)
;)
;
;(defun current-buffer-not-mini ()
;"Return current-buffer if current buffer is not the *mini-buffer*
;else return buffer before minibuf is activated."
;(not (window-minibuffer-p)) (current-buffer)
;(if (eq (get-lru-window) (next-window))
;(window-buffer (previous-window)) (window-buffer (next-window))))
;;------------------------------------------------------------------------------
;; auto-complete
;; -----------------------------------------------------------------------------
;; Add the directories to your load path
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete)
(global-auto-complete-mode t)
;; Use C-n/C-p to select candidates
;;(define-key ac-complete-mode-map "\M-n" 'ac-next)
;;(define-key ac-complete-mode-map "\M-p" 'ac-previous)
;; you can stop completion by pressing M-/.
;;(define-key ac-complete-mode-map "\M-TAB" 'ac-stop)
;; Completion by TAB
;;
;; Add following code to your .emacs.
;;
(define-key ac-complete-mode-map "\t" 'ac-complete)
(define-key ac-complete-mode-map "\r" nil)
;; Do What I Mean mode
;; -------------------
;;
;; If DWIM (Do What I Mean) mode is enabled,
;; the following features is available:
;;
;; a. TAB (ac-expand) behave as completion (ac-complete)
;; when only one candidate is left
;; b. TAB (ac-expand) behave as completion (ac-complete)
;; after you select candidate
;; c. Disapear automatically when you
;; complete a candidate.
;;
;; DWIM mode is enabled by default.
;; You can enable this feature by
;; setting `ac-dwim' to t.
;;
(setq ac-dwim t)
;;------------------------------------------------------------------------------
;; quit a frame the same way no matter what kind of frame you are on"
;;------------------------------------------------------------------------------
;;This method, when bound to C-x C-c, allows you to close an emacs frame the
;;same way, whether it's the sole window you have open, or whether it's
;;a "child" frame of a "parent" frame. If you're like me, and use emacs in
;;a windowing environment, you probably have lots of frames open at any given
;;time. Well, it's a pain to remember to do Ctrl-x 5 0 to dispose of a child
;;frame, and to remember to do C-x C-x to close the main frame (and if you're
;;not careful, doing so will take all the child frames away with it). This
;;is my solution to that: an intelligent close-frame operation that works in
;;all cases (even in an emacs -nw session).
;;(global-set-key "\C-x\C-c" 'ic) ;forward reference
(defun ic ()
"quit a frame the same way no matter what kind of frame you are on"
(interactive)
(if (eq (car (visible-frame-list)) (selected-frame))
;;for parent/master frame...
(if (> (length (visible-frame-list)) 1)
;;close a parent with children present
(delete-frame (selected-frame))
;;close a parent with no children present
(save-buffers-kill-emacs))
;;close a child frame
(delete-frame (selected-frame))))
;;------------------------------------------------------------------------------
;; hithlight-80+:
;;------------------------------------------------------------------------------
;;(add-to-list 'load-path "~/.emacs.d/")
;;(global-highlight-80+-mode t)
(require 'highlight-80+)
(add-hook 'f90-mode-hook 'highlight-80+-mode)
;;------------------------------------------------------------------------------
;; 自动补全括号
;; 输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
;;------------------------------------------------------------------------------
(defun auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(\"_"\"")
(\'_"'")
(\(")")
(\[_"]")
(\{_"}")
;(?\{?_"}")
))
(setq skeleton-pair t)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'f90-mode-hook 'auto-pair)
;;------------------------------------------------------------------------------
;; redo/undo
;;------------------------------------------------------------------------------
(require 'redo)
(global-set-key (kbd "C-/") 'undo)
(global-set-key (kbd "M-/") 'redo)
;;------------------------------------------------------------------------------
;; flyspell.el
;;
;; flyspell is an Emacs package that highlights misspelld words as you type;
;; Remark:
;; `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are
;; valid. For instance, a personal dictionary can be used by
;; invoking `ispell-change-dictionary'.
;;
;; ispell-program-name = "aspell"
;; ispell-aspell-dict-dir = "/usr/lib/aspell"
;;------------------------------------------------------------------------------
;; enable flyspell-mode (minor mode) in latex-mode (major mode)
(add-hook 'latex-mode-hook 'flyspell-mode)
;; enable flyspell-prog-mode (minor mode) in f90-mode (major mode)
;;(add-hook 'f90-mode-hook 'flyspell-prog-mode)
(setq ispell-local-dictionary "american")
;;(setq ispell-local-dictionary "french")
jeudi 6 mai 2010
search in linux
1. find
find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件。
find的使用格式如下:
$ find <指定目录> <指定条件> <指定动作>
- <指定目录>: 所要搜索的目录及其所有子目录。默认为当前目录。
- <指定条件>: 所要搜索的文件的特征。
- <指定动作>: 对搜索结果进行特定的处理。
如果什么参数也不加,find默认搜索当前目录及其子目录,并且不过滤任何结果(也就是返回所有文件),将它们全都显示在屏幕上。
find的使用实例:
$ find . -name 'my*'
搜索当前目录(含子目录,以下同)中,所有文件名以my开头的文件。
$ find . -name 'my*' -ls
搜索当前目录中,所有文件名以my开头的文件,并显示它们的详细信息。
$ find . -type f -mmin -10
搜索当前目录中,所有过去10分钟中更新过的普通文件。如果不加-type f参数,则搜索普通文件+特殊文件+目录。
2. locate
locate命令其实是“find -name”的另一种写法,但是要比后者快得多,原因在于它不搜索具体目录,而是搜索一个数据库(/var/lib/locatedb),这个数据库中含有本地所有文件信息。Linux系统自动创建这个数据库,并且每天自动更新一次,所以使用locate命令查不到最新变动过的文件。为了避免这种情况,可以在使用locate之前,先使用updatedb命令,手动更新数据库。
locate命令的使用实例:
$ locate /etc/sh
搜索etc目录下所有以sh开头的文件。
$ locate ~/m
搜索用户主目录下,所有以m开头的文件。
$ locate -i ~/m
搜索用户主目录下,所有以m开头的文件,并且忽略大小写。
3. whereis
whereis命令只能用于程序名的搜索,而且只搜索二进制文件(参数-b)、man说明文件(参数-m)和源代码文件(参数-s)。如果省略参数,则返回所有信息。
whereis命令的使用实例:
$ whereis grep
4. which
which命令的作用是,在PATH变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果。也就是说,使用which命令,就可以看到某个系统命令是否存在,以及执行的到底是哪一个位置的命令。
which命令的使用实例:
$ which grep
5. type
type命令其实不能算查找命令,它是用来区分某个命令到底是由shell自带的,还是由shell外部的独立二进制文件提供的。如果一个命令是外部命令,那么使用-p参数,会显示该命令的路径,相当于which命令。
type命令的使用实例:
$ type cd
系统会提示,cd是shell的自带命令(build-in)。
$ type grep
系统会提示,grep是一个外部命令,并显示该命令的路径。
$ type -p grep
加上-p参数后,就相当于which命令。
mercredi 5 mai 2010
emacs shell history
41.5.1 Shell History Ring
M-p
C-
Fetch the next earlier old shell command.
M-n
C-
Fetch the next later old shell command.
M-r regexp
M-s regexp
Search backwards or forwards for old shell commands that match regexp.
C-c C-x
Fetch the next subsequent command from the history.
C-c .
Fetch one argument from an old shell command.
C-c C-l
Display the buffer's history of shell commands in another window (comint-dynamic-list-input-ring).
Shell buffers provide a history of previously entered shell commands. To reuse shell commands from the history, use the editing commands M-p, M-n, M-r and M-s. These work just like the minibuffer history commands except that they operate on the text at the end of the shell buffer, where you would normally insert text to send to the shell.
M-p fetches an earlier shell command to the end of the shell buffer. Successive use of M-p fetches successively earlier shell commands, each replacing any text that was already present as potential shell input. M-n does likewise except that it finds successively more recent shell commands from the buffer. C- works like M-p, and C- like M-n.
The history search commands M-r and M-s read a regular expression and search through the history for a matching command. Aside from the choice of which command to fetch, they work just like M-p and M-n. If you enter an empty regexp, these commands reuse the same regexp used last time.
When you find the previous input you want, you can resubmit it by typing, or you can edit it first and then resubmit it if you wish. Any partial input you were composing before navigating the history list is restored when you go to the beginning or end of the history ring.
Often it is useful to reexecute several successive shell commands that were previously executed in sequence. To do this, first find and reexecute the first command of the sequence. Then type C-c C-x; that will fetch the following command—the one that follows the command you just repeated. Then type to reexecute this command. You can reexecute several successive commands by typing C-c C-x over and over.
The command C-c . (comint-input-previous-argument) copies an individual argument from a previous command, like ESC . in Bash. The simplest use copies the last argument from the previous shell command. With a prefix argument n, it copies the nth argument instead. Repeating C-c . copies from an earlier shell command instead, always using the same value of n (don't give a prefix argument when you repeat the C-c . command).
These commands get the text of previous shell commands from a special history list, not from the shell buffer itself. Thus, editing the shell buffer, or even killing large parts of it, does not affect the history that these commands access.
Some shells store their command histories in files so that you can refer to commands from previous shell sessions. Emacs reads the command history file for your chosen shell, to initialize its own command history. The file name is ~/.bash_history for bash, ~/.sh_history for ksh, and ~/.history for other shells.
M-p
C-
Fetch the next earlier old shell command.
M-n
C-
Fetch the next later old shell command.
M-r regexp
M-s regexp
Search backwards or forwards for old shell commands that match regexp.
C-c C-x
Fetch the next subsequent command from the history.
C-c .
Fetch one argument from an old shell command.
C-c C-l
Display the buffer's history of shell commands in another window (comint-dynamic-list-input-ring).
Shell buffers provide a history of previously entered shell commands. To reuse shell commands from the history, use the editing commands M-p, M-n, M-r and M-s. These work just like the minibuffer history commands except that they operate on the text at the end of the shell buffer, where you would normally insert text to send to the shell.
M-p fetches an earlier shell command to the end of the shell buffer. Successive use of M-p fetches successively earlier shell commands, each replacing any text that was already present as potential shell input. M-n does likewise except that it finds successively more recent shell commands from the buffer. C-
The history search commands M-r and M-s read a regular expression and search through the history for a matching command. Aside from the choice of which command to fetch, they work just like M-p and M-n. If you enter an empty regexp, these commands reuse the same regexp used last time.
When you find the previous input you want, you can resubmit it by typing
Often it is useful to reexecute several successive shell commands that were previously executed in sequence. To do this, first find and reexecute the first command of the sequence. Then type C-c C-x; that will fetch the following command—the one that follows the command you just repeated. Then type
The command C-c . (comint-input-previous-argument) copies an individual argument from a previous command, like ESC . in Bash. The simplest use copies the last argument from the previous shell command. With a prefix argument n, it copies the nth argument instead. Repeating C-c . copies from an earlier shell command instead, always using the same value of n (don't give a prefix argument when you repeat the C-c . command).
These commands get the text of previous shell commands from a special history list, not from the shell buffer itself. Thus, editing the shell buffer, or even killing large parts of it, does not affect the history that these commands access.
Some shells store their command histories in files so that you can refer to commands from previous shell sessions. Emacs reads the command history file for your chosen shell, to initialize its own command history. The file name is ~/.bash_history for bash, ~/.sh_history for ksh, and ~/.history for other shells.
lundi 3 mai 2010
emacs 自动补全括号
;;-----------------------------------------------------------------------
;;自动补全括号
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
(defun mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?\" ? _ " \"")
(?\' ? _ " '")
(?\( ? _ " )")
(?\[ ? _ " ]")
(?\{ ? _ " } ")
))
(setq skeleton-pair t)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'f90-mode-hook 'mode-auto-pair)
;;自动补全括号
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
(defun mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?\" ? _ " \"")
(?\' ? _ " '")
(?\( ? _ " )")
(?\[ ? _ " ]")
(?\{ ? _ " } ")
))
(setq skeleton-pair t)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'f90-mode-hook 'mode-auto-pair)
Inscription à :
Articles (Atom)