Debian 终端Shell命令行长路径改为短路径

需要修改bashrc

~/.bashrc

先备份一份

cp .bashrc bashrc.backup

编辑bashrc

vim ~/.bashrc

可以看到bashrc内容为

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples# If not running interactively, don't do anything
case $- in*i*) ;;*) return;;
esac# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth# append to the history file, don't overwrite it
shopt -s histappend# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; thendebian_chroot=$(cat /etc/debian_chroot)
fi# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" inxterm-color|*-256color) color_prompt=yes;;
esac# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yesif [ -n "$force_color_prompt" ]; thenif [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then# We have color support; assume it's compliant with Ecma-48# (ISO/IEC-6429). (Lack of such support is extremely rare, and such# a case would tend to support setf rather than setaf.)color_prompt=yeselsecolor_prompt=fi
fiif [ "$color_prompt" = yes ]; thenPS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
elsePS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";;
*);;
esac# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; thentest -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"alias ls='ls --color=auto'#alias dir='dir --color=auto'#alias vdir='vdir --color=auto'#alias grep='grep --color=auto'#alias fgrep='fgrep --color=auto'#alias egrep='egrep --color=auto'
fi# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.if [ -f ~/.bash_aliases ]; then. ~/.bash_aliases
fi# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; thenif [ -f /usr/share/bash-completion/bash_completion ]; then. /usr/share/bash-completion/bash_completionelif [ -f /etc/bash_completion ]; then. /etc/bash_completionfi
fi

别的都不用关心

找到这样一段代码

if [ "$color_prompt" = yes ]; thenPS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
elsePS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

将其中的\w改为\W,也就是把小写w改为大写W

改完后保存退出

执行

source .bashrc

可以看到终端路径不论cd了多少层目录,都只会显示最后的文件夹名称

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/200483.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

道可云元宇宙每日资讯|潍坊市元宇宙产业发展座谈会召开

道可云元宇宙每日简报(2023年12月5日)讯,今日元宇宙新鲜事有: 元宇宙数字内容创作大赛在璧山区举行 3日下午,梦界元境杯元宇宙数字内容创作大赛、第十四届蓝桥杯大赛专项赛颁奖典礼在重庆市璧山区举行。 本次大赛&am…

微信小程序网络请求二次封装

