ubuntu环境配置

之前用的ubuntu虚拟机突然崩溃了,只好重新安装配置下ubuntu环境。顺手记录一下。

apt-get 代理

sudo vi /etc/apt/apt.conf.d/01proxy(没有则新增)
Acquire::http { Proxy "http://xxx-proxy.com:8080"; };

禁止休眠

System Settings -> Brightness
Turn screen off when inactive for : Never


ubuntu环境配置_第1张图片
image
ubuntu环境配置_第2张图片
image

FireFox 代理设置

Edit -> Preferences -> Advanced -> Network -> Connection -> Settings...

更新FireFox

先卸载原来的 firefox sudo apt-get remove firefox
http://firefox.com.cn/download/
然后将下载的Firefox-latest.tar.bz2解压到/usr/lib目录下,在 /usr/bin 建立软链接:

cd /usr/lib/
sudo tar -xvf /home/zyh/software/Firefox-latest.tar.bz2
cd /usr/bin/
sudo ln -s /usr/lib/firefox/firefox

给Firefox创建一个快捷方式

cd /usr/share/applications
vi firefox.desktop
[Desktop Entry]
Name=Firefox
Comment=火狐浏览器
GenericName=火狐浏览器-中国版
Exec=/usr/lib/firefox/firefox
Icon=/usr/lib/firefox/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
Categories=Application;Network;

oh-my-zsh && 插件配置

https://github.com/robbyrussell/oh-my-zsh

sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# 安装 zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 安装 zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
vi ~/.zsh
# pulgin 添加
plugins=(git
    z # jump to workspace
    python pip
    cargo
    zsh-autosuggestions zsh-syntax-highlighting
    vi-mode # ESC+v to edit current commandline
    colored-man-pages # colorful man pages
    history # hanful alias for history && search
)
# 常用的 alias
alias zz='z -c'
alias ll='ls -lhtF --color=auto'
alias utop='top -u $(whoami)'
alias tailf='tail -f'
# 不同 shell 之间不共享操作的历史命令
unsetopt share_history
# 防止在使用byobu时自动修改title
DISABLE_AUTO_TITLE="true"
image

修改 zsh promot

vi ~/.oh-my-zsh/themes/jayson.zsh-theme

# Based on gnzh theme

setopt prompt_subst

() {

local PR_USER PR_USER_OP PR_PROMPT PR_HOST

# Check the UID
if [[ $UID -ne 0 ]]; then # normal user
  PR_USER='%F{green}%n%f'
  PR_USER_OP='%F{green}%#%f'
  PR_PROMPT='%f> %f'
else # root
  PR_USER='%F{red}%n%f'
  PR_USER_OP='%F{red}%#%f'
  PR_PROMPT='%F{red}> %f'
fi

# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT"  ||  -n "$SSH2_CLIENT" ]]; then
  PR_HOST='%F{red}%M%f' # SSH
else
  PR_HOST='%F{green}%M%f' # no SSH
fi


local return_code="%(?..%F{red}%? ↵%f)"

local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%d%f%b"
local rvm_ruby=''
if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
  rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f'
elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
  rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f'
elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
  rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f'
fi
local git_branch='$(git_prompt_info)'

PROMPT="${user_host} ${current_dir}${rvm_ruby} ${git_branch}
$PR_PROMPT "
RPROMPT="${return_code}"

eval my_gray='$FG[246]'
RPS1='$my_gray%D{%Y-%m-%d %H:%M:%S}%{$reset_color%}%'

ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%f"

}

vimrc 配置

sudo apt-get install vim
vi ~/.vimrc
"""""" 文件编码
set fileencodings=utf-8,gbk,gb2312
set termencoding=utf-8
set encoding=utf-8
"""""" 缩进相关
set ts=4    " tabstop 设置tab为4个空格
set sw=4    " shiftwidth 每层缩进4个空格
set expandtab   " 输入的tab自动展开为空格. 设置后, 输入TAB, 需要Ctrl-V
set softtabstop=4
"set smarttab
set ai!
set cindent
set smartindent
set sm      " 输入后括号时, 光标跳回对应的前括号显示匹配情况
"""""" 显示相关
set nu      " 显示行号
set ru      " 显示屏幕右下角行号, 列号信息
set showtabline=2
set ic      " 查找时不考虑大小写
set incsearch   " 增量搜索
set hlsearch    " 搜索时高亮结果
set cursorline  " 显示当前行
set showmode  " 显示当前操作模式
"Sets how many lines of history VIM har to remember
set history=400
set nocompatible    " 不使用旧的VI兼容模式
"set mouse=a     " 鼠标可用
set mouse=v    " 关闭鼠标模式
set autoread    " 文件被修改时, 重新加载
" 记录上次打开文件时编辑的位置
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"解决粘贴时的自动缩进带来的自动注释困扰 (和autoindent互斥, 要粘贴代码时手动输入 :set paste)
"set paste
" 设置vim打开文件之后,页脚的状态栏,包括文件编码,文件类型,光标当前列,当前行,以及总行数等信息
set statusline=%2*%n%m%r%h%w%*\ %f\ %1*[FORMAT=%2*%{&ff}:%{&fenc!=''?&fenc:&enc}%1*]\ [Type=%2*%Y%1*]\ [Column=%2*%v%1*]\ [Line=%2*%l%1*/%3*%L(%p%%)%1*]
set laststatus=2
" Auto add head info
" .py file into add header
function! HeaderPython()
    call setline(1, "#!/usr/bin/env  python")
    call append(1, "#encoding=utf-8")
    call append(2, "from __future__ import print_function")
    call append(3, "import sys")
    call append(4, "")
    call append(5, "__doc__= ''' '''")
    call append(5, "__author__ = ''")
    call append(6, "")
    normal G
    normal o
endf
autocmd bufnewfile *.py call HeaderPython()

Sougou 输入法

参见:
https://blog.csdn.net/ljheee/article/details/52966456

安装常用的编译环境

sudo apt-get install g++ autogen libtool shtool automake autoconf

生成公钥, 供git使用

ssh-keygen
cat ~/.ssh/id_rsa.pub # 把公钥填写到git管理系统上

Chrome 常用插件

  • Vimium -- vim的键盘模式控制浏览器
  • Postman -- RESTful 调试器
  • EditThisCookie -- Cookie 编辑器
  • Octotree -- GitHub 代码目录树
  • Tampermonkey -- 脚本管理器
    • 浏览目录树

一些命令行工具

暂时只记录MacOS下的配置命令

# ls && tree 的更好替代品
brew install exa
# .zshrc里面配置别名
alias ll='exa -l --color=always -h -s modified -r'

# grep/ag 的更好替代品
brew install ripgrep

# top 
brew install htop
brew install glances


# sz/rz 服务器上传下载文件
brew install lrzsz

# 屏幕/会话管理器
brew install tmux byobu

# diff
brew install icdiff
# 在 ~/.zshrc 中添加
alias gd='git icdiff'

# du
brew install ncdu

# man 
brew install tldr

你可能感兴趣的:(ubuntu环境配置)