~/.fvwm/fvwm.stroke

#strokes
#window list without drag
Stroke 0 0 R N WindowList

#button 3 guesture with Ctrl starts programs in any context
#"r" like guestures starts rxvt
#Stroke N5456 0 A C Exec exec xkill
#Stroke N65456 0 A C Exec exec xkill
#Stroke N7414789 0 A C Exec exec rxvt
#Stroke N7414759 0 A C Exec exec rxvt
#Stroke N74147589 0 A C Exec exec rxvt
#Stroke N7414756 0 A C Exec exec rxvt
#Stroke N74156 	0 A C Exec exec rxvt
#Stroke N74159 	0 A C Exec exec rxvt
#Stroke N7536951 0 A C Exec exec xterm
#Stroke N9514753 0 A C Exec exec xterm
#Stroke N7412369 0 A C Exec exec gvim
#Stroke N1478963 0 A C Exec exec mozilla
#Stroke N7896321 0 A C Exec exec stardict
#Stroke N9874123 0 A C Exec exec drscheme
#先用这么多吧
Stroke N258 0 R C Exec exec  rxvt -geometry 80x50+105+160 
               -sr -tr -sh 90 -bg black -fg wheat 
               -fn "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-*-*"
Stroke N852 0 R C Exec exec gnome-terminal 
#打开网页浏览器
Stroke N9874123 0 R C Exec exec iceweasel
Stroke N87413 0 R C Exec exec iceweasel
Stroke N987412 0 R C Exec exec iceweasel
Stroke N87412 0 R C Exec exec iceweasel
#打开虚拟机
Stroke N753 0 R C Exec exec virtualbox
#用于关闭窗口
Stroke N5456 0 R C Exec exec xkill
Stroke N65456 0 R C Exec exec xkill
#用于开启spb
Stroke N456 0 R C Exec exec projmgr 

#
#grow horizontal and vertically
#Stroke N258 0 TSF2 N Maximize True 0 growup
#Stroke N852 0 TSF2 N Maximize True 0 growdown
#Stroke N456 0 TSF2 N Maximize True growright 0
#Stroke N654 0 TSF2 N Maximize True growleft 0

#grow bidirectional
#Stroke N25852 	0 TSF2 N Maximize True 0 grow
#Stroke N5852 	0 TSF2 N Maximize True 0 grow 
#Stroke N85258 	0 TSF2 N Maximize True 0 grow 
#Stroke N5258 	0 TSF2 N Maximize True 0 grow 
#Stroke N65456 	0 TSF2 N Maximize True grow 0
#Stroke N5456 	0 TSF2 N Maximize True grow 0
#Stroke N45654 	0 TSF2 N Maximize True grow 0
#Stroke N5654 	0 TSF2 N Maximize True grow 0

#grow diagonally
#Stroke N159 	0 TSF2 N Maximize True growright growup
#Stroke N951 	0 TSF2 N Maximize True growleft growdown
#Stroke N753 	0 TSF2 N Maximize True growright growdown
#Stroke N357 	0 TSF2 N Maximize True growleft growup
#Stroke N5159 	0 TSF2 N Maximize True grow grow
#Stroke N5951 	0 TSF2 N Maximize True grow grow
#Stroke N5753 	0 TSF2 N Maximize True grow grow
#Stroke N5357 	0 TSF2 N Maximize True grow grow

#reverse to unmaximized
#Stroke N74123 0 TSF2 N Maximize False

#window functions
#Stroke 0 	0 TSF	N RaiseLower
#Stroke 0 	0 2   	N Maximize-Func
#Stroke 0 	0 A	C Lower
#Stroke N852 	0 A C Iconify

#Drag mouse on the root window
#Mouse 1 R C StrokeFunc DrawMotion 
#Mouse 1 R A StrokeFunc DrawMotion 

#Drag mouse with Ctrl key
Mouse 3 R A StrokeFunc DrawMotion

#Drag mouse on the border
#Mouse 3 TSF N StrokeFunc DrawMotion

#Drag mouse 1 on the maxmize button
#Mouse 1 2 N StrokeFunc DrawMotion 

