LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-12-2016, 07:06 AM   #1
wladwolkow
LQ Newbie
 
Registered: Jul 2016
Location: Moscow
Distribution: Slackware 14.2
Posts: 3

Rep: Reputation: Disabled
How to cutomize better this .bashrc config?


PHP Code:
#!/syntax/bash
# /!\ repo sync
#
#source ~/.profile                                      
[[ "$PS1]] || return # only interactive shells apply

test -~/.alias && . ~/.alias || true
export PATH
="~/bin:/usr/sbin:$PATH"
#rvm default 2.2.4                    
export EDITOR=vim
# Defaults
#
shopt -s no_empty_cmd_completion
shopt 
-s histappend
HISTSIZE
=10000
HISTFILESIZE
=10000
HISTTIMEFORMAT
='%F %T %Z: '
HISTCONTROL=ignorespace:ignoredups
HISTIGNORE
=''

#set +H # disable expansion

prompt_command () {
    
# set an error string for the prompt, if applicable
    
if [ $? -eq 0 ]; then
        ERRPROMPT
=" "
    
else
        
ERRPROMPT=" ($?) "
    
fi
 
    local BRANCH
=""
 
    
# if we're in a Git repo, show current branch
    #if [ "\$(type -t __git_ps1 2> /dev/null)" ]; then
    #    BRANCH="\$(__git_ps1 '[ %s ] ')"
    #fi
 
    
if [ -".svn" ]; then
        BRANCH
="[ "`svn info | awk '/Last\ Changed\ Rev/ {print $4}'`" ]"
    
fi
 
    local LOAD
=`cut -d' ' -f1 /proc/loadavg`
    
#local TIME=`date +"%d.%m.%Y %H:%M:%S"`
    
local TIME=`date +"%H:%M:%S"`
    
local CURENT_PATH=`echo ${PWD/#$HOME/\~}`
 
    # trim long path
    
if [ ${#CURENT_PATH} -gt "35" ]; then
        
let CUT=${#CURENT_PATH}-35
        
CURENT_PATH="...$(echo -n $PWD | sed -e "s/\(^.\{$CUT\}\)\(.*\)/\2/")"
    
fi
 
    local TITLEBAR
="\[\e]2;${CURENT_PATH}\a\]"
 
    
local GREEN="\[\033[0;32m\]"
    
local CYAN="\[\033[0;36m\]"
    
local BCYAN="\[\033[1;36m\]"
    
local BLUE="\[\033[0;34m\]"
    
local GRAY="\[\033[0;37m\]"
    
local DKGRAY="\[\033[1;30m\]"
    
local WHITE="\[\033[1;37m\]"
    
local RED="\[\033[0;31m\]"
    
# return color to Terminal setting for text color
    
local DEFAULT="\[\033[0;39m\]"
 
    
PROMPT="[ ${TIME}${LOAD}${USER}@${HOSTNAME} ]$ERRPROMPT [ ${CURENT_PATH} ]"
 
    
# different prompt and color for root
    
local PR="$ "
    
local USERNAME_COLORED="${BCYAN}${USER}${GREEN}@${BCYAN}${HOSTNAME}"
    
if [ "$UID"0" ]; then
        PR
="# "
        
USERNAME_COLORED="${RED}${USER}${GREEN}@${RED}${HOSTNAME}"
    
fi
 
    
# use only ASCII symbols in linux console
    
local DASH="\e(0q\e(B"
    
local TC="\[\e(0l\e(B\]"
    
local BC="\[\e(0m\e(B\]"
    
if [ "$TERM"linux" ]; then
        TITLEBAR
=""
        
DASH="-"
        
TC=""
        
BC=""
    
fi
 
    local SEPARATOR
=""
    
let FILLS=${COLUMNS}-${#PROMPT}
    
for (( i=0i<$FILLSi++ )) do
        
SEPARATOR=$SEPARATOR$DASH
    done
    history 
-&& history -a  
    local TOP_LINE
="${GRAY}${TC}${CYAN}${WHITE}${TIME}${DKGRAY}${LOAD}${USERNAME_COLORED} 
${CYAN}]${RED}$ERRPROMPT${CYAN}${GRAY}${CURENT_PATH}${CYAN} ]${GRAY}${SEPARATOR}"
    
local BOTTOM_LINE="${BC}${GREEN}${BRANCH}${CYAN}${GREEN}${PR}${DEFAULT}"
    
export PS1="${TITLEBAR}\n${TOP_LINE}\n${BOTTOM_LINE}"
}
PROMPT_COMMAND=prompt_command 
 
Old 08-12-2016, 08:02 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Nobody can answer your question because you don't give us any useful information about what you want to achieve.

Try asking specific questions and tell us what you want your config to do for you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/bashrc ,dircolors and /root/.bash_profile ,/.bashrc not exist in LFS-7.5(sec9.3) jaassi Linux From Scratch 2 09-20-2014 05:04 PM
~/.bashrc, /etc/bash.bashrc files not read? Tachtory Slackware 3 01-04-2014 12:25 AM
[SOLVED] How to use my /home/kangjoo/.bashrc rather than root/.bashrc kangjoo.lee Linux - Newbie 2 11-05-2012 03:38 PM
[SOLVED] Cutomize Maya 8.5 on Linux me_spearhead Linux - Software 0 04-03-2009 12:05 AM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration