Shell配置(基于cygwin和poderosa)

前面两篇文章已经分别介绍了安装cygwin和安装配置poderosa,基本上这个虚拟的linux环境就可以工作了,但是使用起来还不那么顺手,还有一些习惯的shell环境需要配置一下,主要是home目录~/下的.bashrc, .inputrc, .vimrc这三个文件。

由于cygwin的公共bash配置文件是/etc/bash.bashrc, 我们可以将一些配置放在这个文件中。这里就不详细讲解每项配置的含义,一般在#注释中有讲解,或者参考网上的文章。

1、bash配置:

/etc/bash.bashrc

# base-files version 3.7-1


# WARNING

#

# IF THIS bash IS MODIFIED IT WILL NOT BE UPDATED BY THE CYGWIN

# SETUP PROGRAM.  IT BECOMES YOUR RESPONSIBILITY.

#

# The latest version as installed by the Cygwin Setup program can

# always be found at /etc/defaults/etc/bash.bashrc

 

# System-wide .bashrc file

if [[ $- != *i* ]] ; then
    # Shell is non-interactive.  Be done now!
    return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Enable history appending instead of overwriting.  #139609
shopt -s histappend

# Change the window title of X terminals
case ${TERM} in
    xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix)
        PROMPT_COMMAND='echo -ne "/033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}/007"'
        ;;
    screen)
        PROMPT_COMMAND='echo -ne "/033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}/033//"'
        ;;
esac

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] /
    && type -P dircolors >/dev/null /
    && match_lhs=$(dircolors --print-database)
[[ $'/n'${match_lhs} == *$'/n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
    # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
    if type -P dircolors >/dev/null ; then
        if [[ -f ~/.dir_colors ]] ; then
            eval $(dircolors -b ~/.dir_colors)
        elif [[ -f /etc/DIR_COLORS ]] ; then
            eval $(dircolors -b /etc/DIR_COLORS)
        fi
    fi

    if [[ ${EUID} == 0 ]] ; then
        PS1='/[/033[01;31m/]/h/[/033[01;34m/] /W /$/[/033[00m/] '
    else
        PS1='/[/033[01;32m/]/u@/h/[/033[01;34m/] /w /$/[/033[00m/] '
    fi

    alias ls='ls --color=auto'
    alias grep='grep --colour=auto'
else
    if [[ ${EUID} == 0 ]] ; then
        # show root@ when we don't have colors
        PS1='/u@/h /W /$ '
    else
        PS1='/u@/h /w /$ '
    fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs
alias ll='ls -l --color=tty'
export OOO_FORCE_DESKTOP=gnome
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

~/.bashrc

# base-files version 3.7-1

# To pick up the latest recommended .bashrc content,
# look in /etc/defaults/etc/skel/.bashrc

# Modifying /etc/skel/.bashrc directly will prevent
# setup from updating it.

# The copy in your home directory (~/.bashrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benificial to all, please feel free to send
# a patch to the cygwin mailing list.

# User dependent .bashrc file
# Shell Options
# #############

# See man bash for more options...

# Don't wait for job termination notification
# set -o notify

# Don't use ^D to exit
# set -o ignoreeof

# Use case-insensitive filename globbing
# shopt -s nocaseglob

# Make bash append rather than overwrite the history on disk
# shopt -s histappend                                                                     

# When changing directory small typos can be ignored by bash                              
# for example, cd /vr/lgo/apaache would find /var/log/apache                              
# shopt -s cdspell                                                                        

# Completion options                                                                      
# ##################                                                                      

# These completion tuning parameters change the default behavior of bash_completion:      

# Define to access remotely checked-out files over passwordless ssh for CVS               
# COMP_CVS_REMOTE=1                                                                       

# Define to avoid stripping description in --option=description of './configure --help'   
# COMP_CONFIGURE_HINTS=1                                                                  

# Define to avoid flattening internal contents of tar files                               
# COMP_TAR_INTERNAL_PATHS=1                                                               

# If this shell is interactive, turn on programmable completion enhancements.             
# Any completions you add in ~/.bash_completion are sourced last.                         
# case $- in                                                                              
#   *i*) [[ -f /etc/bash_completion ]] && . /etc/bash_completion ;;                       
# esac                                                                                    
PS1='/[/033[01;32m/]/u@/h/[/033[00m/]:/[/033[01;36m/]/w/[/033[00m/]/$ '                   
LS_COLORS='di=36:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'                

# History Options                                                                         
# ###############

# Don't put duplicate lines in the history.                                               
# export HISTCONTROL="ignoredups"                                                         

# Ignore some controlling instructions                                                    
# export HISTIGNORE="[   ]*:&:bg:fg:exit"                                                 

# Whenever displaying the prompt, write the previous line to disk                         
# export PROMPT_COMMAND="history -a"                                                      
export LESSCHARSET="latin1"                                                               
export LC_ALL="zh_CN.UTF-8"                                                               
export LC_CTYPE="zh_CN.UTF-8"                                                             
export LANG="zh_CN.UTF-8"                                                                 
export OUTPUT_CHARSET="UTF-8"                                                             

# Aliases                                                                                 
# #######                                                                                 

# Some example alias instructions                                                         
# If these are enabled they will be used instead of any instructions                      
# they may mask.  For example, alias rm='rm -i' will mask the rm                          
# application.  To override the alias instruction use a / before, ie                      
# /rm will call the real rm not the alias.                                                

# Interactive operation...                                                                
# alias rm='rm -i'                                                                        
# alias cp='cp -i'                                                                        
# alias mv='mv -i'                                                                        

# Default to human readable figures                                                       
# alias df='df -h'                                                                        
# alias du='du -h'

# Misc :)                                                                                 
alias less='less -r'                          # raw control characters                    
# alias whence='type -a'                        # where, of a sort                        
alias grep='grep --color'                     # show differences in colour                

# Some shortcuts for different directory listings                                         
alias ls='ls -hF --color=tty --show-control-chars'                 # classify files in

colour                           
alias dir='ls --color=auto --format=vertical'                                             
# alias vdir='ls --color=auto --format=long'                                              
alias ll='ls -l'                              # long list                                 
alias la='ls -A'                              # all but . and ..                          
alias l='ls -CF'                              #                                           

2、中文输入配置:

~/.inputrc

set meta-flag on
set convert-meta off
set input-meta on
set output-meta on
set editing-mode vi
set completion-ignore-case on
3、vim配置

~/.vimrc

运行命令 cp /usr/share/vim/vim72/vimrc_example.vim ~/.vimrc

直接使用cygwin提供的配置文件,这里就不详细设置了。上面路径中vim72可能根据具体安装的版本会有所不同。

 

至此,windows上的Linux已经初具规模了。

 

你可能感兴趣的:(shell,command,user,bash,Parameters,colors)