在微信小程序中,网络请求操作是非常频繁的,这样导致重复的代码太多了,防止浪费一些不必要的时间,所以,在项目搭建之初,请封装好一切可以封装的代码。 首先配置一个基地址: export default {ho…

基于FPGA的数字时钟设计与实现(含源码)

随着数字电子技术的不断发展,基于FPGA(现场可编程门阵列)的数字时钟设计方案逐渐成为了一种流行的选择。本篇博客将详细介绍如何利用FPGA实现一个简单的数字时钟,涉及到分频器、数码管驱动、时分秒计数、三八译码器和扫描数码管等…

禅道v11.6 基于linux环境下的docker容器搭建的靶场

一、环境搭建 linux环境下的 在docker环境下安装禅道CMS V11.6 docker run --name zentao_v11.6 -p 8084:80 -v /u01/zentao/www:/app/zentaopms -v /u01/zentao/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD123456 -d docker.io/yunwisdom/zentao:v11.6二、常见问题 1.删除…

Swing程序设计详解(二)

一 文件标签组与图标 在Swing程序设计中,标签(JLabel)被用于显示文本、图标等内容。在Swing应用程序的用户系面中,用户能够通过标签上的文本、图标等内容获得相应的提示信息。 1.1 JLable标签 标签(JLabel)的父类是JComponent类。虽然标签不能被添加…

Canal笔记:安装与整合Springboot模式Mysql同步Redis

官方文档 https://github.com/alibaba/canal 使用场景 学习一件东西前,要知道为什么使用它。 1、同步mysql数据到redis 常规情况下,产生数据的方法可能有很多地方,那么就需要在多个地方中,都去做mysql数据同步到redis的处理&…

在微信小程序中如何改变默认打开的页面

在微信小程序中,在我们编写页面的时候,可能会在重新渲染的时候导致页面跳转到默认打开的页面上,为了提升用户的一个体验,我们可以设置一些内容来修改小程序默认打开的页面,提升开发者的开发体验。 当我们打开一个微信…

nodejs微信小程序+python+PHP在线购票系统的设计与实现-计算机毕业设计推荐

目 录 摘 要 I ABSTRACT II 目 录 II 第1章 绪论 1 1.1背景及意义 1 1.2 国内外研究概况 1 1.3 研究的内容 1 第2章 相关技术 3 2.1 nodejs简介 4 2.2 express框架介绍 6 2.4 MySQL数据库 4 第3章 系统分析 5 3.1 需求分析 5 3.2 系统可行性分析 5 3.2.1技术可行性:…

某60区块链安全之JOP实战二学习记录

区块链安全 文章目录 区块链安全Jump Oriented Programming实战二实验目的掌握对EVM逆向能力实验环境实验工具实验原理实验内容Jump Oriented Programming实战二 实验步骤Jump Oriented Programming实战二 实验目的 学会使用python3的web3模块 学会分析以太坊智能合约中中Jum…

MyBatis 常见面试题

目录 1.MyBatis——概述1.1.什么是 ORM 框架?1.2.✨谈谈对 MyBatis 的理解。1.3.使用 MyBatis 相对于直接使用 SQL 有哪些优点?1.4.MyBatis 有什么优缺点?1.5.✨MyBatis 的分层结构是什么样的?1.6.✨MyBatis 的执行流程是什么样的…

机器学习实验一:线性回归

系列文章目录 机器学习实验一:线性回归机器学习实验二:决策树模型机器学习实验三:支持向量机模型机器学习实验四:贝叶斯分类器机器学习实验五:集成学习机器学习实验六:聚类 文章目录 系列文章目录一、实验…

12、pytest上下文友好的输出

官方实例 # content of test_assert2.py import pytestdef test_set_comparison():set1 set("1308")set2 set("8035")assert set1 set2def test_dict_comparison():dict_1 {name:陈畅,sex:男}dict_2 {name:赵宁,sex:女}assert dict_1 dict_2def tes…

今日心得:多总结多探索,多于他人沟通,思想观点碰撞

今日在工作中获得了一些新的体验和感悟,使我深刻认识到不断总结和探索的重要性。 通过反思和总结,我能够更好地理解自己的行为和决策,发现自己的优点和不足,从而更好地规划未来的行动。 在人生的旅途中,我们不断地遇到…

Flask项目Day1,Flask常见第三方拓展包

拉项目 git clone https://gitee.com/hahaguai007/python-flask-mysql.git git clone 项目地址运行后即可获取项目 2.创建数据库 在MySQL中创建一个数据库,名字自己定,然后修改RealProject\settings.py里的SQLALCHEMY_DATABASE_URI,格式为 …

第18章 C++11标准库(STL)

STL定义了强大的、基于模板的、可复用的组件,实现了许多通用的数据结构及处理这些数据结构的算法。其中包含三个关键组件——容器(container,流行的模板数据结构)、迭代器(iterator)和算法(algo…

动态规划求解 fibonacci 数列

动态规划: 动态规划的基本思想是:将原问题拆分为若干子问题,自底向上的求解。是自底向上的求解,即是先计算子问题的解,再得出原问题的解。 思路: 创建一个数组,大小为n1,用于存储斐波那契数列的值。数组的…

maven-profile

指定profile生效的几种方式 maven中profile的使用详解_maven profile_2021不再有雨的博客-CSDN博客 【Maven】【翻译】3、Profiles文件_maven的profiles文件是什么-CSDN博客 查看当前生效的profile mvn help:active-profiles 比如有些是用activeProfiles在pom中指定的&…

我在USC南加大学游戏:真实经历/录取作品集_RoSSo艺术留学

近日,美国Common App最新早申统计数据:早申人数与疫情前相比增加了41%!专注于国际艺术教育的RoSSo也发现,2022-2023申请季提交早申的学生中,各类热门院校以及艺术留学专业申请人数均是“涨”声一片! 图源官…

SpringBoot3-快速体验

1、pom.xml <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/POM/4.0.…

计算机寄存器是如何实现的

冯诺依曼体系 冯诺依曼体系为现代计算机的设计和发展奠定了基础&#xff0c;它的核心思想和原则在当今计算机体系结构中仍然被广泛采用和应用。所以只要谈论计算机的组成就离不开冯诺依曼体系 作为核心组成部分的CPU除了由运算器和控制器组成之外&#xff0c;还有一些寄存器…