38 lines
1.1 KiB
Bash
38 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# File : .bashrc_common
|
|
# License : MIT
|
|
# Author : Feng Bohan <1953356163@qq.com>
|
|
# Date : 2025-04-25 17:20:07
|
|
# Last Modified Date: 2025-04-25 17:21:35
|
|
# Last Modified By : Feng Bohan <1953356163@qq.com>
|
|
# -----
|
|
# Copyright © 2025 Feng Bohan. All Rights Reserved.
|
|
alias e='gvim ~/.bashrc'
|
|
alias s='source ~/.bashrc'
|
|
alias eg='gvim ~/.vimrc'
|
|
|
|
#******************** set prompt ********************
|
|
free_mem()
|
|
{
|
|
free -m | awk 'NR==2{printf "%.2fG", $4/1024}'
|
|
}
|
|
w5(){
|
|
current_dir=$(pwd)
|
|
IFS='/' read -r -a dir_array <<< "$current_dir"
|
|
array_length=${#dir_array[@]}
|
|
if [ $array_length -gt 5 ]; then
|
|
start_index=$((array_length - 5))
|
|
short_path="/"
|
|
for (( i=$start_index; i<$array_length; i++ )); do
|
|
short_path+="${dir_array[i]}/"
|
|
done
|
|
echo "${short_path%?}"
|
|
else
|
|
echo "$current_dir"
|
|
fi
|
|
}
|
|
|
|
export PS1="[\[\e[01;32m\]\u@\h\[\e[00m\]-\t \$(free_mem)]:\[\e[01;34m\]\$(w5)\[\e[00m\]\$ "
|
|
# set for tabby auto detect work dir
|
|
export PS1="$PS1\[\e]1337;CurrentDir="'$(pwd)\a\]'
|