~/.fvwm/.fvwm2rc

ImagePath +:/usr/share/icons:/usr/share/pixmaps:/usr/share/icons/hicolor/48x48/apps:/usr/local/share/fvwm/icons:$HOME/.fvwm/icons
EdgeResistance 250 100
EdgeScroll 100 100
EdgeThickness 10
ColormapFocus FollowsMouse
ClickTime 750
DeskTopSize 2x2
#忽略数字锁定键
IgnoreModifiers L25

# default Styles:
Style * BorderWidth 5, HandleWidth 5, DepressableBorder
Style * Icon kcmkwm.png
Style * MWMFunctions, MWMDecor, MWMButtons, HintOverride
Style * DecorateTransient, NoPPosition
Style * SloppyFocus, MouseFocusClickRaises
Style * SmartPlacement
Style * Font  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
Style * IconFont  -*-simsun-medium-r-*-*-12-*-*-*-*-*-*-*
Style * HilightFore black, HilightBack gainsboro
Style * IconBox 360x200+1-1, IconFill left bottom

Style * WindowShadeShrinks, WindowShadeSteps 100

TitleStyle height 22
AddTitleStyle ActiveDown VGradient 8 gold black

MenuStyle * MWM
MenuStyle * PopupDelayed, PopupDelay 160, Animation, TitleWarp
MenuStyle * Foreground gold, Background gray40
MenuStyle * ActiveFore White
MenuStyle * Font  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
MenuStyle * MenuFace VGradient 64 darkgray MidnightBlue
#MenuStyle * MenuFace TiledPixmap weird10dark.xpm

ButtonStyle All -- UseTitleStyle
ButtonStyle All ActiveDown VGradient 8 palevioletred black

ButtonStyle 1 Vector 7 
  65x15@0 25x55@1 45x55@0 35x85@1 75x45@0 55x45@1 65x15@0
ButtonStyle 6 16 20x20@1 30x20@1 50x40@1 70x20@1 80x20@1 80x30@0 60x50@0 80x80@0 70x80@0 50x60@0 30x80@0 20x80@0 20x70@0 40x50@1 20x30@0 20x20@1

CursorStyle ROOT 58
CursorStyle TITLE 62
CursorStyle STROKE 86


# Styles for various Fvwm modules:
Style "Fvwm*"       Layer 5,  NoTitle,  Sticky, WindowListSkip
Style "Fvwm*"       BorderWidth 2, CirculateSkipIcon, CirculateSkip
Style "FvwmPager"   StaysOnTop
Style "FvwmBanner"  StaysOnTop
Style "FvwmButtons" Icon toolbox.xpm, NeverFocus
Style "FvwmConsole" SloppyFocus

# Styles for your common terminal emulator programs:
Style "xterm"       Icon /usr/share/icons/Bluecurve/48x48/apps/gnome-term-tiger.png, SloppyFocus
Style "rxvt"        NoTitle, Icon /usr/share/icons/Bluecurve/48x48/apps/gnome-term-linux.png
Style "gv"	    ClickToFocus
Style "mozilla"	    RandomPlacement, SloppyFocus
#Style "Allegro*"    Layer 5 
Style "NoResource" NoTitle BorderWidth 0, HandleWidth 0
Style "xdaliclock" NoTitle, NoHandles, Sticky, WindowListSkip, ClickToFocus, Layer 6
Style "MPlayer" NoTitle, Layer 7
Style "RealPlayer" Layer 7
Style "XSIM"	    Layer 7, NoTitle, HandleWidth 1, Sticky, WindowListSkip
Style "emacs"	    Icon gnu-animal.xpm
Style "gv"	    Icon gv.xpm
Style "Xdvi help"	NoTitle
Style "AcroRead"	VariablePosition, VariableUSPosition
Style * RaiseTransient LowerTransient StackTransientParent
#Style * NoActiveIconOverride
Style "Oracle VM VirtualBox*" MoveToPage 2

