【自用】常用配置记录

Python

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Go

export GOPROXY="https://goproxy.cn/"
export GOROOT=""

Nodejs

换源

npm set registry http://registry.npmmirror.com

修改npm全局安装位置

export NPM_HOME=""
export PNPM_HOME=""

Java

环境变量

export JAVA_HOME=""

Maven换源

<mirror>
    <id>aliyunmaven</id>
    <mirrorOf>*</mirrorOf>
    <name>阿里云公共仓库</name>
    <url>https://maven.aliyun.com/repository/public</url>
</mirror>

Docker

sudo vim /etc/docker/daemon.json

{
    "registry-mirrors": [
        "https://registry.hub.docker.com",
        "http://hub-mirror.c.163.com",
        "https://registry.docker-cn.com"
    ]
}

sudo systemctl restart docker

Git

配置

git config --global user.name "Brevin"
git config --global user.email "brevin@foxmail.com"
git config --global core.editor "vim"
git config --global init.defaultBranch "main"

源码

https://mirrors.edge.kernel.org/pub/software/scm/git/

终端补全,显示git分支

参考 “Linux初始化脚本”中的git部分与bash_profile部分

各Linux发行版更改软件源

fedora

终端执行

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

alpine

终端执行

sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

ubuntu

按网页内容操作

# x86
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
# arm
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/

Jetbrains Mono字体

https://www.jetbrains.com/lp/mono/

Linux初始化脚本

适用与aarch64架构的openEuler操作系统,其他系统没有测试过。
github镜像如果失效,需要修改成可用镜像

#! /usr/bin/env bash

if [ $(id -u ${USER} -r) -ne 0 ];then
  echo "Please execute with root"
  exit 0
fi

# -------------------- 基础环境配置 --------------------
# 下面需要用到的命令可能没有
dnf install -y passwd iproute tar xz wget findutils python3 python3-pip
# 安装运行环境和常用软件
dnf install -y gcc g++ make cmake go git vim tmux


github_mirror='kgithub.com'
raw_github_mirror='raw.kgithub.com'

git_name='Brevin'
git_email='brevin@foxmail.com'

root_password='brevin'

pip_mirror='https://pypi.tuna.tsinghua.edu.cn/simple'

arch=$(arch)


# -------------------- 开始 --------------------
passwd --stdin root <<< "${root_password}"

# 更新除内核外的所有软件
dnf list --upgrades | tail -n +3 | awk '{print $1}' | grep -v 'kernel' \
| xargs -n 10 dnf upgrade -y


# -------------------- Python --------------------
/usr/bin/pip config set global.index-url "${pip_mirror}"

# -------------------- ShellCheck --------------------
wget -O shellcheck.tar.xz "https://${github_mirror}/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.${arch}.tar.xz" \
&& tar -Jxf shellcheck.tar.xz \
&& mv shellcheck-v0.9.0/shellcheck /usr/local/bin/ \
&& rm -rf shellcheck.tar.xz shellcheck-v0.9.0


# -------------------- Git --------------------
git config --global user.name "${git_name}"
git config --global user.email "${git_email}"
git config --global core.editor "vim"
git config --global init.defaultBranch "main"

wget -O /etc/bash_completion.d/git-completion.bash \
https://${raw_github_mirror}/git/git/master/contrib/completion/git-completion.bash
wget -O /etc/bash_completion.d/git-prompt.sh \
https://${raw_github_mirror}/git/git/master/contrib/completion/git-prompt.sh

# -------------------- Vim --------------------
git clone --depth=1 https://${github_mirror}/amix/vimrc.git ~/.vim_runtime && \
sh ~/.vim_runtime/install_awesome_vimrc.sh && \
echo "set nu" >> ~/.vim_runtime/my_configs.vim && \
echo "set visualbell" >> ~/.vim_runtime/my_configs.vim

# -------------------- inputrc --------------------
echo "set enable-bracketed-paste off" >> /etc/inputrc
echo "set bell-style none" >> /etc/inputrc

# -------------------- bash_profile --------------------
{
  printf 'PS1_GREEN="%s"\n' "\\[\\e[0;32m\\]"
  printf 'PS1_BLUE="%s"\n' "\\[\\e[0;34m\\]"
  printf 'GIT_COLOR="%s"\n' "\\[\\e[0;35m\\]"
  printf 'PS1_RESET="%s"\n' "\\[\\e[0m\\]"

  if [ -f /etc/bash_completion.d/git-prompt.sh ]; then
    printf '. /etc/bash_completion.d/git-completion.bash\n'
    printf '. /etc/bash_completion.d/git-prompt.sh\n'
    printf 'export GIT_PS1_SHOWDIRTYSTATE=1\n'
    printf 'export GIT_PS1_SHOWSTASHSTATE=1\n'
    printf 'export GIT_PS1_SHOWUNTRACKEDFILES=1\n'
    printf 'export GIT_PS1_SHOWUPSTREAM="auto"\n'
    echo "export PS1='\\[\\e[0;32m\\]\\u@\\h\\[\\e[0m\\]:\\[\\e[0;34m\\]\\w\\[\\e[0;35m\\]\$(__git_ps1 \" (%s)\") \\[\\e[0m\\]'"
  else
    printf 'export PS1="${PS1_GREEN}\\u@\\h${PS1_RESET}:${PS1_BLUE}\\w ${PS1_RESET}"\n'
  fi

  printf '\n'
  printf 'unset PS1_GREEN\n'
  printf 'unset PS1_BLUE\n'
  printf 'unset GIT_COLOR\n'
  printf 'unset PS1_RESET\n'
  printf 'export EDITOR="/usr/bin/vim"\n'
} >> /etc/profile.d/custom.sh


dnf autoremove -y
reboot
posted @   BrevinZhang  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示