1+ #! /bin/bash
2+
3+ # =============================================================================
4+ # Copyright (C) 2025, Robotic Systems Lab, ETH Zurich
5+ # All rights reserved.
6+ # http://www.rsl.ethz.ch
7+ #
8+ # This software is distributed WITHOUT ANY WARRANTY; without even the
9+ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+ # See the License for more information.
11+ # =============================================================================
12+ # Authors: Julian Nubert, [email protected] 13+ # Lorenzo Terenzi, [email protected] 14+ # =============================================================================
15+
16+ # If not running interactively, don't do anything
17+ case $- in
18+ * i* ) ;;
19+ * ) return ;;
20+ esac
21+
22+ # don't put duplicate lines or lines starting with space in the history.
23+ HISTCONTROL=ignoreboth
24+
25+ # append to the history file, don't overwrite it
26+ shopt -s histappend
27+
28+ # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
29+ HISTSIZE=1000
30+ HISTFILESIZE=2000
31+
32+ # check the window size after each command and, if necessary,
33+ # update the values of LINES and COLUMNS.
34+ shopt -s checkwinsize
35+
36+ # make less more friendly for non-text input files, see lesspipe(1)
37+ [ -x /usr/bin/lesspipe ] && eval " $( SHELL=/bin/sh lesspipe) "
38+
39+ # set variable identifying the chroot you work in (used in the prompt below)
40+ if [ -z " ${debian_chroot:- } " ] && [ -r /etc/debian_chroot ]; then
41+ debian_chroot=$( cat /etc/debian_chroot)
42+ fi
43+
44+ # set a fancy prompt (non-color, unless we know we "want" color)
45+ case " $TERM " in
46+ xterm-color|* -256color) color_prompt=yes;;
47+ esac
48+
49+ # uncomment for a colored prompt, if the terminal has the capability; turned
50+ # off by default to not distract the user: the focus in a terminal window
51+ # should be on the output of commands, not on the prompt
52+ # force_color_prompt=yes
53+
54+ if [ -n " $force_color_prompt " ]; then
55+ if [ -x /usr/bin/tput ] && tput setaf 1 >& /dev/null; then
56+ # We have color support; assume it's compliant with Ecma-48
57+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
58+ # a case would tend to support setf rather than setaf.)
59+ color_prompt=yes
60+ else
61+ color_prompt=
62+ fi
63+ fi
64+
65+ if [ " $color_prompt " = yes ]; then
66+ PS1=' ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
67+ else
68+ PS1=' ${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
69+ fi
70+ unset color_prompt force_color_prompt
71+
72+ # If this is an xterm set the title to user@host:dir
73+ case " $TERM " in
74+ xterm* |rxvt* )
75+ PS1=" \[\e]0;${debian_chroot: +($debian_chroot )} \u@\h: \w\a\]$PS1 "
76+ ;;
77+ * )
78+ ;;
79+ esac
80+
81+ # enable color support of ls and also add handy aliases
82+ if [ -x /usr/bin/dircolors ]; then
83+ test -r ~ /.dircolors && eval " $( dircolors -b ~ /.dircolors) " || eval " $( dircolors -b) "
84+ alias ls=' ls --color=auto'
85+ alias grep=' grep --color=auto'
86+ alias fgrep=' fgrep --color=auto'
87+ alias egrep=' egrep --color=auto'
88+ fi
89+
90+ # some more ls aliases
91+ alias ll=' ls -alF'
92+ alias la=' ls -A'
93+ alias l=' ls -CF'
94+
95+ # Add an "alert" alias for long running commands. Use like so:
96+ # sleep 10; alert
97+ alias alert=' notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e ' \' ' s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//' \' ' )"'
98+
99+ # Alias definitions.
100+ if [ -f ~ /.bash_aliases ]; then
101+ . ~ /.bash_aliases
102+ fi
103+
104+ # enable programmable completion features (you don't need to enable
105+ # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
106+ # sources /etc/bash.bashrc).
107+ if ! shopt -oq posix; then
108+ if [ -f /usr/share/bash-completion/bash_completion ]; then
109+ . /usr/share/bash-completion/bash_completion
110+ elif [ -f /etc/bash_completion ]; then
111+ . /etc/bash_completion
112+ fi
113+ fi
114+
115+ # ==
116+ # Fuzzy search
117+ # ==
118+ # Install fuzzy-search if missing
119+ if [[ ! -d ~ /.fzf ]]
120+ then
121+ git clone --depth 1 https://github.com/junegunn/fzf.git ~ /.fzf && ~ /.fzf/install
122+ fi
123+
124+ # Enable fuzzy search in terminal
125+ [ -f ~ /.fzf.bash ] && source ~ /.fzf.bash
126+
127+ # ==
128+ # Git
129+ # ==
130+ parse_git_branch () {
131+ git branch 2> /dev/null | sed -e ' /^[^*]/d' -e ' s/* \(.*\)/(\1)/'
132+ }
133+ export PS1=$PS1 " \[\e[91m\]\$ (parse_git_branch)\[\e[00m\]$ "
134+ export PS1=" (D) " $PS1
135+
136+ # ==
137+ # ROS
138+ # ==
139+ # Source the ROS distribution file to configure the shell environment.
140+ FILE=/opt/ros/noetic/setup.bash
141+ if test -f " $FILE " ;
142+ then
143+ echo " $FILE exists. Therefore sourcing noetic."
144+ source $FILE
145+ else
146+ echo " $FILE does not exist. Therefore not sourcing noetic."
147+ fi
148+
149+ # EOF
0 commit comments