目录

Ubuntu开发环境搭建

环境:Ubuntu 16.04.5 LTS。

更新

1
2
3
sudo apt update
sudo apt upgrade
sudo apt autoremove

安装底层软件

基本软件:

1
sudo apt install git zsh autojump vim htop tree python3-pip

pyenv 编译 Python 的依赖

1
2
3
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl

docker 的依赖

1
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

安装常用 cli 工具

docker

卸载官方源中安装的 docker:

1
sudo apt purge docker docker-engine docker.io containerd runc

添加 docker 维护的源:

1
2
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

安装 docker-ce:

1
2
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

将当前用户添加到 docker 组中:

1
2
sudo groupadd docker
sudo usermod -aG docker $USER

oh-my-zsh

1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

配置,编辑 ~/.zshrc 文件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 以下是修改已经存在的配置
ZSH_THEME="agnoster"
plugins=(git autojump docker adb pyenv python)

# 新增配置
DEFAULT_USER="chi"

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# pyenv
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"

# pipenv
export PIPENV_VENV_IN_PROJECT=true

注意:注销后重新登录才会开始自动启用 zsh。

pyenv

1
curl https://pyenv.run | zash

Python CLI 工具

由于 Linuxbrew 在 Ubuntu 上遇到了诸多问题,因此这些 Python 语言编写的工具将不再使用 Linuxbrew 安装,而是使用 pip3 安装到全局 Python3 上。

1
pip install tldr httpie pipenv you-get mitmproxy

安装桌面软件和字体

桌面软件

下载安装包或添加 apt 源安装:

从 Ubuntu 软件中心安装

  • Postman
  • Bitwarden
  • calibre

字体

配置

终端

Gnome Terminator 的配置文件路径为 /home/chi/.config/terminator/config,内容为

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[global_config]
  always_split_with_profile = True
  broadcast_default = off
  inactive_color_offset = 1.0
  title_font = JetBrains Mono 12
  title_hide_sizetext = True
  title_transmit_bg_color = "#68aa13"
  title_use_system_font = False
[keybindings]
  next_tab = <Primary>Tab
  paste = <Primary><Shift>v
  prev_tab = <Primary><Shift>Tab
[layouts]
  [[default]]
    [[[child1]]]
      parent = window0
      type = Terminal
    [[[window0]]]
      parent = ""
      type = Window
[plugins]
[profiles]
  [[default]]
    background_darkness = 0.76
    background_image = None
    background_type = transparent
    copy_on_selection = True
    font = JetBrains Mono 12
    foreground_color = "#dcdcdc"
    palette = "#000000:#cc0000:#4e9a06:#c4a000:#3465a4:#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:#729fcf:#ad7fa8:#34e2e2:#eeeeec"
    scrollback_lines = 8192
    use_system_font = False

设置 Gnome Terminitor 为默认终端

1
2
sudo update-alternatives --config x-terminal-emulator
gsettings set org.gnome.desktop.default-applications.terminal exec 'terminator'

git

1
touch ~/.gitconfig
1
2
3
4
5
6
[user]
    name = foo
    email = [email protected]
[core]
    quotepath = false
    editor = vim

quotepath = false 可以使 shell 中的 git 能够显示中文路径和文件名。

vim

1
touch ~/.vimrc
1
2
syntax on
set number

改善易用性

安装主题、图标包和鼠标指针

安装 Flatabulous 主题 和 ultra-flat-icons 图标包

1
2
3
4
sudo add-apt-repository ppa:noobslab/themes
sudo add-apt-repository ppa:noobslab/icons
sudo apt update
sudo apt install flatabulous-theme ultra-flat-icons

下载鼠标指针 Bibata,解压后:

1
sudo mv Bibata_* /usr/share/icons

安装 unity-tweak-tool 并美化

安装 unity-tweak-tool,unity-tweak-tool 是一个 Unity 桌面的配置工具。

1
sudo apt install unity-tweak-tool

打开 unity-tweak-tool 工具,打开 Appearance 分类下的 Theme,设置:

  • 在 Theme 选项卡,选择使用 Flatabulous 主题;
  • 在 Icon 选项卡,选择使用 Ultra-flat 图标包;
  • 在 Cursor 选项卡,选择使用 Bibata 系列鼠标指针;
  • 在 Fonts 选项卡,将默认字体设置为思源黑体,默认等宽字体设置为 JetBrains Mono,文字缩放比例改为 1.25;

中文输入

  1. 进入 [System Settings] - [Language Support],在 Language 选项卡中选择 [Install / Remove Languages…],添加 Chinese(simplified) 语言,将汉语拖动到列表第一位置。并选择 [Keyboard input method system] 为 fcitx,重启电脑;
  2. 进入 [System Settings] - [Text Entry],点击 [+] 添加输入源,以“pinyin”为关键字搜索,添加 Google Pinyin(Fcitx) 输入源。

不要尝试卸载 ibus,否则会造成 unity 桌面菜单空白。

显卡驱动

进入 [System Settings] - [Software & Updates],在 [Additional Drivers] 选项卡中,选择已经经过测试的 NVIDIA 闭源驱动。

系统增强

安装 indicator-sysmonitor,在状态栏上展示系统信息。

安装

1
2
3
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
sudo apt update
sudo apt install indicator-sysmonitor

搜索 system monitor indicator 打开软件。勾选开机自启动,我的配置为:

1
| cpu {cpu} {cputemp} | mem {mem} | {net} |

改键

在 Ubuntu 中 ALT 键用于显示 HUD 界面,打游戏很不方便。

打开 [System Settings] - [Keyboard] - [Shortcuts] - [Launchers],修改 [Key to show the HUD] 为右 ALT 键。

参考链接