Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UserConfig
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
UserConfig
Commits
d6db9bac
Commit
d6db9bac
authored
5 years ago
by
JiriKalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Add bash promt features no name and new line
parent
cf0c532f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bash/bashrc
+33
-19
33 additions, 19 deletions
bash/bashrc
bash/init.sh
+1
-0
1 addition, 0 deletions
bash/init.sh
with
34 additions
and
19 deletions
bash/bashrc
+
33
−
19
View file @
d6db9bac
...
...
@@ -19,41 +19,55 @@ shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
parse_git_branch() {
promt_
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
rvalue() {
promt_
rvalue() {
lastcmd=$?;
if [ $lastcmd -ne 0 ]; then
echo "[$lastcmd]";
fi
exit $lastcmd
}
rvalueUsr() {
promt_NoUser=0
promt_usrCut(){
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $promt_NoUser -eq 0 ]; then
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
echo -e "\033[01;31m$lastcmdStr\033[01;32m${usr:${#lastcmdStr}}" | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
printf ${usr:${#lastcmdStr}} | sed -e 's/* \(.*\)/(\1)/'
else
printf $usr | sed -e 's/* \(.*\)/(\1)/'
fi
fi
exit $lastcmd
}
promt_NewLine=0;
promt_MakNewLine(){
if [ $promt_NewLine -ne 0 ]; then
printf '\n$' #| sed -e 's/* \(.*\)/(\1)/'
else
tmp=$usr
printf "\[\033[01;32m$usr\]" | sed -e 's/* \(.*\)/(\1)/'
printf '$' #| sed -e 's/* \(.*\)/(\1)/'
fi
}
#echo -n "$usr"
pNL()
{
if [ $promt_NewLine -eq 0 ]; then
promt_NewLine=1;
else
promt_NewLine=0;
fi
}
usrCut() {
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
printf ${usr:${#lastcmdStr}} | sed -e 's/* \(.*\)/(\1)/'
pNN()
{
if [ $promt_NoUser -eq 0 ]; then
promt_NoUser=1;
else
pr
intf $usr | sed -e 's/* \(.*\)/(\1)/'
pr
omt_NoUser=0;
fi
exit $lastcmd
}
# check the window size after each command and, if necessary,
...
...
@@ -94,7 +108,7 @@ if [ -n "$force_color_prompt" ]; then
fi
#if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]$(rvalue)\[\033[01;32m\]$(usrCut)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]$ \[\033[00m\]'
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]$(
promt_
rvalue)\[\033[01;32m\]$(
promt_
usrCut)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(
promt_
parse_git_branch)\[\033[00m\]$
(promt_MakNewLine)
\[\033[00m\]'
# PS1='\e[31m$(rvalue)${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]\$ \[\033[00m\] '
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]$ \[\033[00m\] '
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
...
...
This diff is collapsed.
Click to expand it.
bash/init.sh
+
1
−
0
View file @
d6db9bac
cp
bashrc ~/.bashrc
echo
"
$1
"
>>
~/.bashrc
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment