热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

国产操作系统安装之联网、gcc、rust、exa、zsh5.8、OhMyZsh、powerlevel10k、git、高亮插件、补全命令插

中标麒麟版本:kylinos-server-v7.0-x86_64.iso3.99GB主机平台:intelx86一、联网1、编辑ifcfg-eth0文

中标麒麟版本:kylinos-server-v7.0-x86_64.iso 3.99 GB
主机平台:intel x86



一、联网

1、编辑 ifcfg-eth0 文件,vim 最小化安装时没有被安装,需要自行安装不描述。


vim /etc/sysconfig/network-scripts/ifcfg-eth0


2、修改如下内容

BOOTPROTO="static" #dhcp改为static
ONBOOT="yes" #开机启用本配置
IPADDR=10.1.40.102 #静态IP
GATEWAY=10.1.40.1 #默认网关
NETMASK=255.255.255.0 #子网掩码
DNS1=192.168.7.1 #DNS 配置

如果是虚拟机安装,比如pd安装

BOOTPROTO="static" #dhcp改为static
ONBOOT="yes" #开机启用本配置
IPADDR=10.211.55.72 #静态IP
GATEWAY=10.211.55.1 #默认网关
NETMASK=255.255.255.0 #子网掩码
DNS1=10.211.55.1 #DNS 配置

3、修改后效果(需要修改的地方有注释)


cat /etc/sysconfig/network-scripts/ifcfg-eth0


HWADDR="00:15:5D:07:F1:02"
TYPE="Ethernet"
BOOTPROTO="static" #dhcp改为static
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
UUID="bb3a302d-dc46-461a-881e-d46cafd0eb71"
ONBOOT="yes" #开机启用本配置
IPADDR=10.1.40.102 #静态IP
GATEWAY=10.1.40.1 #默认网关
NETMASK=255.255.255.0 #子网掩码
DNS1=192.168.7.1 #DNS 配置

4、重启下网络服务


service network restart


5、ping


ping qq.com


[root@localhost ~]# ping qq.com
PING qq.com (61.129.7.47) 56(84) bytes of data.
64 bytes from 61.129.7.47 (61.129.7.47): icmp_seq=1 ttl=50 time=30.5 ms
64 bytes from 61.129.7.47 (61.129.7.47): icmp_seq=2 ttl=50 time=30.2 ms
64 bytes from 61.129.7.47 (61.129.7.47): icmp_seq=3 ttl=50 time=30.1 ms
64 bytes from 61.129.7.47 (61.129.7.47): icmp_seq=4 ttl=50 time=30.2 ms

6、联网后第一件事:update


yum update



二、exa

https://github.com/ogham/exa/
https://the.exa.website/

1、安装rust编译器


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


2、安装提示,重新打开shell

3、安装exa


cargo install exa


[root@localhost ~]# cargo install exaUpdating crates.io indexFetch [========> ] 39.40%

4、出错了

error: linker `cc` not found|= note: No such file or directory (os error 2)error: aborting due to previous errorerror: could not compile `log`To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: linker `cc` not found|= note: No such file or directory (os error 2)error: aborting due to previous errorerror: linker `cc` not found|= note: No such file or directory (os error 2)error: aborting due to previous errorerror: failed to compile `exa v0.10.1`, intermediate artifacts can be found at `/tmp/cargo-installpF3yZD`

意思是没有gcc呗,装


sudo yum -y install gcc


(⚠️:安装redis也可能用到gcc哦)

5、再来


cargo install exa


Updating crates.io index
warning: spurious network error (2 tries remaining): SSL error: syscall failure: Connection reset by peer; class=Os (2)
Installing exa v0.10.1
Compiling libc v0.2.98
Compiling pkg-config v0.3.19
Compiling matches v0.1.8
Compiling tinyvec_macros v0.1.0
Compiling log v0.4.14
Compiling unicode-width v0.1.8
Compiling cfg-if v1.0.0
Compiling bitflags v1.2.1
Compiling percent-encoding v2.1.0
Compiling byteorder v1.4.3
Compiling number_prefix v0.4.0
Compiling lazy_static v1.4.0
Compiling ansi_term v0.12.1
Compiling glob v0.3.0
Compiling scoped_threadpool v0.1.9
Compiling natord v1.0.9
Compiling tinyvec v1.2.0
Compiling unicode-bidi v0.3.5
Compiling pad v0.1.6
Compiling term_grid v0.1.7
Compiling form_urlencoded v1.0.1
Compiling unicode-normalization v0.1.19
Compiling jobserver v0.1.22
Compiling locale v0.2.2
Compiling users v0.11.0
Compiling num_cpus v1.13.0
Compiling term_size v0.3.2
Compiling cc v1.0.69
Compiling datetime v0.5.2
Compiling zoneinfo_compiled v0.5.1
Compiling idna v0.2.3
Compiling exa v0.10.1
Compiling libz-sys v1.1.3
Compiling libgit2-sys v0.12.21+1.1.0
Compiling url v2.2.2
Compiling git2 v0.13.20
Finished release [optimized] target(s) in 6m 48s
Installing /root/.cargo/bin/exa
Installed package `exa v0.10.1` (executable `exa`)

