Shell .bashrc settings
This article contains some settings I used for the .bashrc
configuration file during my study and work.
Do tasks depending on hostname
Add conditions as such to do tasks for different host server accordingly. This is useful when you work with multiple servers as they share the same storage.
# Determine the hostname and do tasks accordingly
## on host 1: develop server
if [ $HOSTNAME = "qce-apps01.ewi.tudelft.nl" ]; then
echo "Load Vivado/2019.1"
module load Vivado/2019.1
fi
## on host 2: Alveo server
if [ $HOSTNAME = "qce-alveo01.ewi.tudelft.nl" ]; then
echo "Load XRT, Vitis and Vivado 2019.2"
source /opt/xilinx/xrt/setup.sh
source /opt/apps/xilinx/Vivado/2019.2/settings64.sh
source /opt/apps/xilinx/Vitis/2019.2/settings64.sh
fi
Broken scp
When you put echo
command in the .bashrc file, command scp
to that server could be unsuccessful. A solution is to bypass non-interactive shell, which is the case for scp
. Just put the following line before any tasks in the .bashrc file.
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
Simple explanation:
$-
current flags, would be “himBH” by default- if flag don’t contain ‘i’ flag (interactive), return
- otherwise this is an interactive shell, thus doing following tasks
Reference