rayae 最近的时间轴更新
rayae

rayae

V2EX 第 454487 号会员,加入于 2019-11-21 09:26:05 +08:00
今日活跃度排名 8583
rayae 最近回复了
分享一下我的:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return

MAIN_DEVICE=harvey

if test -f $HOME/.config/.dotfiles_main_device; then
MAIN_DEVICE=$HOSTNAME
fi

prompt_command() {
local last_ret=$?
history -a

# terminal tab title
local cwd="$PWD"
local title="${cwd/#$HOME/\~}"

if [ "$MAIN_DEVICE"x = "$HOSTNAME"x ] ; then
echo -n -e "\\e]0;$title\\007"
local HOST_FLAG=""
else
echo -n -e "\\e]0;$HOSTNAME > $title\\007"
local HOST_FLAG="${COLOR_YELLOW}\h${COLOR_NOCOLOR} "
fi


export COLOR_NOCOLOR='\[\e[0m\]'
export COLOR_RED='\[\e[0;31m\]'
export COLOR_GREEN='\[\e[0;32m\]'
export COLOR_ORANGE='\[\e[0;33m\]'
export COLOR_BLUE='\[\e[0;34m\]'
export COLOR_PURPLE='\[\e[0;35m\]'
export COLOR_CYAN='\[\e[0;36m\]'
export COLOR_WHITE='\[\e[0;37m\]'
export COLOR_YELLOW='\[\e[0;33m\]'
export COLOR_GRAY='\[\e[0;30m\]'
export COLOR_LIGHT_WHITE='\[\e[1;37m\]'
export COLOR_LIGHT_GRAY='\[\e[0;37m\]'
export COLOR_LIGHT_RED='\[\e[1;31m\]'
export COLOR_LIGHT_GREEN='\[\e[1;32m\]'
export COLOR_LIGHT_BLUE='\[\e[1;34m\]'
export COLOR_LIGHT_PURPLE='\[\e[1;35m\]'
export COLOR_LIGHT_CYAN='\[\e[1;36m\]'
export COLOR_LIGHT_YELLOW='\[\e[1;33m\]'
export COLOR_LIGHT_GRAY='\[\e[1;30m\]'

# PS1
case "$TERM" in
xterm*|gnome*|konsole*|screen*) color_prompt=yes;;
*) color_prompt=no;;
esac

if [ "$color_prompt" == no ]; then
for name in $(env|grep ^COLOR_|cut -d= -f1);do
unset ${name}
done
fi

if [ $UID = 0 ] ; then
local USER_FLAG="#"
else
local USER_FLAG="$"
fi

local SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
local SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
if [ $SSH2_IP ] || [ $SSH_IP ] ; then
local HOST_FLAG="${COLOR_RESET}${COLOR_LIGHT_YELLOW}\h${COLOR_NOCOLOR} "
fi

if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
local DEBIAN_CHROOT=$(cat /etc/debian_chroot)
fi

local GIT_BRANCH=''
if command -v git >/dev/null ; then
local GIT_BRANCH='$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e "s#* \(.*\)# ($(git config user.name) @ \1)#")'
fi

# last exit code
PS1=''
# chroot
PS1="${PS1}${COLOR_RESET}${DEBIAN_CHROOT}"
# show hostname if current not main device
PS1="${PS1}${HOST_FLAG}"
# current directory
PS1="${PS1}${COLOR_LIGHT_GRAY}[${COLOR_LIGHT_GREEN}\w${COLOR_NOCOLOR}${COLOR_LIGHT_GRAY}]"
# git repository info
PS1="${PS1}${COLOR_PURPLE}${GIT_BRANCH}${COLOR_NOCOLOR}"
# color by exit code
if [ $last_ret == 0 ] ; then
PS1="${PS1}${COLOR_LIGHT_WHITE} ${USER_FLAG}"
else
PS1="${PS1}${COLOR_LIGHT_RED} ($last_ret)${USER_FLAG}"
fi
# root/user flag
PS1="${PS1}${COLOR_NOCOLOR} "

export PS1
export PS2='> '
export PS3='#? '
export PS4='+'

for name in $(env|grep ^COLOR_|cut -d= -f1);do
unset ${name}
done
}

export HISTFILESIZE=10000
export HISTSIZE=10000
export HISTCONTROL=erasedups:ignoredups:ignorespace # Don't put duplicate lines in the history and do not add lines that start with a space
export HISTIGNORE="pwd:l:la:[bf]g:exit" # ignore such commands
export HISTTIMEFORMAT='%Y%m%d-%H:%M:%S '
export PROMPT_COMMAND='prompt_command'
export PROMPT_DIRTRIM=3


shopt -s cmdhist # combine multiline commands into single history
shopt -s histappend # append history
shopt -s checkwinsize # re-update LINEs and COLUMNs
shopt -s autocd
shopt -s extglob
shopt -s dotglob
shopt -s cdspell
shopt -s dirspell
shopt -s progcomp
shopt -s no_empty_cmd_completion

set -o noclobber

stty -ixon # replace Ctrl-S for forward-search-history


export EDITOR='vim'


# Use bash-completion, if available
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi


bind "set completion-ignore-case on" 2>/dev/null
bind "set bell-style none" 2>/dev/null
bind "set show-all-if-ambiguous on" 2>/dev/null
bind "set show-all-if-unmodified on" 2>/dev/null
# search history with arrow
bind '"\e[A": history-search-backward' 2>/dev/null
bind '"\e[B": history-search-forward' 2>/dev/null



# alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias cd..="cd .."


if command -v dircolors > /dev/null 2>&1; then
source <(dircolors)
fi
38 天前
回复了 zrc199021 创建的主题 Linux export PS1 不生效问题请教
试一下 unset PROMPT_COMMAND 再 export PS1
@june4 不是每个浏览器都会对网页 [安装到桌面] 的功能进行弹窗拦截提示,厂商当然默认对自家浏览器做默认的信任。并且现如今,会用非 OEM 提供的浏览器的人少之又少
你希望某些网站在你手机桌面上到处拉屎的感觉吗,我觉得默认禁用挺好的
@xinmans 那要不直接 rsync 吧
每个容器都 commit 一遍,导成 tar 去另一边导入
和装机助手小程序很像,但是实话实话是,我会选择小程序
高版本 jdk 反射要加 VM 参数
132 天前
回复了 bantoushui 创建的主题 职场话题 分享一下大家工作后的薪资变化
@silencil 工作量换的
132 天前
回复了 bantoushui 创建的主题 职场话题 分享一下大家工作后的薪资变化
5K ( 2021 ) -> 6.5K ( 2021 ) -> 17K ( 2022 ) -> 20K ( 2023 ) -> 22K ( 2024 )
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3042 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
Developed with CodeLauncher
♥ Do have faith in what you're doing.