6、使用exa

[root@localhost ~]# exa -la
.rw------- 565 root 17 723:19 .bash_history
.rw-r--r--@ 18 root 29 122013 .bash_logout
.rw-r--r--@ 197 root 17 720:37 .bash_profile
.rw-r--r--@ 197 root 17 720:37 .bashrc
drwxr-xr-x - root 17 722:32 .cargo
.rw-r--r--@ 100 root 29 122013 .cshrc
drwxr----- - root 17 720:36 .pki
.rw-r--r-- 21 root 17 720:37 .profile
drwxr-xr-x - root 17 720:37 .rustup
.rw-r--r--@ 129 root 29 122013 .tcshrc
.rw-------@ 1.3k root 17 719:45 anaconda-ks.cfg
[root@localhost ~]#

三、安装zsh、git


yum install -y zsh git


[root@localhost ~]# git --version
git version 2.23.0
[root@localhost ~]#

sh -c “$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”


[root@localhost ~]# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Cloning Oh My Zsh...
正克隆到 '/root/.oh-my-zsh'...
remote: Enumerating objects: 1239, done.
remote: Counting objects: 100% (1239/1239), done.
remote: Compressing objects: 100% (1204/1204), done.
remote: Total 1239 (delta 20), reused 1099 (delta 15), pack-reused 0
接收对象中: 100% (1239/1239), 863.89 KiB | 315.00 KiB/s, 完成.
处理 delta 中: 100% (20/20), 完成.Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] y
Changing the shell...
Changing shell for root.
Shell changed.
Shell successfully changed to '/bin/zsh'.__ ______ / /_ ____ ___ __ __ ____ _____/ /_/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_//____/ ....is now installed!Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh➜ ~

好家伙,zsh装了个5.0.7,powerlevel10k至少需要5.1


四、安装zsh5.8、插件、powerlevel10k

前置安装:


yum -y install perl-ExtUtils-MakeMaker ncurses-devel autoconf


下载最新的zsh-5.8.tar.xz包,并上传到Linux系统中

yum -y install perl-ExtUtils-MakeMaker autoconf
yum -y install ncurses-devel
# 编译安装
cd zsh-5.8
./configure
make && make install
# 将zsh加入/etc/shells
vim /etc/shells # 添加:/usr/local/bin/zsh

安装插件,参考这篇Centos7源码安装最新的zsh并安装oh-my-zsh

在zsh中有一些好用的插件,这里介绍几个常用的,安装的插件都存放在 ~/.oh-my-zsh/custom/plugins下:

安装以下几个插件并添加到.zshrc文件中的plugins中后,在命令行中执行命令时,会有语法高亮,历史命令提示,和路径补全等

zsh-syntax-highlighting:语法高亮,命令正确执行时是绿色的,失败时是红色的


git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting


zsh-autosuggestions:输入命令时,会提供命令补全,路径补全等,按键盘 → 补全


git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions


zsh-history-substring-search:这个是记住执行过的命令的,使用上下键可以方便的再次执行指定的命令


git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search


安装完插件后,编辑.zshrc文件,把插件都添加到文件中去:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; thensource "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH# Path to your oh-my-zsh installation.
export ZSH="/root/.oh-my-zsh"# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="powerlevel10k/powerlevel10k"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"# Uncomment the following line to display red dots whilst waiting for completion.
# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(gitzsh-syntax-highlightingzsh-autosuggestionszsh-history-substring-search)source $ZSH/oh-my-zsh.sh# User configuration# export MANPATH="/usr/local/man:$MANPATH"# You may need to manually set your language environment
# export LANG=en_US.UTF-8# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi# Compilation flags
# export ARCHFLAGS="-arch x86_64"# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

0. 设置代理

具体教程看:终端设置http https SOCKS代理

这个代理好了,不用设置git代理。


1. 安装git

安装:

sudo apt-get install git

配置:

git config --global http.proxy "http://192.168.1.101:53327"

git config --global https.proxy "https://192.168.1.101:53327"

git config --global http.proxy "socks5://127.0.0.1:1080"

git config --global https.proxy "socks5://127.0.0.1:1080"

git config --global user.name suvancheng

git config --global user.email suvancheng@outlook.com

查看配置:

git config --list

2. 安装zsh

安装:

sudo apt-get install zsh

启动:

chsh -s /bin/zsh

查看是否启动:

echo $0

3. 安装Oh My Zsh

官网:https://github.com/ohmyzsh/ohmyzsh
安装:sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

huanghe% sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Cloning Oh My Zsh...
正克隆到 '/home/huanghe/.oh-my-zsh'...
remote: Enumerating objects: 1243, done.
remote: Counting objects: 100% (1243/1243), done.
remote: Compressing objects: 100% (1207/1207), done.
remote: Total 1243 (delta 20), reused 1100 (delta 15), pack-reused 0
接收对象中: 100% (1243/1243), 864.95 KiB | 7.00 KiB/s, 完成.
处理 delta 中: 100% (20/20), 完成.Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /home/huanghe/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.__ ______ / /_ ____ ___ __ __ ____ _____/ /_/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_//____/ ....is now installed!Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh➜ ~

