I want to capture my very simple, yet I think clean, settings I like to use.
Here is my .bashrc
---------------------------------------------------------
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
LS_COLORS='di=1;33' ; export LS_COLORS
PROMPT_DIRTRIM=3
export PROMPT_DIRTRIM
PS1="[\u \w]\$"
---------------------------------------------------------
This sets some colors and makes the prompt show the directories in a way that I find useful because I am always deep into the directory structure.
[user1 ~/.../opt/solr-5.4.1/example]$
Here is my .vimrc
---------------------------------------------------------
colorscheme desert
---------------------------------------------------------
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Thursday, February 11, 2016
BASH Script to remove trailing back slash
I was working with a script that was called in an RPM build (in the SPEC file). I passed a directory as a the first variable to the script. The directory ended with a back slash. I needed to remove that backslash since all of my variables started with a backslash.
RPM_BUILD_DIR=""
if [ -n "$1" ]
then
RPM_BUILD_DIR=${1%/} #REMOVE TRAILING /
fi
So, the bash script checks to see if we have a parameter in the first position and if so remove the trailing backslash.
If the directory string was "/usr/local/bin/" the results are:
"/usr/local/bin"
I searched for examples to do this and they all seemed overly complex. Maybe this one is too simple for some situations, but it works for my needs.
RPM_BUILD_DIR=""
if [ -n "$1" ]
then
RPM_BUILD_DIR=${1%/} #REMOVE TRAILING /
fi
So, the bash script checks to see if we have a parameter in the first position and if so remove the trailing backslash.
If the directory string was "/usr/local/bin/" the results are:
"/usr/local/bin"
I searched for examples to do this and they all seemed overly complex. Maybe this one is too simple for some situations, but it works for my needs.
Subscribe to:
Posts (Atom)