Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Open a terminal and Execute commands and Keep terminal open
gnome-terminal --tab -e "/bin/bash -c 'ls -al ; exec /bin/bash -i'"
clock_gettime(), clock_getres()
相關文件
- http://man7.org/linux/man-pages/man2/clock_gettime.2.html
- CLOCK_MONOTONIC
Vi & Vim Tutorial
cite:
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
:set wrap
:set nowrap
Set tab spaces
1. vim /etc/vim/vimrc
2. set ts=4
Foreground and Background Switch
1) Ctrl + z
2) fg ....
http://arjanvandergaag.nl/blog/foreground-and-background-processes.html
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white
※lightmagenta darkgray lightgrey darkgrey lightgreen lightgray darkmagenta gray white red grey darkred brown darkblue darkgreen lightblue yellow cyan
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
:set wrap
:set nowrap
Replace all string in document
- : %s / ______________ /\ ________________/ g
Set tab spaces
1. vim /etc/vim/vimrc
2. set ts=4
利用字串取代('^M' 要用 Ctrl+V 不要放開 Ctrl 再按 M 才能打出來喔!)
:%s/^M/\r/g
Display the line number in vim
- vim /etc/vim/vimrc
- :set number
Foreground and Background Switch
1) Ctrl + z
2) fg ....
http://arjanvandergaag.nl/blog/foreground-and-background-processes.html
Set current line highlight
set cursorlinehi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white
※lightmagenta darkgray lightgrey darkgrey lightgreen lightgray darkmagenta gray white red grey darkred brown darkblue darkgreen lightblue yellow cyan
Folding codes in vim
1. visual select the codes (v) (ctrl+v)
2. zf
3. za
相關文件
- Graphical vi-vim Cheat Sheet and Tutorial
- tab 切換
- Ctrl+PageUp | Ctrl+PageDown
- gt
- http://www.ptt.cc/bbs/Editor/M.1340702403.A.CFA.html
- Copy and Paste using Visual Selection
- Vim 懶人包 Janus
- Vim After 11 years
- Vim 套件 : PHP and javascript 檢查套件
- Vim Plugins
- Automatic Syntax Checking
- Vim 外掛管理工具 Vundle
- Vim 自動完成
- https://bitbucket.org/ns9tks/vim-autocomplpop/
- http://www.ptt.cc/bbs/CSIE_DBMS/M.1356354669.A.B0B.html
- Vim 設定檔
- **snipMate (自動完成 for, foreach, etc.)
- http://www.vim.org/scripts/script.php?script_id=2540
- http://www.catonmat.net/blog/vim-plugins-snipmate-vim/ (Also for Cygwin)
- http://net.tutsplus.com/tutorials/other/vim-essential-plugin-snipmate/ (**)
- **AutoComplPop (自動完成keywork)
- http://www.vim.org/scripts/script.php?script_id=1879
- http://www.ptt.cc/bbs/Linux/M.1260322500.A.CE3.html
- **Code folding
- http://smartic.us/2009/04/06/code-folding-in-vim/
- http://www.youtube.com/watch?v=2VQozxCH7D0
使用 cscope + ctags + taglist 來閱讀sourcecode
ctags + taglist
1) Install ctags$ sudo apt-get install exuberant-ctags
2)Download and install taglist
https://sourceforge.net/projects/ctags/files/
http://vim-taglist.sourceforge.net/
$ unzip taglist_45.zip
#it will generate plugin and doc
$ mv plugin/ ~/.vim
$ mv doc/ ~/.vim
3)turn on/off the taglist in vim
$ sudo vim /etc/vim/vimrc
Add the following line:
map <f9> :Tlist<CR>
4)check the target directory and create the tags
$ ctags -R *.c *.h
OR
$ find 'pwd' -type f -name "*.[ch]" -o -name "*.cc" -o -name "*.[sS]" | sed -e 's/^/"/' -e 's/$/"/' | xargs /usr/bin/ctags -a
5)Open the vim and press F9
#The window will divide by two part, use the Ctrl-W-W to switch the window
#The left window: Jump to the correspond function or definition
#The right window:
Ctrl+]:Jump to function implement position, the cursor should be the function name's front
Ctrl+t:return to the original position
cite:http://stenlyho.blogspot.com/2008/11/ubuntuvim-plugin-ctagstaglist.html
Cscope
Call Graph
CCTree: http://www.vim.org/scripts/script.php?script_id=2368
make 命令 & makefile
makefile syntax
- dependencies (相依性項目)
- one target (目標項目)
- some source code files
- (target), (semicolon), (space or tab), ....., (source code files), (space or tab), .....
- e.g. all: myapp myapp.l
- rules (法則)
- the rules illustrate how to generate a target
- (tab)
- the rules muse be on the same line
- comment (註解)
- (#)
- macro (巨集)
- define the macro => MACRONAME = value
- access the macro => $(MACRONAME), ${MACRONAME}
- -
- make will ignore the error
- e.g. -mkdir
- e.g. -rm -r
- @
- make will not output the executed command on standard output
- #這是makefile的格式(註解)
[target]: [dependency] [dependency]
[TAB][rule]
[TAB][rule]
[target]: [dependency]
[TAB][rule]
make options
-k : 會讓make再遇到錯誤之時,仍然繼續執行而不會停在第一個問題點。可以利用這個選項找出發生問題的原始碼檔案。
-n : 告訴make只列出要進行的工作,而不會真正去執行它。
-f : tell the make to use the as a makefile. Otherwise, the make will use the makefile, Makefile (recommend).
-p : 要求 make 印出內建法則
-j3 : use the 3 cores
Automatic Varaiables
$@ : The name of the current target
$% : The filename element of an archive member specification
$<: first="" he="" name="" nbsp="" of="" p="" prerequisite="" the="">
$?: The names of all prerequisites that are newer than the target, separated by spaces,代表須要重建(被修改)的相依性項目
$^: The names of all prerequisites, separated by spaces. This is list has duplicated names removed.
$+: Similar to $^, except $+ includes duplicateds.. This variable was created for specific situations such as arguments to linkers where duplicated values have meaning.
$*: The stem of the target filename. A stem is typically a filename without its suffix. Current dependencies without the extension (副檔名)
- define the marcro : 1) make CC=c89 2) make "CC = c89"
- Use the all as the first target in makefile
- all (target)
- install (target)
- uninstall (target)
- clean (target)
GNU gcc
gcc -MM : generate a dependency list to make
Conventional Macros (common built in rules of makefiles)
typing "make −p" to print out the defaults
| AR | Archive−maintaining program; default is `ar'. |
| AS | Program for compiling assembly files; default is `as'. |
| CC | Program for compiling C programs; default is `cc'. |
| CO | Program for checking out files from RCS; default is `co'. |
| CXX | Program for compiling C++ programs; default is `g++'. |
| CPP | Program for running the C preprocessor, with results to standard output; default is `$(CC) -E'. |
| ARFLAGS | Flags to give the archive-maintaining program; default is `rv'. |
| ASFLAGS | Extra flags to give to the assembler when explicitly invoked on a `.s' or `.S' file. |
| CFLAGS | Extra flags to give to the C compiler. |
| CXXFLAGS | Extra flags to give to the C compiler. |
| COFLAGS | Extra flags to give to the RCS co program. |
| CPPFLAGS | Extra flags to give to the C preprocessor and programs, which use it (such as C and Fortran compilers). |
Conditional Directives
- ifeq
- ifneq
- ifdef
- ifndef
- else
- endif
e.g.
ifeq (arg1, arg2) ifeq 'arg1' 'arg2' ifeq "arg1" "arg2" ifeq "arg1" 'arg2' ifeq 'arg1' "arg2"
相關文件
- Linux 程式設計教學手冊 CH9
- 撰寫Makefile教學
- Makefile語法簡介
- 利用Autotools來建立Makefile檔案
- 實戰Makefile.am
- TutorialPoint Quick Guide
- http://www.tutorialspoint.com/makefile/makefile_quick_guide.htm
- Autotools Tutorial for Beginners
Introduce the Linux Directories
If you look at the Linux file hierarchy, you find the following :
- /bin - common binaries
- /sbin - Binaries used for system administration are placed here.
- /boot - static files of the boot loader. Usually it contain the Linux kernel, Grub boot loader files and so on.
- /dev - device files such as your CD drive, hard disk, and any other physical device. (In Linux/Unix, the common premise is that everything is a file).
- /home - user home directories are found here. In unices like FreeBSD, the home directoriesare found in /usr/home. And in Solaris it is in /export. So quite a big difference here.
- /lib - Essential shared libraries and kernel modules
- /mnt - temporary mount point useful for when you insert your USB stick and it gets mounted under /mnt. Though in Ubuntu and the likes, it is usually mounted under /media.
- /var - variable data, such as logs, news, mail spool files and so on which is constantly being modified by various programs running on your system.
- /tmp - temporary files are placed here by default.
- /usr - the secondary hierarchy which contain its own bin and sbin sub-directories.
- /etc - Usually contain the configuration files for all the programs that run on your Linux/Unix system.
- /opt - Third party application packages which does not conform to the standard Linux file hierarchy can be installed here.
- /srv - Contains data for services provided by the system.
Subscribe to:
Posts (Atom)