sh Bash | ubuntu的自定义配置脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Bash | ubuntu的自定义配置脚本相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# ---------------------------------------
#             Local variables
# ---------------------------------------
name="<Your name>"
email="<Your email>"
dev_directory=~/Dev
work_directory=$dev_directory/Repos
bash_profile=~/.bashrc
ruby_version="2.2.4"
postgres_version="9.5"
current_directory=`pwd`

# ---------------------------------------
#           Apt-get packages
# ---------------------------------------
sudo add-apt-repository -y ppa:webupd8team/atom
sudo apt-get update
sudo apt-get -y install libpq-dev nginx libsqlite3-dev \
  build-essential cmake postgresql-$postgres_version \
  xsel curl terminator software-properties-common at
  
# ---------------------------------------
#           Install tmate
# ---------------------------------------
sudo add-apt-repository -y ppa:tmate.io/archive
sudo apt-get update
sudo apt-get install tmate
git clone git://github.com/nviennot/tmux-config.git ~/.tmux
cd ~/.tmux
make install
cd $current_directory
  
# ---------------------------------------
#          Install wikipedia cli
# ---------------------------------------
sudo apt-get -y install php-cli php-curl php-xml elinks
wget https://raw.githubusercontent.com/mevdschee/wped/master/wped.php -O wped
chmod 755 wped
sudo mv wped /usr/bin/wped
sudo ln -s /usr/bin/wped /usr/bin/wiki

# ---------------------------------------
#          Install radio
# ---------------------------------------
sudo apt-get install -y radiotray python-xdg

bookmarks='
<bookmarks>
  <group name="root">
    <group name="Pop / Rock">
      <bookmark name="RockFM Spain" url="http://rockfm.cope.stream.flumotion.com/cope/rockfm.mp3.m3u"/>
      <bookmark name="WZXR" url="http://16083.live.streamtheworld.com/WZXRFM_SC"/>
    </group>
    <group name="Games">
      <bookmark name="RPG Gamers" url="http://stream.rpgamers.net:8000/rpgn"/>
      <bookmark name="Rainwave" url="https://rainwave.cc/tune_in/5.mp3.m3u"/>
      <bookmark name="Otaku Music Radio" url="https://www.otakumusicradio.com/files/otakumusicradio.m3u"/>
    </group>
  </group>
</bookmarks>
'

mkdir -p ~/.local/share/radiotray
echo $bookmarks > ~/.local/share/radiotray/bookmarks.xml

# ---------------------------------------
#          Git configuration
# ---------------------------------------
sudo apt-get install -y git gitk meld tig

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.p push
git config --global alias.a add
git config --global alias.rb rebase
git config --global user.email $email
git config --global user.name $name
git config --global merge.tool meld
git config --global mergetool.meld.cmd 'exec meld $LOCAL $MERGED $REMOTE'
git config --global push.default current
git config --global pager.log "diff-highlight | less"
git config --global pager.show "diff-highlight | less"
git config --global pager.diff "diff-highlight | less"
git config --global tig.diff-highlight "true"

wget https://raw.githubusercontent.com/git/git/v2.3.5/contrib/diff-highlight/diff-highlight
sudo chmod +x diff-highlight
sudo mv diff-highlight /usr/local/bin/

# ---------------------------------------
#                Node.js 8
# ---------------------------------------
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
apt-get install nodejs
npm install -g npm

# ---------------------------------------
#              Ruby (rbenv)
# ---------------------------------------
sudo apt-get -y install autoconf bison libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $bash_profile
echo 'export PATH=".git/safe/../../bin:$PATH"' >> $bash_profile
echo 'eval "$(rbenv init -)"' >> $bash_profile
source $bash_profile
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install $ruby_version
rbenv global $ruby_version
gem install bundle git-up
cd ~/
git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
git clone https://github.com/maljub01/rbenv-bundle-exec.git ~/.rbenv/plugins/rbenv-bundle-exec

echo irb >> ~/.no_bundle_exec
echo pry >> ~/.no_bundle_exec

# ---------------------------------------
#                 Rust
# ---------------------------------------
curl https://sh.rustup.rs -sSf | sh

# ---------------------------------------
#                Python
# ---------------------------------------
sudo apt-get install -y python3-dev python3-pip
sudo -H pip3 install thefuck
eval $(thefuck --alias) >> $bash_profile
sudo apt-get install -y python-pygments


# ---------------------------------------
#                 Haxe
# ---------------------------------------
sudo add-apt-repository ppa:haxe/releases -y
sudo apt-get update
sudo apt-get install haxe -y
mkdir $dev_directory/haxelib && haxelib setup $dev_directory/haxelib

# ---------------------------------------
#                 IDES
# ---------------------------------------
curl -sL https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
sudo apt-get update
sudo apt-get install -y atom

# ---------------------------------------
#                 Docker
# ---------------------------------------
source <(curl -s https://get.docker.com/)

# ---------------------------------------
#            Aliases and bash
# ---------------------------------------

cat >> $bash_profile <<- EOM

# Git colors for prompt (https://gist.github.com/Ranjithkumar/9526665)
function color_my_prompt {
    local __user_and_host="\[\033[01;32m\]\u@\h"
    local __cur_location="\[\033[01;34m\]\w"
    local __git_branch_color="\[\033[31m\]"
    #local __git_branch="\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`"
    local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E  s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
    local __prompt_tail="\[\033[35m\]$"
    local __last_color="\[\033[00m\]"
    export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
color_my_prompt

# Alias commands
alias a='echo Opening Atom editor on `pwd` && atom .'
alias g='git'
alias gk='gitk --all &'
alias be='bundle exec'
alias bi='bundle install'
alias b='bundle'
alias work='cd $work_directory'
alias ccat='pygmentize -g'
alias clipboard='xsel -ib'
alias wiki='wped -l es'
alias fucking='sudo'
alias beep='paplay /usr/share/sounds/ubuntu/ringtones/Bliss.ogg &'
EOM

以上是关于sh Bash | ubuntu的自定义配置脚本的主要内容,如果未能解决你的问题,请参考以下文章

sh 用于Ubuntu 14.0.4的LEMP堆栈安装Bash脚本

sh 用于Ubuntu 14.0.4的LEMP堆栈安装Bash脚本

sh 一个bash脚本,用于在Ubuntu上设置OneDrive与GNOME的集成。

bash与sh的问题

如何使用docker构建我自己的自定义Ubuntu ISO

sh Bash脚本安装Apache,MySQL和PHP以及PHPMyAdmin和一些调整。对于Debian和Ubuntu。要运行,请将脚本复制到se