WSL 服务自动启动
参考 https://zhuanlan.zhihu.com/p/47733615
Windows 启用 WSL 功能支持
> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
在Windows应用商店中下载安装 Ubuntu 系统



Ubuntu 系统设置更新源设置为国内更新源
lsgx@DESKTOP-OS0DFSI:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak lsgx@DESKTOP-OS0DFSI:~$ sudo cat /etc/apt/sources.list # See https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # 预发布软件源,不建议启用 #deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse #deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
lsgx@DESKTOP-OS0DFSI:~$
Ubuntu 系统升级更新
lsgx@DESKTOP-OS0DFSI:~$ sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y
Ubuntu 系统安装 ssh 服务
lsgx@DESKTOP-OS0DFSI:~$ sudo apt-get install aptitude lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$ sudo aptitude purge openssh-server openssh-sftp-server lsgx@DESKTOP-OS0DFSI:~$ sudo aptitude install openssh-server openssh-sftp-server lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$ sudo cat /etc/ssh/sshd_config # $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # Restart ssh service command : sudo service ssh --full-restart # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. Port 2222 #AddressFamily any ListenAddress 0.0.0.0 #ListenAddress :: #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_ecdsa_key #HostKey /etc/ssh/ssh_host_ed25519_key # Ciphers and keying #RekeyLimit default none # Logging #SyslogFacility AUTH #LogLevel INFO # Authentication: #LoginGraceTime 2m PermitRootLogin no #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #PubkeyAuthentication yes # Expect .ssh/authorized_keys2 to be disregarded by default in future. #AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #AuthorizedPrincipalsFile none #AuthorizedKeysCommand none #AuthorizedKeysCommandUser nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! PasswordAuthentication yes #PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no AllowUsers lsgx # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes #GSSAPIStrictAcceptorCheck yes #GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. UsePAM yes #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes #PermitTTY yes PrintMotd no #PrintLastLog yes #TCPKeepAlive yes #UseLogin no #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #UseDNS no #PidFile /var/run/sshd.pid #MaxStartups 10:30:100 #PermitTunnel no #ChrootDirectory none #VersionAddendum none # no default banner path #Banner none # Allow client to pass locale environment variables AcceptEnv LANG LC_* # override default of no subsystems Subsystem sftp /usr/lib/openssh/sftp-server # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # PermitTTY no # ForceCommand cvs server lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$ sudo service ssh --full-restart lsgx@DESKTOP-OS0DFSI:~$
Windows 防火墙中开放 2222 端口拨入




Ubuntu 系统添加启动脚本文件 /etc/init.wsl
lsgx@DESKTOP-OS0DFSI:~$ sudo aptitude install supervisor
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ sudo cat /etc/init.wsl
#! /bin/sh
# Filename: /etc/init.wsl
# Usage: sudo /etc/init.wsl [start|stop|restart]
/etc/init.d/cron $1
/etc/init.d/ssh $1
/etc/init.d/supervisor $1
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ sudo chmod +x /etc/init.wsl
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
%sudo ALL=NOPASSWD: /etc/init.wsl
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
lsgx@DESKTOP-OS0DFSI:~$
Windows 中添加自动启动的脚本 startubuntu.vbs 。
a. 打开当前用户默认自启动加载文件夹,在 Windows 中,开始-运行,输入:
shell:startup
b. 在当前用户默认自启动加载文件夹中,添加要加载的VBS脚本文件 startubuntu.vbs 。
Set ws = WScript.CreateObject("WScript.Shell")
ws.run "ubuntu run sudo /etc/init.wsl start", vbhide
重启 Windows 系统,验证WSL服务是否自动启动。

