Unset auxiliary env variables
[idea/community.git] / plugins / terminal / resources / jediterm-bash.in
1 #!/bin/bash
2
3 function load_login_configs {
4   #       When bash is invoked as an interactive login shell, or as a  non-interac-
5   #       tive  shell with the --login option, it first reads and executes commands
6   #       from the file /etc/profile, if that  file  exists.   After  reading  that
7   #       file,  it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in
8   #       that order, and reads and executes  commands  from  the  first  one  that
9   #       exists  and  is  readable.
10
11   if [ -f /etc/profile ]; then
12      source /etc/profile
13   fi
14
15   if [ -f ~/.bash_profile ]; then
16      source ~/.bash_profile
17   else
18      if [ -f ~/.bash_login ]; then
19         source ~/.bash_login
20      else
21         if [ -f ~/.profile ]; then
22            source ~/.profile
23         fi
24      fi
25   fi
26 }
27
28 function load_interactive_configs {
29   if [ -f ~/.bashrc ]; then
30        source ~/.bashrc
31   fi
32 }
33
34 if [ -n $LOGIN_SHELL ]; then
35   load_login_configs
36   unset LOGIN_SHELL
37 fi
38
39 load_interactive_configs
40
41 # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
42 bind '"\e\e[C":forward-word'
43 bind '"\e\e[D": backward-word'
44 bind '"\e\O[C":forward-word'
45 bind '"\e\O[D": backward-word'
46
47 function generate_command_executed_sequence() {
48    printf '\e\7'
49 }
50
51 export -f generate_command_executed_sequence
52
53
54 #generate escape sequence after command is executed to notify jediterm emulator
55 trap "generate_command_executed_sequence" DEBUG
56
57 if [ -n "$JEDITERM_USER_RCFILE" ]
58 then
59   source $JEDITERM_USER_RCFILE
60   unset JEDITERM_USER_RCFILE
61 fi
62
63 if [ -n "$JEDITERM_SOURCE" ]
64 then
65   source $JEDITERM_SOURCE
66   unset JEDITERM_SOURCE
67 fi