0

我创建了自己的 dotfile 存储库,这是 install.sh 文件,它加载所有内容:

#!/bin/bash
clear
echo "Installation started"

SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`

cd $SCRIPTPATH && git submodule update -i

echo "Install some useful program"
sudo apt-get install tmux
sudo apt-get install xclip

echo "Replace old ~/.git-prompt.sh"
rm ~/.git-prompt.sh
ln -s $SCRIPTPATH/.git-prompt.sh ~/.git-prompt.sh

echo "Replace old ~/.tmux.conf"
rm ~/.tmux.conf
ln -s $SCRIPTPATH/.tmux.conf ~/.tmux.conf

echo "Replace old ~/.gitconfig"
rm ~/.gitconfig
ln -s $SCRIPTPATH/.gitconfig ~/.gitconfig

echo "Replace old ~/.bashrc file"
rm ~/.bashrc
ln -s $SCRIPTPATH/.bashrc ~/.bashrc

echo "Replace old ~/.profile file"
rm ~/.profile
ln -s $SCRIPTPATH/.profile ~/.profile

echo "Replace old ~/.vim folder"
rm -rf ~/.vim
ln -s $SCRIPTPATH/.vim ~/.vim

echo "Replace old ~/.vimrc file"
rm ~/.vimrc
ln -s $SCRIPTPATH/.vimrc ~/.vimrc

echo "done!"

最后,这是我的 .bashrc 文件的一部分:

# Prompt colors
Red="\[\e[0;31m\]"
Darkgreen="\[\e[0;32m\]"
Green="\[\e[1;32m\]"
White="\[\e[0;0m\]"
Yellow="\[\e[1;33m\]"

# Show git branch name
source ~/.git-prompt.sh

# Custom prompt
export PS1="${Red}\u ${Yellow}\A ${Darkgreen}\w${Green}$(__git_ps1) \$ ${White}"

# Wondering in folders
alias ..="cd .."
alias ...=".. && .."
alias ....=".. && .. && .."

# Listing 
alias ll="ls -l"
alias la="ls -la"

# Fix git configurations
git config --global core.editor /usr/bin/vim

# Colors
alias grep="grep --color"
alias ls="ls --color"

我在 Ubuntu 上。当我点击终端的图标时,终端就打开了。但.bashrc永远不会在这一刻加载。.bashrc在以下情况下加载:

  • 我手动运行“source ~/.bashrc”
  • 我用 CTRL+SHIFT+N 打开新终端
  • 我运行 tmux

为什么ubuntu第一次不加载.bashrc?一些额外的信息可能是:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty
4

0 回答 0