# Styles for various common programs:
Style "xbiff"       NoTitle, Sticky, WindowListSkip, ClickToFocus
Style "xcalc"       Icon xcalc.xpm, NoButton 2,RandomPlacement,ClickToFocus
Style "xmh"         Icon mail1.xpm, NoIconTitle,StickyIcon
Style "xmh"	    RandomPlacement, NoButton 2
Style "xman"	    Icon xman.xpm, RandomPlacement, ClickToFocus
Style "xmag"	    RandomPlacement, ClickToFocus
Style "FvwmButtons"	BorderWidth 0,NoHandles


#Read fvwm.strokes
# some simple default key bindings:
#Key Tab A M -
Key Next         A       SCM     Next [*] Focus
Key Prior        A       SCM     Prev [*] Focus

#在不同的桌面间移动
Key F1 A M  MoveToDesk 0 0 
Key F2 A M  MoveToDesk 0 1
Key F3 A M  MoveToDesk 0 2
Key F4 A M  MoveToDesk 0 3

#Key F1 A M GotoDesk -1
#Key F2 A M GotoDesk 1
#用于实现ctrl+alt+a截屏
#Key A  A CM Exec exec gnome-screenshot -a
Key A  A CM Exec exec ~/scripts/screenshot.sh

#用于实现Win+D
#Key D A 4 All(.*) Iconify True
Key D A 4 All (AcceptsFocus CurrentPage !Iconic !Shaded, !FvwmTaskBar, !FvwmButtons, !xdaliclock)Iconify 

#Mouse 1 A M MoveToDesk 1 0
#Mouse 3 A M MoveToDesk 0
#Mouse 1 A M MoveToDesk 1

Mouse 3 A M Iconify True
Mouse 1 A M Iconify False



Key F3 M A Module FvwmConsole -terminal rxvt -geometry 45x5-0+0 -bg gold -fg midnightblue -fn "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-*-*"
Key F5 A C Exec exec import -window root shot.png
Key F11 A C Exec xscreensaver-command -lock

# some simple default mouse bindings:
Mouse 1	R   	A       Menu RootMenu Nop
Mouse 3	R   	A       Menu AssistantMenu Nop
Mouse 2	R    	A      	Menu ProgramsMenu Nop

Mouse 3 WI	SC	CloseOrNot
Mouse 3	A   	MC      Menu RootMenu Nop
Mouse 3 A	S	Move

DestroyFunc CloseOrNot
AddToFunc CloseOrNot
+ C Silent Close
+ M Nop

#   for the title bar buttons:
Mouse 1	4    	A     	Iconify
Mouse 1 6	A	Close
Mouse 3	2    	A     	Maximize-Func2

#   for other parts of the window/borders/icons:
Mouse 1	F	A	Resize-or-Raise
Mouse 1	TS	A	Move-or-Raise
Mouse 1	I	A	Move-or-Iconify

######################## Initialization Functions ############################
DestroyFunc StartFunction
AddToFunc StartFunction   	
+ I Module FvwmButtons MainPanel
#+ I Module FvwmAuto 500 Raise Nop
+ I Module FvwmAnimate
+ I Module FvwmTaskBar
+ I Module FvwmPager 0 3
+ I Exec exec xdaliclock -transparent -geometry +842+0 -fg green
+ I Exec exec xloadimage -onroot -fullscreen ~/.fvwm/icons/desktop1.jpg 

+ I Exec exec xsim
+ I Exec exec naultilus.sh
#启动gnome菜单
#+ I Exec exec gnome-panel
#启动mail提醒
#+ I Exec exec mail-notification --sm-disable
#启动网络配置
+ I Exec exec ~/scripts/network.sh
#启动fetchmail
+ I Exec exec ~/scripts/fetchmail.sh

DestroyFunc InitFunction
AddToFunc InitFunction 	  
+ I Exec exec xscreensaver -no-splash

DestroyFunc ExitFunction
AddToFunc ExitFunction
+ I All (xdaliclock) Close
+ I All (xscreensaver) Close
+ I All (xsim) Close
+ I All (naultilus) Close
#+ I All (gnome-panel) Close
#+ I All (mail-notification) Close
+ I All (~/scripts/network.sh) Close
+ I All (~/scripts/fetchmail.sh) Close