4. 安装exa

zsh --versionzsh --version

sudo apt-get install exa

配置alias

sudo vim ./.zshrc

alias l="exa -l"
alias la="exa -la"

安装romkatv/powerlevel10k

确保zsh版本大于5.7:zsh --version
官网:https://github.com/romkatv/powerlevel10k

安装:

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

修改zshrc:Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc


安装插件

安装以下几个插件并添加到.zshrc文件中的plugins中后,在命令行中执行命令时,会有语法高亮,历史命令提示,和路径补全等

zsh-syntax-highlighting:语法高亮,命令正确执行时是绿色的,失败时是红色的

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-autosuggestions:输入命令时,会提供命令补全,路径补全等,按键盘 → 补全

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

zsh-history-substring-search:这个是记住执行过的命令的,使用上下键可以方便的再次执行指定的命令

git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search

安装完插件后,编辑.zshrc文件,把插件都添加到文件中去:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
。。。。
。省略 。
。。。。
# Add wisely, as too many plugins slow down shell startup.
plugins=(gitzsh-syntax-highlightingzsh-autosuggestionszsh-history-substring-search)source $ZSH/oh-my-zsh.sh
。。。。
。省略 。
。。。。
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

推荐阅读
  • Docker安全策略与管理
    本文探讨了Docker的安全挑战、核心安全特性及其管理策略,旨在帮助读者深入理解Docker安全机制,并提供实用的安全管理建议。 ... [详细]
  • 本文详细介绍了在Linux操作系统上安装和部署MySQL数据库的过程,包括必要的环境准备、安装步骤、配置优化及安全设置等内容。 ... [详细]
  • 构建个人多节点Linux环境(CodeSheep)
    本文介绍如何通过虚拟机搭建一个多节点的Linux环境,这对于学习、实验和项目部署都具有重要意义。文章详细讲解了网络IP设置、节点间通信等关键步骤。 ... [详细]
  • Ubuntu 14.04 系统安装后网卡名称修改方法
    本文介绍了在安装 Ubuntu 14.04 Server 版本后,如何将默认的网卡名称从非 eth 格式修改为传统的 eth 格式,并提供了详细的步骤和示例。 ... [详细]
  • 在CentOS 7中部署Nginx并配置SSL证书
    本文详细介绍了如何在CentOS 7操作系统上安装Nginx服务器,并配置SSL证书以增强网站的安全性。适合初学者和中级用户参考。 ... [详细]
  • 本文探讨了互联网服务提供商(ISP)如何可能篡改或插入用户请求的数据流,并提供了有效的技术手段来防止此类劫持行为,确保网络环境的安全与纯净。 ... [详细]
  • 本文基于Java官方文档进行了适当修改,旨在介绍如何实现一个能够同时处理多个客户端请求的服务端程序。在前文中,我们探讨了单客户端访问的服务端实现,而本篇将深入讲解多客户端环境下的服务端设计与实现。 ... [详细]
  • 本文详细介绍了如何使用C#实现不同类型的系统服务账户(如Windows服务、计划任务和IIS应用池)的密码重置方法。 ... [详细]
  • 1、编写一个Java程序在屏幕上输出“你好!”。programmenameHelloworld.javapublicclassHelloworld{publicst ... [详细]
  • 在中标麒麟操作系统上部署达梦数据库及导入SQL文件
    本文档详细介绍了如何在中标麒麟操作系统上安装达梦数据库,并提供了导入SQL文件的具体步骤。首先,检查系统的发行版和内核版本,接着创建必要的用户和用户组,规划数据库安装路径,挂载安装介质,调整系统限制以确保数据库的正常运行,最后通过图形界面完成数据库的安装。 ... [详细]
  • Zabbix自定义监控与邮件告警配置实践
    本文详细介绍了如何在Zabbix中添加自定义监控项目,配置邮件告警功能,并解决测试告警时遇到的邮件不发送问题。 ... [详细]
  • Nginx 启动命令及 Systemctl 配置详解
    本文详细介绍了在未配置和已配置 Systemctl 的情况下启动 Nginx 的方法,并提供了详细的配置步骤和命令示例。 ... [详细]
  • 本文详细介绍了在 Ubuntu 16.04 系统上安装和配置 PostgreSQL 数据库的方法,包括如何设置监听地址、启用密码加密、更改默认用户密码以及调整客户端访问控制。 ... [详细]
  • 本文详细介绍了在 CentOS 7 系统中安装 Python 3.7 的步骤,包括编译工具的安装、Python 3.7 源码的下载与编译、软链接的创建以及常见错误的处理方法。 ... [详细]
  • 汇总了2023年7月7日最新的网络安全新闻和技术更新,包括最新的漏洞披露、工具发布及安全事件。 ... [详细]
author-avatar
koglum
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有