Linux终端基础环境设置

本文介绍了Linux终端的基础环境设置,包括.bashrc文件的个性化配置,.vimrc文件的Vim编辑器设置,以及.gitconfig文件的Git个性化选项,帮助用户提升终端使用体验。

Table of Contents

bashrc

vimrc

gitconfig


bashrc

export PS1="\[\033[0;37m\][\u@\h \t \w]\[\033[00m\] "

set -o vi
export TERM=xterm
export EDITOR=vi

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=5000
HISTFILESIZE=5000
# Save and reload the history after each command finishes
#export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
h() {
    _bash_history_sync
    #builtin history "$@"
}
_bash_history_sync() {
    builtin history -a
    HISTFILESIZE=$HISTFILESIZE
    builtin history -c
    builtin history -r
}
export PROMPT_COMMAND=_bash_history_sync

alias c=clear
alias l='ls -lh'
alias la='ls -a'
alias ll='ls -la'
alias lr='ls -lrt'
alias psof='ps -ef | grep -v grep | grep '
alias finda='find . -name '
alias vin='vim -u NONE'
alias sudo='sudo -E'

alias cd.='cd ../'
alias cd..='cd ../../'
alias cd...='cd ../../../'
alias cd....='cd ../../../../'
alias cd.....='cd ../../../../../'
alias sd='echo $PWD > ~/.oldpwd'
alias ds='cd `cat ~/.oldpwd`'

vimrc

set nocompatible	" Use Vim defaults (much better!)
set bs=indent,eol,start		" allow backspacing over everything in insert mode
set viminfo='20,\"500	" read/write a .viminfo file, don't store more
set history=500		" keep 50 lines of command line history
set ruler		" show the cursor position all the time

" Uncomment the following to have Vim jump to the last position when reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

" search
set showmatch		" Show matching brackets.
set smartcase		" Do smart case matching
set incsearch		" Incremental search
set hlsearch
set ignorecase
set nowrapscan

" code read
"filetype plugin indent on
filetype on
syntax on
set cin
set ai
set foldmethod=syntax
set foldlevel=100
set noexpandtab
set tabstop=8
set shiftwidth=8
let local_vimrc = findfile(".vimrc.local", ".;")
if filereadable(local_vimrc)
  exec "source "local_vimrc
endif
function! Tab4()
    set ts=4
    set sw=4
    set expandtab
endfunction
noremap <Leader>4 :call Tab4()<cr>
function! Tab8()
    set ts=8
    set sw=8
    set noexpandtab
endfunction
noremap <Leader>8 :call Tab8()<cr>

" file
set nu
set noswapfile
set nobackup
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

" Cursor
set cursorline
"set cursorcolumn
"hi CursorLine term=reverse cterm=NONE ctermbg=black ctermfg=NONE
"hi CursorColumn term=reverse cterm=NONE ctermbg=black ctermfg=NONE
set scrolloff=3


" move
noremap <C-j> <C-e>
noremap <C-k> <C-y>

" Tag list settings
map <F4> :Tlist<CR>
nnoremap <Leader>tl :Tlist<CR>
let Tlist_Exit_OnlyWindow = 1
let Tlist_Auto_Open = 1
let Tlist_Show_One_File=1
let Tlist_Sort_Type = 'name'

" It's useful to show the buffer number in the status line.
set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
map <F2> :mksession! ~/.vim_session <cr> " Quick write session with F2
map <F3> :source ~/.vim_session <cr>     " And load session with F3


" copy paste
vmap <C-y>  :w! ~/.vimbuf<CR>
nmap <C-y>  :. w! ~/.vimbuf<CR>
nmap <C-p>  :r ~/.vimbuf<CR>

gitconfig

[user]
	name = imtank
	email = imtank@gmail.com
[diff]
	tool = vimdiff
[difftool]
	prompt = false
[alias]
	c = checkout
	b = branch
	d = difftool
	l = log --date=short --pretty=format:'[%h %ad %an] %s'
	s = status -uno
	f = show --name-only
	u = rm --cached

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值