######################## Menus ###################

DestroyMenu RootMenu
AddToMenu RootMenu	"Root Menu"	Title
+			"&xterm%mini.display.xpm%"	Exec exec gnome-terminal
+			"&Rxvt%mini.monitor.xpm%"	Exec exec rxvt
+			"&Big Rxvt"	Exec exec rxvt -geometry  78x43
+			""		Nop
+                       "&Programs"      Popup ProgramsMenu
+			""	        Nop
+                       "&System"        Popup SystemMenu
+			""		Nop
+                       "&Utilities"     Popup UtilitiesMenu
+			""		Nop
+                       "&File"          Popup FileMenu
+			""		Nop

+                       "Re&fresh Screen"   Refresh
+                       "Re&capture Screen" Recapture
+			""		Nop
+                       "&Lock"         Exec exec xscreensaver-command -lock
+			"&Exit Fvwm%mini.exit.xpm%"	Popup Quit-Verify

DestroyMenu ProgramsMenu
AddToMenu "ProgramsMenu" "Programs" Title
+			"&VIM"  Exec exec gvim
+			"文件管理"  Exec exec nautilus --no-desktop
+			"mo&zilla" Exec exec iceweasel
+                       "星际译王" Exec exec stardict

DestroyMenu SystemMenu
AddToMenu "SystemMenu" "System" Title
+                       "xkill" Exec exec xkill
+                       "NetWork Restart" Exec exec ~/scripts/netrestart.sh

+                       "关机"  Exec exec ~/scripts/shutdown.sh
+                       "重启"  Exec exec ~/scripts/restart.sh

DestroyMenu UtilitiesMenu
AddToMenu UtilitiesMenu  "Utilities" Title
+			"Top"		Exec exec xterm -T Top -n Top -e top
+			"Calculator"	Exec exec xcalc
+			"Xman"		Exec exec xman
+			"Xmag"		Exec exec xmag
+			""		Nop
+                       "Reset X defaults" Exec xrdb -load $HOME/.Xresources 
+  			"screenshot" 	Exec import -window root shot.png

DestroyMenu FileMenu
AddToMenu "FileMenu" "File" Title
#+                       "&Home"         Popup HomeDirMenu
+                       "&Device"         Popup DeviceMenu

#DestoryMenu HomeDirMenu
#AddToMenu  "HomeDirMenu"
#        PipeRead 'for i in $HOME/*;
#                 do echo "+ $i Exec xterm -e vim $i";done'
//添加自动挂载的设备
DestoryMenu DeviceMenu
AddToMenu  "DeviceMenu"
+ DynamicPopupAction  Function MakeMedia
 
AddToFunc MakeMedia
+ I DestroyMenu recreate DeviceMenu
+ I AddTomenu DeviceMenu Devices Title
+ I PipeRead 'for i in /media/*;
                 do echo AddToMenu DeviceMenu "$i"  Exec exec ~/scripts/umount.sh  $i;done'
   
DestroyMenu Quit-Verify 	
AddToMenu Quit-Verify 	"Really Quit Fvwm?" Title	
+		      	"Yes, Really Quit"  Quit	
+                       "Restart Fvwm2"     Restart fvwm2
+		      	"No, Don't Quit"    Nop	



######################## Sample Functions ##########################
DestroyFunc Move-or-Raise		
AddToFunc Move-or-Raise		I Raise
+				"M" Move
+  				"D" WindowShade
DestroyFunc Move-or-Raise2	
AddToFunc Move-or-Raise2	"M" Raise
+				"M" Move
+  				"D" Lower
DestroyFunc Maximize-Func		
AddToFunc Maximize-Func		"M" Maximize	 0 100
+				"C" Maximize	 0 80
+				"D" Maximize	 100 98
DestroyFunc Maximize-Func2	
AddToFunc Maximize-Func2	"M" Maximize	 100 0
+				"C" Maximize	 80 0
+				"D" Maximize	 100 98
DestroyFunc Move-or-Iconify	
AddToFunc Move-or-Iconify	I Raise
+				"M" Move
+				"D" Iconify
DestroyFunc Resize-or-Raise	
AddToFunc Resize-or-Raise	I Raise
+				"M" Resize
+				"D" Lower
DestroyFunc Resize-or-Raise2	
AddToFunc Resize-or-Raise2	"M" Raise
+				"M" Resize
+				"D" Lower
DestroyFunc Iconify-and-Raise     
AddToFunc Iconify-and-Raise     I Iconify
+                               I Raise

