Linux

shell

将配置保存到 ~/.bashrc 应用于当前用户,保存到 /etc/profile 应用于所有用户。

新创建的终端窗口会应用 /etc/profile 的配置,手动登陆一次 bash 则会应用 ~/.bashrc 的配置。

命令别名

alias l='ls -l'
alias la='ls -la'
alias lrt='ls -lrt'

# mac os
alias l='ls -lG'
alias la='ls -laG'
alias lrt='ls -lrtG'
alias vi='vim'

命令提示符

export PS1="\[\e[32m\]\u\[\e[m\]@\[\e[32m\]\h\[\e[m\]:\[\e[31m\]\w\[\e[m\]$ "

# 如果安装了git,在仓库内可以显示分支名称
function git-branch {
  local branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
  if [ $branch ]; then printf "[%s]" $branch; fi
}
export PS1="\[\e[32m\]\u\[\e[m\]@\[\e[32m\]\h\[\e[m\]:\[\e[31m\]\w\[\e[m\]\[\e[32m\]\$(git-branch)\[\e[m\]$ "

确保.bashrc被成功加载

当初次打开新的终端页面时,.bashrc 有可能未被加载,需要在 /etc/profile 追加以下内容来确保其加载。

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

Go

alias gr='go run main.go'

vim

~/.vimrc 添加:

syntax on
set number
set nocompatible
set showcmd
set t_Co=256
set tabstop=4
set softtabstop=4
set shiftwidth=4
set cursorline
set showmatch
set hlsearch
set incsearch
set ignorecase
set nowrapscan
set noswapfile
set autochdir
set list
set listchars=tab:>-,trail:-
set shortmess=atI
set backspace=indent,eol,start
if &diff
    colors blue
endif

系统配置

设置用户 sudo 免密码

chmod +w /etc/sudoers

# 在 /etc/sudoers 中添加以下行,指定用户名:
<user> ALL=(ALL) NOPASSWD:ALL

chmod -w /etc/sudoers

Sublime Text

设置配置

{
	"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
	"drag_text": false,
	"draw_white_space": "all",
	"font_face": "Microsoft Yahei Mono",
	"font_size": 12,
	"highlight_line": true,
	"ignored_packages":
	[
		"Package Control",
		"Vintage"
	],
	"rulers":
	[
		120
	],
	"scroll_past_end": true,
	"tab_size": 4,
	"translate_tabs_to_spaces": false,
	"show_tab_close_buttons": false,
	"open_files_in_new_window": false,
	"update_check": false,
	"theme": "auto"
}