zsh setup

查看是否安装

cat /etc/shells 
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/zsh                # 有这个说明已经安装了
/usr/bin/zsh
/usr/bin/tmux

查看当前shell 类型

echo $SHELL

安装

# 安葬
sudo apt install zsh

# 默认shell 设置zsh
chsh -s /bin/zsh

# 配置密码文件,解决chsh: PAM认证失败的问题;  第一行最后面是zsh
root:x:0:0:root:/root:/bin/zsh

# 网友提供的安装配置oh-my-zsh脚本

sh -c "$(curl -fsSL https://gitee.com/shmhlsy/oh-my-zsh-install.sh/raw/master/install.sh)"

# oh-my-zsh 路径为 ~/.oh-my-zsh/
# oh-my-zsh 核心脚本 ~/.oh-my-zsh/oh-my-zsh.sh
# .zshrc 里面也会执行 上面的脚本


# 安装好用的插件
# 自动补全, 不设置设个,补全效果不好
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh}/plugins/zsh-autosuggestions

# 语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh}/plugins/zsh-syntax-highlighting

# 快捷跳转
sudo apt-get install autojump

配置.zshrc

# 加载插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)


# 启动autojump
source /usr/share/autojump/autojump.sh


# rosenv
ros2init(){
     source /opt/ros/rolling/setup.zsh
	
     export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
     
     export ROS_DOMAIN_ID=42
     export ROS_VERSION=2
     export ROS_PYTHON_VERSION=3
     export ROS_DISTRO=rolling
}


卸载zsh

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

把/etc/passwd改回bash, 注意第一行,和最后一行

root:x:0:0:root:/root:/bin/zsh
hopps:x:1000:1000:hopps,,,:/home/hopps:/usr/bin/zsh

如何修改zsh 终端的输出格式

首先知道linux PS1  prompt 

zsh 好像与这两个关系不大,应为格式输出与主题关系大,应该在主题脚本里查看

设置ros/ros2 开发环境变量,在.zshrc 后面添加

r2() {
     export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

     export ROS_VERSION=2
     export ROS_PYTHON_VERSION=3
     export ROS_DISTRO=galactic
     #export ROS_DOMAIN_ID=42

     source /opt/ros/galactic/setup.zsh
     source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.zsh
     source /usr/share/colcon_cd/function/colcon_cd.sh
     eval "$(register-python-argcomplete3 ros2)"
     eval "$(register-python-argcomplete3 colcon)"
}

r1() {
      source /opt/ros/noetic/setup.zsh
      export ROS_VERSION=1
      #export ROS_MASTER_URI=3
      #export ROS_IP=
      export ROS_DISTRO=noetic
}


#r1
#r2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值