################## FvwmButtons button-bar ################################
#*FvwmButtonsBack bisque3
#*MainPanel: Geometry 80x18+40+4
#*MainPanel: Back SeaGreen
#*MainPanel: (Panel(down, indicator, delay 0, steps 1) 
#		PagerPanel "Module FvwmButtons PagerPanel")
#*MainPanel: Font  -*-simsun-medium-r-*-*-16-*-*-*-*-*-*-*
#*PagerPanel: Geometry 80x352
#*PagerPanel: (Swallow FvwmPager "Module FvwmPager 0 3")
#*PagerPanel: Font  -*-simsun-medium-r-*-*-16-*-*-*-*-*-*-*

########################## Icon Manager ####################################
# this FvwmIconMan setup is for swallowing in above button bar example
*FvwmIconMan*numManagers 1
*FvwmIconMan*Resolution  page
*FvwmIconMan*background  bisque3
*FvwmIconMan*foreground  black
*FvwmIconMan*font        -*-magicsong-medium-r-*-*-16-*-*-*-*-*-gb2312.1980-0
*FvwmIconMan*format      "%t"
*FvwmIconMan*action      Mouse   1 N sendcommand Focus, sendcommand "Iconify"
*FvwmIconMan*action      Mouse   2 N sendcommand "Iconify 1"
*FvwmIconMan*action      Mouse   3 N sendcommand "FvwmIdent"
*FvwmIconMan*followfocus true
*FvwmIconMan*sort        none
*FvwmIconMan*plainbutton          up black bisque3
*FvwmIconMan*selectbutton         down black bisque3
*FvwmIconMan*focusbutton          up yellow firebrick
*FvwmIconMan*focusandselectButton down yellow firebrick
*FvwmIconMan*dontshow icon=Untitled
#*FvwmIconMan*drawicons true
*FvwmIconMan*buttongeometry  300x0
*FvwmIconMan*managergeometry 1x5

########################## Window-Identifier ###############################
# Just choose colors and a fonts
*FvwmIdentBack MidnightBlue
*FvwmIdentFore Yellow
*FvwmIdentFont  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*

########################### Pager #########################################
*FvwmPager: Geometry 150x150+1121+845
*FvwmPager: UseSkipList
*FvwmPager: Rows 4
*FvwmPager: Columns 1
*FvwmPagerBack #908090
*FvwmPagerFore #484048
*FvwmPager:Font  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
*FvwmPagerHilight #cab3ca
*FvwmPagerLabel 0 Main
*FvwmPagerLabel 1 Internet
*FvwmPagerLabel 2 Program
*FvwmPagerLabel 3 Amusement
*FvwmPager:SmallFont  -*-simsun-medium-r-*-*-12-*-*-*-*-*-*-*
*FvwmPagerBalloons            All
*FvwmPagerBalloonBack         Yellow
*FvwmPagerBalloonFore         Black
*FvwmPager:BalloonFont         -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
*FvwmPagerBalloonYOffset      +2
*FvwmPagerBalloonBorderWidth  1
*FvwmPagerBalloonBorderColor  Black

##########################FvwmWinList##################################
*FvwmWinListBack #908090
*FvwmWinListFore Black
*FvwmWinListFont  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
*FvwmWinListAction Click1 Iconify -1,Focus
*FvwmWinListAction Click2 Iconify
*FvwmWinListAction Click3 Module "FvwmIdent" FvwmIdent
*FvwmWinListUseSkipList
*FvwmWinListGeometry +0-1
                                      

#for FvwmBacker
*FvwmBackerDesk 0 -solid steelblue
*FvwmBackerDesk 1 -solid midnightblue

