热门标签 | 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

推荐阅读
  • 优化局域网SSH连接延迟问题的解决方案
    本文介绍了解决局域网内SSH连接到服务器时出现长时间等待问题的方法。通过调整配置和优化网络设置,可以显著缩短SSH连接的时间。 ... [详细]
  • 使用Vultr云服务器和Namesilo域名搭建个人网站
    本文详细介绍了如何通过Vultr云服务器和Namesilo域名搭建一个功能齐全的个人网站,包括购买、配置服务器以及绑定域名的具体步骤。文章还提供了详细的命令行操作指南,帮助读者顺利完成建站过程。 ... [详细]
  • CentOS系统安装与配置常见问题及解决方案
    本文详细介绍了在CentOS系统安装过程中遇到的常见问题及其解决方案,包括Vi编辑器的操作、图形界面的安装、网络连接故障排除等。通过本文,读者可以更好地理解和解决这些常见问题。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 如何配置Unturned服务器及其消息设置
    本文详细介绍了Unturned服务器的配置方法和消息设置技巧,帮助用户了解并优化服务器管理。同时,提供了关于云服务资源操作记录、远程登录设置以及文件传输的相关补充信息。 ... [详细]
  • 本文详细介绍了如何在CentOS 7操作系统上安装和配置Grafana,包括必要的依赖项安装、插件管理以及服务启动等步骤。 ... [详细]
  • 本文详细介绍了如何通过RPM包在Linux系统(如CentOS)上安装MySQL 5.6。涵盖了检查现有安装、下载和安装RPM包、配置MySQL以及设置远程访问和开机自启动等步骤。 ... [详细]
  • 本文详细介绍了如何解压并安装MySQL集群压缩包,创建用户和组,初始化数据库,配置环境变量,并启动相关服务。此外,还提供了详细的命令行操作步骤和常见问题的解决方案。 ... [详细]
  • CentOS 7.6环境下Prometheus与Grafana的集成部署指南
    本文旨在提供一套详细的步骤,指导读者如何在CentOS 7.6操作系统上成功安装和配置Prometheus 2.17.1及Grafana 6.7.2-1,实现高效的数据监控与可视化。 ... [详细]
  • 本文详细介绍如何使用arm-eabi-gdb调试Android平台上的C/C++程序。通过具体步骤和实用技巧,帮助开发者更高效地进行调试工作。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 根据最新发布的《互联网人才趋势报告》,尽管大量IT从业者已转向Python开发,但随着人工智能和大数据领域的迅猛发展,仍存在巨大的人才缺口。本文将详细介绍如何使用Python编写一个简单的爬虫程序,并提供完整的代码示例。 ... [详细]
  • PostgreSQL 10 离线安装指南
    本文详细介绍了如何在无法联网的服务器上进行 PostgreSQL 10 的离线安装,并涵盖了从下载安装包到配置远程访问的完整步骤。 ... [详细]
  • 选择适合生产环境的Docker存储驱动
    本文旨在探讨如何在生产环境中选择合适的Docker存储驱动,并详细介绍不同Linux发行版下的配置方法。通过参考官方文档和兼容性矩阵,提供实用的操作指南。 ... [详细]
  • 在编译BSP包过程中,遇到了一个与 'gets' 函数相关的编译错误。该问题通常发生在较新的编译环境中,由于 'gets' 函数已被弃用并视为安全漏洞。本文将详细介绍如何通过修改源代码和配置文件来解决这一问题。 ... [详细]
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社区 版权所有