查看 Ubuntu 系统启动的服务列表
lsgx@DESKTOP-OS0DFSI:~$ sudo service --status-all
[ - ] acpid
[ - ] apparmor
[ ? ] apport
[ - ] atd
[ - ] console-setup.sh
[ + ] cron
[ ? ] cryptdisks
[ ? ] cryptdisks-early
[ - ] dbus
[ - ] ebtables
[ ? ] hwclock.sh
[ + ] irqbalance
[ + ] iscsid
[ - ] keyboard-setup.sh
[ - ] kmod
[ - ] lvm2
[ + ] lvm2-lvmetad
[ + ] lvm2-lvmpolld
[ - ] lxcfs
[ - ] lxd
[ - ] mdadm
[ - ] mdadm-waitidle
[ + ] open-iscsi
[ - ] open-vm-tools
[ ? ] plymouth
[ ? ] plymouth-log
[ - ] procps
[ - ] rsync
[ - ] rsyslog
[ - ] screen-cleanup
[ + ] ssh
[ + ] supervisor
[ - ] udev
[ - ] ufw
[ - ] unattended-upgrades
[ - ] uuidd
[ - ] x11-common
lsgx@DESKTOP-OS0DFSI:~$
开发环境软件安装
$ sudo aptitude install tree
$ sudo aptitude install curl
$ sudo aptitude install wget $ sudo aptitude install htop
$ sudo aptitude install bash bash-completion $ sudo aptitude install xterm $ sudo aptitude install tmux $ sudo aptitude install p7zip-full $ sudo aptitude install dmidecode $ sudo aptitude install pciutils $ sudo aptitude install psmisc $ sudo aptitude install v86d
$ sudo aptitude install hwinfo $ sudo aptitude install lshw $ sudo aptitude install smartmontools $ sudo aptitude install build-essential $ sudo aptitude install gdb gdb-doc cgdb $ sudo aptitude install perl perl-doc $ sudo aptitude install guile-2.0 guile-2.0-libs guile-2.2-doc
$ sudo aptitude install chezscheme $ sudo aptitude install expect $ sudo aptitude install autoconf automake $ sudo aptitude install libtool libtool-bin libtool-doc $ sudo aptitude install cmake cmake-curses-gui cmake-doc $ sudo aptitude install git git-doc $ sudo aptitude install subversion subversion-tools $ sudo aptitude install fakeroot $ sudo aptitude install valgrind $ sudo aptitude install bison $ sudo aptitude install flex flex-doc $ sudo aptitude install swig $ sudo aptitude install libncurses5-dev $ sudo aptitude install libssl-dev $ sudo aptitude install libiconv-hook-dev $ sudo aptitude install dpkg-dev $ sudo aptitude install kernel-package $ sudo aptitude install linux-headers-`uname -r` $ sudo aptitude install locales language-selector-common $ sudo aptitude install language-pack-en language-pack-en-base $ sudo aptitude install language-pack-zh-hans language-pack-zh-hans-base $
lsgx@DESKTOP-OS0DFSI:~$ cat /var/lib/locales/supported.d/local en_US.UTF-8 UTF-8 zh_CN.UTF-8 UTF-8 zh_SG.UTF-8 UTF-8 lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$ cat /etc/default/locale # File generated by update-locale LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" lsgx@DESKTOP-OS0DFSI:~$ lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ cat ~/.vimrc
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2001 Jul 18
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设定默认解码
set guifont=-misc-simsun-medium-r-normal-*-*-120-*-*-c-*-iso10646-1
set bsdir=buffer
set enc=utf-8
set fenc=utf-8
set fencs=utf-8,ucs-bom,gb2312,cp936,gbk,big5
set langmenu=zh_CN.UTF-8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,latin1,gb2312,gb18030,cp936,gbk,big5
set termencoding=utf-8
"设置颜色
colorscheme desert
"set guifont=Nimbus Mono L 12
"set guifont=WenQuanYi Bitmap Song 12
"set guifont=Verdana 10
"set guifont=Courier 11
"set guifont=Bitstream Vera Sans Mono 10
" 显示中文帮助
if version >= 603
set helplang=cn
set encoding=utf-8
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
" 不要使用vi的键盘模式,而是vim自己的键盘模式
set nocompatible
" history文件中需要记录的行数
set history=100
" 显示行号
set number
" 在处理未保存或只读文件的时候,弹出确认
set confirm
" 与windows共享剪贴板
set clipboard+=unnamed
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 语法高亮显示
syntax on
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""高亮显示gtk关键字""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax keyword gtkType gint gshort guint gushort gulong gdouble gfloat gchar guchar gboolean gpointer
highlight link gtkType Type
" 高亮字符,让其不受100列限制
highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
match OverLength '\%101v.*'
" 状态行颜色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文件设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 不要备份文件(根据自己需要取舍)
set nobackup
" 不要生成swap文件,当buffer被丢弃的时候隐藏它
setlocal noswapfile
set bufhidden=hide
" 字符间插入的像素行数目
set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 在状态行上显示光标所在位置的行号和列号
set ruler
set rulerformat=%20(%2*%<%f%= %m%r %3l %c %p%%%)
" 输入的命令显示出来,看的清楚些
set showcmd
" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=2
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=indent,eol,start
" 跨行移动
set whichwrap=b,s,<,>,[,]
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
"set mouse=a
"set selection=exclusive
"set selectmode=mouse,key
" 启动的时候不显示那个援助乌干达儿童的提示
set shortmess=atI
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 不让vim发出讨厌的滴滴声
set noerrorbells
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert: ,stl: ,stlnc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 搜索和匹配
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5
" 在搜索的时候忽略大小写
set ignorecase
" 不要高亮被搜索的句子(phrases)
set nohlsearch
" 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索)
set incsearch
" 制表符可见
"set list
" 输入:set list命令是应该显示些啥?
set listchars=tab:| ,trail:.,extends:>,precedes:<,eol:$
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 不要闪烁
set novisualbell
" 我的状态行显示的内容(包括文件类型和解码)
set statusline=%F%m%r%h%w [FORMAT=%{&ff}] [TYPE=%Y] [POS=%l,%v][%p%%] %{strftime("%d/%m/%y - %H:%M")}
" 总是显示状态行
set laststatus=2
" 屏幕放不下时,按一次屏幕移动一个字符
set sidescroll=1
" 下面的滚动条开启
"slet g:netrw_winsize = 20et guioptions+=b
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文本格式和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 自动格式化
set formatoptions=tcrqn
" 继承前一行的缩进方式,特别适用于多行注释
set autoindent
" 为C程序提供自动缩进
set smartindent
" 使用C样式的缩进
set cindent
" 制表符为4
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 不要用空格代替制表符
set noexpandtab
" 不要换行
set nowrap
" 在行和段开始处使用制表符
set smarttab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按照名称排序
let Tlist_Sort_Type = "name"
" 在右侧显示窗口
let Tlist_Use_Right_Window = 1
" 压缩方式
let Tlist_Compart_Format = 1
" 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_Exist_OnlyWindow = 1
" 不要关闭其他文件的tags
let Tlist_File_Fold_Auto_Close = 0
" 不要显示折叠树
let Tlist_Enable_Fold_Column = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 键盘命令
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"imap <C-P> <C-X><C-P>
"imap <C-F> <C-X><C-F>
"imap <C-I> <C-X><C-I>
"imap <C-D> <C-X><C-D>
"imap <C-L> <C-X><C-L>
" 根据打开文件类型, 启用智能补全
set completeopt=longest,menu
" p命令可以使用剪切板上的内容来替换选中的内容
vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
nmap <F2> :nohlsearch<CR>
map <F3> :copen<CR>:grep -R
map <F7> :w<CR><CR>:copen<CR>:make<CR><CR>
imap <F7> <Esc>:w<CR><CR>:copen<CR>:make<CR><CR>
map <F8> :cclose<CR>
map <F9> :TlistToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 代码折叠编译运行按键命令
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 只在下列文件类型被侦测到的时候显示行号,普通文本文件不显示
if has("autocmd")
autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o-->
autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o/*<ESC>'>o*/
autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=78
autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
if line("'"") > 0 && line("'"") <= line("{1}quot;) |
exe "normal g`"" |
endif
endif " has("autocmd")
" F5编译和运行C程序,F6编译和运行C++程序
" 请注意,下述代码在windows下使用会报错
" 需要去掉./这两个字符
" C的编译和运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc
" C++的编译和运行
map <F6> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc
" 能够漂亮地显示.NFO文件
set encoding=utf-8
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()
" 高亮显示普通txt文件(需要txt.vim脚本)
au BufRead,BufNewFile * setfiletype txt
" 用空格键来开关折叠
set foldenable
"set foldmethod=manual
set foldmethod=syntax
set foldlevel=100
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" minibufexpl插件的一般设置
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
"设置快捷方式 Set mapleader
let mapleader = ","
"快捷加载,当输入",ss"时,加载 .vimrc 文件
map <silent> <leader>ss :source ~/.vimrc<cr>
"快速打开编辑 .vimrc配置文件--->",ee"
map <silent> <leader>ee :e ~/.vimrc<cr>
"快速保存文件--->",w"
map <silent> <leader>w :w<cr>
"快速保存并退出文件--->",w"
map <silent> <leader>wq :wq<cr>
"自动命令,每次写入.vimrc后,都会执行这个自动命令,source一次~/.vimrc
autocmd! bufwritepost .vimrc source ~/.vimrc
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ cat ~/.tmux.conf
#
# author : lsgx <lsgxthink@gmail.com>
# modified : 2014-11-12
#
#-- base settings --#
set -g default-terminal "screen-256color" # 设置终端缺省的支持颜色为256色
set -g display-time 3000 # 提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set -g escape-time 0 # 等待时间的持续时间;设置越小越好
set -g history-limit 65535 # 历史记录条数的最大限制值
#set -g base-index 1 # 窗口的初始序号;默认为0,这里设置为1
#set -g pane-base-index 1 # 面板的初始序号;默认为0,这里设置为1
#set -sg repeat-time 600 # 控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
#set -s quiet on
#setw -g xterm-keys on
#-- bindkeys --#
# prefix key (Ctrl+a) # 将激活控制台的快捷键由Ctrl+b修改为Ctrl+a
set -g prefix ^a
unbind ^b
bind a send-prefix
# split window # 窗口分割
unbind '"'
bind - splitw -v # vertical split (prefix -) # 上下分割窗口
unbind %
bind | splitw -h # horizontal split (prefix |) # 左右分割窗口
# select pane # 选择面板
bind k selectp -U # above (prefix k) # 选择上面板
bind j selectp -D # below (prefix j) # 选择下面板
bind h selectp -L # left (prefix h) # 选择左面板
bind l selectp -R # right (prefix l) # 选择右面板
# resize pane
bind -r ^k resizep -U 2 # upward (prefix Ctrl+k) # 当前面板上移2
bind -r ^j resizep -D 2 # downward (prefix Ctrl+j) # 当前面板下移2
bind -r ^h resizep -L 2 # to the left (prefix Ctrl+h) # 当前面板左移2
bind -r ^l resizep -R 2 # to the right (prefix Ctrl+l) # 当前面板右移2
# swap pane
bind ^u swapp -U # swap with the previous pane (prefix Ctrl+u) # 与上面板交换
bind ^d swapp -D # swap with the next pane (prefix Ctrl+d) # 与下面板交换
# create new session
bind C-c new-session # 创建一个新的会话
# control sessions
bind z kill-session # 结束一个会话
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%' # 查找会话
# clear both screen and history
#bind -n C-l send-keys C-l ; run 'tmux clear-history' # 清空屏幕内容和历史记录
# reload config (prefix r)
bind r source ~/.tmux.conf ; display "Configuration reloaded!" # 重新加载配置文件
# misc
bind e lastp # select the last pane (prefix e) # 选择最后一个面板
bind ^e last # select the last window (prefix Ctrl+e) # 选择最后一个窗口
bind q killp # kill pane (prefix q) # 关闭当前面板
bind ^q killw # kill window (prefix Ctrl+q) # 关闭当前窗口
# app
bind ! splitw htop # htop (prefix !)
bind m command-prompt "splitw 'exec man %%'" # man (prefix m)
bind @ command-prompt "splitw 'exec perldoc -t -f %%'" # perl func (prefix @)
bind * command-prompt "splitw 'exec perldoc -t -v %%'" # perl var (prefix *)
bind % command-prompt "splitw 'exec perldoc -t %%'" # perl doc (prefix %)
bind / command-prompt "splitw 'exec ri %%'" # ruby doc (prefix /)
#-- statusbar --#
#set -g status-utf8 on # 开启状态栏的UTF-8支持
set -g status-interval 1 # 状态栏的分辨时间间隔
set -g status-keys vi # 操作状态栏时的默认键盘布局;可以设置为vi或emacs
set -g visual-activity on # 开启窗口操作的可视
set -g set-clipboard on # 开启剪切板
set -g display-panes-time 800 # slightly longer pane indicators display time # 稍长的窗格中显示的时间指标
set -g display-time 1000 # slightly longer status messages display time # 稍长的状态消息的显示时间
set -g renumber-windows on # renumber windows when a window is closed # 关闭窗口后重新编号
setw -g automatic-rename on # rename window to reflect current program # 重命名窗口,以反映当前的程序
#setw -g utf8 on # 开启窗口的UTF-8支持
setw -g monitor-activity on # 开启窗口活动监视
setw -g mode-keys vi # 复制模式中的默认键盘布局;可以设置为vi或emacs
setw -g clock-mode-style 24 # 24 hour clock # 24小时显示方式
#setw -g mode-mouse on # 开启鼠标模式
# copy mode
bind Enter copy-mode # enter copy mode # 按Enter进入复制模式
bind b list-buffers # list paster buffers # 复制缓冲区列表
bind p paste-buffer # paste from the top pate buffer # 粘贴最后复制的缓冲区内容
bind P choose-buffer # choose which buffer to paste from # 选择粘贴缓冲区
# the following vi-copy bindings match my vim settings
# see https://github.com/gpakosz/.vim.git
#bind -t vi-copy v begin-selection # 复制模式下开始选取
#bind -t vi-copy C-v rectangle-toggle # 复制模式下矩形选取
#bind -t vi-copy y copy-selection # 复制模式下复制选取的内容
#bind -t vi-copy Escape cancel # 复制模式下退出复制模式
#bind -t vi-copy H start-of-line # 复制模式下开始行选取
#bind -t vi-copy L end-of-line # 复制模式下结束行选取
# mouse resize selcet
#setw -g mouse-resize-pane on # 鼠标调整面板大小
#setw -g mouse-select-pane on # 鼠标选择面板
#setw -g mouse-select-window on # 鼠标选择窗口
# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer "$(xclip -o -sel clipbaord)"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i -sel clipbaord"
#-- colorscheme --#
# see also: https://github.com/daethorian/conf-tmux/blob/master/colors/zenburn.conf
# modes
setw -g clock-mode-colour colour223
setw -g mode-attr bold
setw -g mode-fg colour223
setw -g mode-bg colour235
# panes
set -g pane-border-bg colour234
set -g pane-border-fg colour234
set -g pane-active-border-bg colour232
set -g pane-active-border-fg colour232
# statusbar
set -g status-justify centre
set -g status-bg colour235
set -g status-fg colour248
set -g status-attr dim
set -g status-left "#[fg=green,bright]Session: #S #[fg=yellow,bright]Window: #I #[fg=cyan,bright]Pane: #P"
set -g status-left-attr bright
set -g status-left-length 30
set -g status-right "#[fg=yellow,bright][ #[fg=cyan,bright]#W #[fg=yellow,bright]]#[default] #[fg=yellow,bright]- %Y.%m.%d #[fg=green,bright]%H:%M #[default]"
set -g status-right-attr bright
set-option -g status-right-length 30
setw -g window-status-current-fg colour223
setw -g window-status-current-bg colour237
setw -g window-status-current-attr bold
#setw -g window-status-current-format "#I:#W#F"
#setw -g window-status-alert-attr bold
#setw -g window-status-alert-fg colour255
#setw -g window-status-alert-bg colour160
# messages
set -g message-attr bold
set -g message-fg colour223
set -g message-bg colour235
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$ cat ~/.Xresources
!------------------------------------------
! XTerm
!------------------------------------------
XTerm*termName: xterm-color
XTerm*visualBell: false
XTerm*marginBell: false
XTerm*alwaysHighlight: false
XTerm*cursorBlink: true
XTerm*cursorOffTime: 450
XTerm*cursorOnTime: 900
XTerm*highlightSelection: true
XTerm*saveLines: 8192
XTerm*foreground: rgb:a8/a8/a8
XTerm*background: rgb:00/00/00
XTerm*color0: rgb:00/00/00
XTerm*color1: rgb:a8/00/00
XTerm*color2: rgb:00/a8/00
XTerm*color3: rgb:a8/54/00
XTerm*color4: rgb:00/00/a8
XTerm*color5: rgb:a8/00/a8
XTerm*color6: rgb:00/a8/a8
XTerm*color7: rgb:a8/a8/a8
XTerm*color8: rgb:54/54/54
XTerm*color9: rgb:fc/54/54
XTerm*color10: rgb:54/fc/54
XTerm*color11: rgb:fc/fc/54
XTerm*color12: rgb:54/54/fc
XTerm*color13: rgb:fc/54/fc
XTerm*color14: rgb:54/fc/fc
XTerm*color15: rgb:fc/fc/fc
XTerm*scrollBar: true
XTerm*rightScrollBar: true
XTerm*scrollKey: false
XTerm*scrollTtyOutput: false
XTerm*loginShell: false
XTerm*locale: true
XTerm*eightBitInput: false
XTerm*eightBitOutput: true
XTerm*metaSendEscape: true
XTerm*faceName: Bitstream Vera Sans Mono
XTerm*faceSize: 14
XTerm*faceNameDoublesize: WenQuanYi Bitmap Song
XTerm*mkWidth: false
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48
lsgx@DESKTOP-OS0DFSI:~$
lsgx@DESKTOP-OS0DFSI:~$
================== End