#for FvwmScroll
*FvwmScrollBack grey40
*FvwmScrollFore green
	
*FvwmAnimate: Delay 25
*FvwmAnimate: Effect Random
*FvwmAnimate: Width 3

Style FvwmTaskBar HandleWidth 0, BorderWidth 0
*FvwmTaskBar: UseSkipList
*FvwmTaskBar: AutoStick
*FvwmTaskBar: DeskOnly
#*FvwmTaskBar: Action Click1 DeiconifyRaiseAndFocus
*FvwmTaskBar: Action Click2 Iconify On
*FvwmTaskBar: Action Click3 Lower
#*FvwmTaskBar: Action Click3 FvwmIdent
*FvwmTaskBar: BellVolume 30
*FvwmTaskBar: MailCommand Exec exec rxvt -e mutt
*FvwmTaskBar: 3DFvwm
*FvwmTaskBar: StartName FVWM
*FvwmTaskBar: StartMenu RootMenu
*FvwmTaskBar: Font  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
#*FvwmTaskBar: Font  "xft:Luxi Mono"
*FvwmTaskBar: SelFont  -*-simsun-medium-r-*-*-14-*-*-*-*-*-*-*
*FvwmTaskBar: ShowTips
*FvwmTaskBar: ClockFormat 
*FvwmTaskBar: WindowButtonsRightMargin 20 

*FvwmTaskBar: Back seagreen
*FvwmTaskBar: Fore gold2
*FvwmTaskBar: FocusFore cornsilk
*FvwmTaskBar: IconBack darkgreen
*FvwmTaskBar: IconFore white
*FvwmTaskBar: StartCommand(Mouse 3) Popup RightKeyMenu 

#*FvwmTaskBar: Button Title hello, Icon mini.x.xpm, Action (Mouse 1) Module FvwmConsole
#*FvwmTaskBar: DateFormat "%A, %B %d, %Y"
#*FvwmTaskBar: WindowButtonsLeftMargin 20
#*FvwmTaskBar: HighlightFocus
#*FvwmTaskBar: AutoHide 6

Read fvwm.strokes

正在一步一步改良!

我的debian下安装 spb16.3的经历

网上大多数都是在redhat系列机器的安装的,我始终不成功:

整了好几天总算能启动了:

额外的安装步骤如下:

        1.安装csh,ksh

        2.

cd /usr
ln -s /tmp tmp

       3.

cd /bin
ln -s /usr/bin/basename basename

       4.将教程中的

./pubkey -d cdslmd -y

改成

./pubkey -d cdslmd -fy

       剩下的参看:http://www.isspy.com/opensuse13%E4%B8%8B%E5%AE%89%E8%A3%85-cadence-allegro-spb-16-30-000/

      教程

我的.Xresources

经过无数次的尝试,我终于在rxvt下vim中的desert配色方案中达到与gnome-terminal相似的结果!

Rxvt.colorIT:       magenta
Rxvt.underlineColor:cyan
Rxvt.tintColor:     gray
Rxvt.cursorColor:   white
Rxvt.shading:       100

xvt.background: black
Rxvt.foreground : #f6f3e8
Rxvt.colorBD : #8ac6f2
Rxvt.colorUL : #95e454
! red
!Rxvt.color1 : #e5786d
!Rxvt.color9 : #e5786d
!
!! green
!Rxvt.color2 : #cae682
!Rxvt.color10 : #cae682
!! yellow (from the Desert color scheme for Vim:
! http://fugal.net/vim/colors/desert.html)
!Rxvt.color3 : khaki
!Rxvt.color11 : khaki
!! blue
!Rxvt.color4 : #8ac6f2
!Rxvt.color12 : #8ac6f2
!! magenta (green at hue 300)
!Rxvt.color5 : #e682e6
!Rxvt.color13 : #e682e6
!! cyan (green at hue 180)
!Rxvt.color6 : #82e6e6
!Rxvt.color14 : #82e6e6
!! white
!Rxvt.color7 : #f6f3e8
!Rxvt.color15 : #f6f3e8

Rxvt.termName : xterm
!Rxvt.color0: black
!Rxvt.color1: red3
!特定粗体字符背景的颜色 默认:red3
!Rxvt.color2: green3
!数据类型的颜色 默认:green3
!Rxvt.color3: #cd8500
!变量值 语言逻辑词的颜色 默认:yellow3  #cd8500
!Rxvt.color4: DodgerBlue1
!Rxvt.color5: magenta3
!宏定义 字符转义等  默认:magenta3
!Rxvt.color6: gray50
!注释的颜色 默认:cyan3  #336600
!Rxvt.color7:  cyan3 
!Rxvt.color8:  #336600
!Rxvt.color7: gray90
!Rxvt.color8: gray25
!常规字的颜色
!Rxvt.color9: red
!Rxvt.color10: green
!Rxvt.color11: yellow
!Rxvt.color12: SteelBlue1
!Rxvt.color13: magenta
!Rxvt.color14: cyan
!Rxvt.color15: white
!
!
! Red
Rxvt*color1:           #C12121
Rxvt*color9:           #E50E0E

! Green
Rxvt*color2:           #597b20
Rxvt*color10:          #89b83f

! Yellow
Rxvt*color3:           #Ded838
Rxvt*color11:          #efef60

! Blue
Rxvt*color4:           #265997
Rxvt*color12:          #3F6FD0

! Magenta
Rxvt*color5:           #706c9a
Rxvt*color13:          khaki 

! Cyan
!URxvt*color6:           #69a2b0
!URxvt*color14:          #a1cdcd

! White
!URxvt*color7:           #BBBBBB
!URxvt*color15:          #EEEEEF

getopt得用法

getopt被用来解析命令行选项参数。

#include <unistd.h>
      extern
char *optarg; 
 //选项的参数指针
      extern
int optind,  
 //下一次调用getopt的时,从optind存储的位置处重新开始检查选项。 
      extern
int opterr, 
 //当opterr=0时,getopt不向stderr输出错误信息。
      extern
int optopt; 
 //当命令行选项字符不包括在optstring中或者选项缺少必要的参数时,该选项存储在optopt 中,getopt返回’?’、
      int
getopt(int argc, char * const argv[], const char *optstring);

 调用一次,返回一个选项。在命令行选项参数再也检查不到optstring中包含的选项时,返回-1,同时optind储存第一个不包含选项的命令行参数。

首先说一下什么是选项,什么是参数。

1.单个字符,表示选项,

2.单个字符后接一个冒号:表示该选项后必须跟一个参数。参数紧跟在选项后或者以空格隔开。该参数的指针赋给optarg。
3 单个字符后跟两个冒号,表示该选项后必须跟一个参数。参数必须紧跟在选项后不能以空格隔开。该参数的指针赋给optarg。(这个特性是GNU的扩张)。

例如gcc -g -o test test.c ,其中g和o表示选项,test为选项o的参数。

上面是getopt()函数的基本含义,大家懂得了这些之后,我们一个例子加深一下理解。

例如我们这样调用getopt(argc, argv, "ab:c:de::");

从上面我们可以知道,选项a,d没有参数,选项b,c有一个参数,选项e有有一个参数且必须紧跟在选项后不能以空格隔开。getopt首先扫描argv[1]到argv[argc-1],并将选项及参数依次放到argv数组的最左边,非选项参数依次放到argv的最后边。

执行程序为:
              5
 
      
$ ./test file1 -a -b -c code -d file2 -e file3
 扫描过程中,optind是下一个选项的索引, 非选项参数将跳过,同时optind增1。optind初始值为1。当扫描argv[1]时,为非选项参数,跳过,optind=2;扫描到-a选项时,下一个将要扫描的选项是-b,则optind更改为3;扫描到-b选项时,后面有参数(会认为-c为选项b的参数),optind=5,扫描到code非选项跳过optind=6;扫描到-d选项,后面没有参数,optind=7;扫描到file2非选项跳过optind=8;扫描到-e后面本来应该有参数,optind=9但是有空格所以e的参数为空。
 
扫描结束后,getopt会将argv数组修改成下面的形式
          2
 
                  
9

$ ./test -a -b -c -d -e file1 code file2 file3
 
同时,optind会指向非选项的第一个参数,如上面,optind将指向file1

代码如下:

#include <unistd.h>

#include <stdio.h>

int main(int argc, char * argv[])

{

   int aflag=0, bflag=0, cflag=0;

   int ch;

printf("optind:%d,opterr:%dn",optind,opterr);

printf("————————–n");

   while ((ch = getopt(argc, argv, "ab:c:de::")) != -1)

   {

       printf("optind:
%d,argc:%d,argv[%d]:%sn", optind,argc,optind,argv[optind]);


       switch
(ch) {


       case
‘a’:


           printf("HAVE
option: -ann");


    

           break;

       case
‘b’:


           printf("HAVE
option: -bn");


         

           printf("The
argument of -b is %snn", optarg);


           break;

       case
‘c’:


           printf("HAVE
option: -cn");


           printf("The
argument of -c is %snn", optarg);




           break;

   case ‘d’:

      printf("HAVE
option: -dn");


      break;

   case ‘e’:

      printf("HAVE
option: -en");


      printf("The
argument of -e is %snn", optarg);


      break;



       case
‘?’:


           printf("Unknown
option: %cn",(char)optopt);


           break;

       }

   }

   printf("—————————-n");

   printf("optind=%d,argv[%d]=%sn",optind,optind,argv[optind]);

}

执行结果:

shiqi@wjl-desktop:~/code$ vim getopt.c

shiqi@wjl-desktop:~/code$ gcc getopt.c -o g

shiqi@wjl-desktop:~/code$ ./g file1 -a -b -c code -d file2 -e file3

optind:1,opterr:1

————————–

optind: 3,argc:10,argv[3]:-b

HAVE option: -a



optind: 5,argc:10,argv[5]:code

HAVE option: -b

The argument of -b is -c



optind: 7,argc:10,argv[7]:file2

HAVE option: -d



optind: 9,argc:10,argv[9]:file3

HAVE option: -e

The argument of -e is (null)   



—————————-

optind=6,argv[6]=file1        //while循环执行完后,optind=6

C语言编程好习惯(持续更新)

1.编程好习惯之变量定义:
	定义变量时总是按变量类型所占空间大小来排序是最好的!
	如果是只有某个函数使用些变量,而且你又需要在函数让函数退出时不被销毁,那么就使用static吧
2.编程好习惯之函数定义:
	如果我们定义的C函数仅在此C文件中被调用那么加上static吧(适用于多文件编程)
      	如果我们想躲避C函数参数的类型检查,那 么K&R的函数定义声明方式还是很不错的!
3.编程好习惯之变量类型使用
	如果我们考虑可移植性的化,就最好不要去乱用int变量,因为int在不同的平台和编译器上是变化的!
4.编程好习惯之编码
	有时间在不明显减少代码的可读性时,可以考虑将一些语句合并,使编译器充分使用寄存器,
	当然如果使用register 变量作中间变量效果也是一样的!
	对于一些频繁使用的变量可以考虑使用寄存器变理,如for语句中使用的变量,这样可以获得更快的速度,但是要注意的是,这个变量的使用范围一定要非常的小才可以使用寄存器变量!
	尽量使用逻辑运算代替算术运算
5.在使用类似 a &= 0xfff7 来清除某一位时,不妨试试 a &= ~(1 << 4),即不会影响效率,编译器还会帮你确定到底是使用a &= 0xffffff7 还是在高位有更多个ff.
6.宏名有效范围仅限于本c源文件
7.如果要清除某个标志位,或许直接清除,这样比先判断再清除要快得多
8.在进行条件判断时要善于利于逻辑表达式的求值顺序,如if (a > 0 && b > 1)这时侯要花点功夫确定一下到底是(a > 0 && b > 1)还是(b > 1 && a >0)这有关于求值顺序与代码执行效率
9.在使用for循环时,最好外层循环的次数比内层循环大,如
      for (i = 0; i < 100; i++)
        for (i = 0; i < 5; i++)
这样效率比较高。