Browse code

bash_profile (cygwin) - v2.0 - Behavior improved

Improvements of PATH, DISPLAY setup, start_agent calling and ssh multikey management

Fred authored on11/06/2016 21:48:58
Showing1 changed files
... ...
@@ -1,14 +1,15 @@
1 1
 # Title: .bash_profile
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.3
3
+# Version: 2.0
4 4
 # Created in: 2014-01-07
5
-# Modified in: 2014-09-25
5
+# Modified in: 2016-06-10
6 6
 
7 7
 
8 8
 #==========#
9 9
 # Versions #
10 10
 #==========#
11 11
 
12
+# v2.0 - 2016-06-10: PATH updated / DISPLAY variable setup improved to allow remote display through ssh / start_agent with multikey management / start_agent calling improved / ssh aliases updated
12 13
 # v1.3 - 2014-09-25: start_agent with limited ssh key lifetime added
13 14
 # v1.2 - 2014-08-26: CHERE_INVOKING variable added 
14 15
 # v1.1 - 2014-08-20: multiscreen remove because of .screenrc set up / Java variables added
... ...
@@ -36,6 +37,7 @@ fi
36 37
 alias medusa='ssh medusa'
37 38
 alias medusa2='ssh medusa2'
38 39
 alias mendel='ssh mendel'
40
+alias bulmer='ssh bulmer'
39 41
 
40 42
 # Shortcut for vim
41 43
 alias vi='vim'
... ...
@@ -49,36 +51,65 @@ alias wh="cd /cygdrive/c/Users/$USER/"
49 51
 # User specific environment and startup programs #
50 52
 #================================================#
51 53
 
52
-# Personalized PATH
53
-export PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Intel/Services/IPT:/cygdrive/c/Program Files (x86)/NTRU Cryptosystems/NTRU TCG Software Stack/bin:/cygdrive/c/Program Files/NTRU Cryptosystems/NTRU TCG Software Stack/bin:/cygdrive/c/Program Files/Dell/Dell Data Protection/Access/Advanced/Wave/Gemalto/Access Client/v5:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/12.0/DLLShared:/cygdrive/c/Program Files (x86)/Roxio/OEM/AudioCore:/usr/lib/lapack:$HOME/local/bin"
54
-
55
-# Set up the display variable to get an automatique display in the X server
56
-export DISPLAY=:0.0
54
+#---------------#
55
+# Personal Path #
56
+#---------------#
57 57
 
58 58
 # Java
59
-export JAVA_HOME=/cygdrive/c/Users/fcheval/AppData/Local/PortableApps/CommonFiles/Java
59
+export JAVA_HOME=/cygdrive/c/Users/$USER/AppData/Local/PortableApps/CommonFiles/Java
60 60
 export PATH=$PATH:$JAVA_HOME/bin
61 61
 
62 62
 # Chere variable (read by /etc/profile - important to start new shell session from current directory instead of $HOME)
63 63
 export CHERE_INVOKING=1
64 64
 
65
-# SSH environment setup
65
+
66
+#----------------#
67
+# Window display #
68
+#----------------#
69
+
70
+# Set up the display variable to get an automatique display in the X server
71
+if [[ -z "$SSH_CONNECTION" ]]
72
+then
73
+    export DISPLAY=:0.0
74
+elif [[ -n "$SSH_CONNECTION" && -z "$DISPLAY" ]]
75
+then
76
+    flag="\$DISPLAY has no value"
77
+elif [[ -n "$SSH_CONNECTION" && $DISPLAY =~ ":0.0" ]]
78
+then
79
+    flag="Value of \$DISPLAY is $DISPLAY"
80
+fi
81
+
82
+if [[ -n "$flag" ]]
83
+then
84
+    msg="${flag}. You cannot display remote windows. If -Y was used, set \"X11Forwarding yes\" in the server sshd_config file (see man sshd_config)."
85
+    if [[ $(echo $PS1 | grep '\\e\[') ]]
86
+    then
87
+        echo -e "\n\e[33mWarning:\e[00m $msg\n"
88
+    else
89
+        echo "\nWarning: $msg\n"
90
+    fi
91
+fi
92
+
93
+
94
+#-----------------------#
95
+# SSH environment setup #
96
+#-----------------------#
97
+
98
+# Variables
99
+SSH_KEY_LIST="$HOME/.ssh/key_list"  # File with full path of keys (one per line) to load with start_agent
100
+[[ -f "$SSH_KEY_LIST" ]] && SSH_KEYS=($(cat $SSH_KEY_LIST))
66 101
 lifetime=259200 # seconds => 3 days
102
+
103
+# Loading keys
67 104
 if [[ -f "${SSH_ENV}" ]]
68 105
 then
69
-    source "${SSH_ENV}" > /dev/null
70
-    
71
-    # Check if ssh-agent is active
72
-    #ps ${SSH_AGENT_PID} doesn't work under cywgin
73
-    if [[ ! $(ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$) ]]
74
-    then
75
-        start_agent -t $lifetime
106
+    source "$SSH_ENV"
76 107
     # Check if the ssh key is still stored
77
-    elif [[ $(ssh-add -l &> /dev/null; echo $?) != 0 ]]
108
+    if [[ $(ssh-add -l &> /dev/null; echo $?) != 0 ]]
78 109
     then
79 110
         pkill ssh-agent
80
-        start_agent -t $lifetime
111
+        eval start_agent -t $lifetime ${SSH_KEYS[@]}
81 112
     fi
82 113
 else
83
-    start_agent -t $lifetime
114
+    eval start_agent -t $lifetime ${SSH_KEYS[@]}
84 115
 fi
Browse code

bashrc - v1.7 & bash_profile (cygwin) - v1.3

Update of bashrc and bash_profile to add ssh key lifetime (or any ssh-agent option) to the start_agent function and use it in the bash_profile on cygwin.

Fred authored on26/09/2014 00:02:01
Showing1 changed files
... ...
@@ -1,14 +1,15 @@
1 1
 # Title: .bash_profile
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.2
3
+# Version: 1.3
4 4
 # Created in: 2014-01-07
5
-# Modified in: 2014-08-26
5
+# Modified in: 2014-09-25
6 6
 
7 7
 
8 8
 #==========#
9 9
 # Versions #
10 10
 #==========#
11 11
 
12
+# v1.3 - 2014-09-25: start_agent with limited ssh key lifetime added
12 13
 # v1.2 - 2014-08-26: CHERE_INVOKING variable added 
13 14
 # v1.1 - 2014-08-20: multiscreen remove because of .screenrc set up / Java variables added
14 15
 # v1.0 - 2014-08-11: rewriting for better interplay with .bashrc
... ...
@@ -60,3 +61,24 @@ export PATH=$PATH:$JAVA_HOME/bin
60 61
 
61 62
 # Chere variable (read by /etc/profile - important to start new shell session from current directory instead of $HOME)
62 63
 export CHERE_INVOKING=1
64
+
65
+# SSH environment setup
66
+lifetime=259200 # seconds => 3 days
67
+if [[ -f "${SSH_ENV}" ]]
68
+then
69
+    source "${SSH_ENV}" > /dev/null
70
+    
71
+    # Check if ssh-agent is active
72
+    #ps ${SSH_AGENT_PID} doesn't work under cywgin
73
+    if [[ ! $(ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$) ]]
74
+    then
75
+        start_agent -t $lifetime
76
+    # Check if the ssh key is still stored
77
+    elif [[ $(ssh-add -l &> /dev/null; echo $?) != 0 ]]
78
+    then
79
+        pkill ssh-agent
80
+        start_agent -t $lifetime
81
+    fi
82
+else
83
+    start_agent -t $lifetime
84
+fi
Browse code

bash_profile (cygwin) - v1.2 - see Versions

Fred authored on26/08/2014 23:57:19
Showing1 changed files
... ...
@@ -1,14 +1,15 @@
1 1
 # Title: .bash_profile
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.1
3
+# Version: 1.2
4 4
 # Created in: 2014-01-07
5
-# Modified in: 2014-08-20
5
+# Modified in: 2014-08-26
6 6
 
7 7
 
8 8
 #==========#
9 9
 # Versions #
10 10
 #==========#
11 11
 
12
+# v1.2 - 2014-08-26: CHERE_INVOKING variable added 
12 13
 # v1.1 - 2014-08-20: multiscreen remove because of .screenrc set up / Java variables added
13 14
 # v1.0 - 2014-08-11: rewriting for better interplay with .bashrc
14 15
 # v0.0 - 2014-01-07: creation
... ...
@@ -57,3 +58,5 @@ export DISPLAY=:0.0
57 58
 export JAVA_HOME=/cygdrive/c/Users/fcheval/AppData/Local/PortableApps/CommonFiles/Java
58 59
 export PATH=$PATH:$JAVA_HOME/bin
59 60
 
61
+# Chere variable (read by /etc/profile - important to start new shell session from current directory instead of $HOME)
62
+export CHERE_INVOKING=1
Browse code

bash_profile (cygwin) - v1.1 - Add Java variables

Fred authored on20/08/2014 10:15:02
Showing1 changed files
... ...
@@ -1,14 +1,15 @@
1 1
 # Title: .bash_profile
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.0
3
+# Version: 1.1
4 4
 # Created in: 2014-01-07
5
-# Modified in: 2014-08-11
5
+# Modified in: 2014-08-20
6 6
 
7 7
 
8 8
 #==========#
9 9
 # Versions #
10 10
 #==========#
11 11
 
12
+# v1.1 - 2014-08-20: multiscreen remove because of .screenrc set up / Java variables added
12 13
 # v1.0 - 2014-08-11: rewriting for better interplay with .bashrc
13 14
 # v0.0 - 2014-01-07: creation
14 15
 
... ...
@@ -52,8 +53,7 @@ export PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Micr
52 53
 # Set up the display variable to get an automatique display in the X server
53 54
 export DISPLAY=:0.0
54 55
 
55
-# Set up multi-screen display for mintty
56
-if [[ $(which multiscreen 2> /dev/null) ]]
57
-then
58
-	multiscreen
59
-fi
56
+# Java
57
+export JAVA_HOME=/cygdrive/c/Users/fcheval/AppData/Local/PortableApps/CommonFiles/Java
58
+export PATH=$PATH:$JAVA_HOME/bin
59
+
Browse code

bash_profile (cygwin) - v1.0 - see Versions

Fred authored on11/08/2014 17:18:55
Showing1 changed files
... ...
@@ -1,53 +1,33 @@
1
-# To the extent possible under law, the author(s) have dedicated all 
2
-# copyright and related and neighboring rights to this software to the 
3
-# public domain worldwide. This software is distributed without any warranty. 
4
-# You should have received a copy of the CC0 Public Domain Dedication along 
5
-# with this software. 
6
-# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 
1
+# Title: .bash_profile
2
+# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
+# Version: 1.0
4
+# Created in: 2014-01-07
5
+# Modified in: 2014-08-11
7 6
 
8
-# base-files version 4.1-1
9 7
 
10
-# ~/.bash_profile: executed by bash(1) for login shells.
8
+#==========#
9
+# Versions #
10
+#==========#
11 11
 
12
-# The latest version as installed by the Cygwin Setup program can
13
-# always be found at /etc/defaults/etc/skel/.bash_profile
12
+# v1.0 - 2014-08-11: rewriting for better interplay with .bashrc
13
+# v0.0 - 2014-01-07: creation
14 14
 
15
-# Modifying /etc/skel/.bash_profile directly will prevent
16
-# setup from updating it.
17 15
 
18
-# The copy in your home directory (~/.bash_profile) is yours, please
19
-# feel free to customise it to create a shell
20
-# environment to your liking.  If you feel a change
21
-# would be benifitial to all, please feel free to send
22
-# a patch to the cygwin mailing list.
23 16
 
24
-# User dependent .bash_profile file
17
+#===============================#
18
+# Get the aliases and functions #
19
+#===============================#
25 20
 
26
-# source the users bashrc if it exists
27
-if [ -f "${HOME}/.bashrc" ] ; then
28
-  source "${HOME}/.bashrc"
21
+if [[ -f ~/.bashrc ]]
22
+then
23
+	source ~/.bashrc
29 24
 fi
30 25
 
31
-# Set PATH so it includes user's private bin if it exists
32
-# if [ -d "${HOME}/bin" ] ; then
33
-#   PATH="${HOME}/bin:${PATH}"
34
-# fi
35 26
 
36
-# Set MANPATH so it includes users' private man if it exists
37
-# if [ -d "${HOME}/man" ]; then
38
-#   MANPATH="${HOME}/man:${MANPATH}"
39
-# fi
40 27
 
41
-# Set INFOPATH so it includes users' private info if it exists
42
-# if [ -d "${HOME}/info" ]; then
43
-#   INFOPATH="${HOME}/info:${INFOPATH}"
44
-# fi
45
-
46
-
47
-
48
-#=========#
49
-# Aliases #
50
-#=========#
28
+#==================#
29
+# Specific aliases #
30
+#==================#
51 31
 
52 32
 # Shortcuts for ssh operations
53 33
 alias medusa='ssh medusa'
... ...
@@ -72,3 +52,8 @@ export PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Micr
72 52
 # Set up the display variable to get an automatique display in the X server
73 53
 export DISPLAY=:0.0
74 54
 
55
+# Set up multi-screen display for mintty
56
+if [[ $(which multiscreen 2> /dev/null) ]]
57
+then
58
+	multiscreen
59
+fi
Browse code

bash_profile (cygwin) - v0.0

Fred authored on07/01/2014 17:52:24
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,74 @@
1
+# To the extent possible under law, the author(s) have dedicated all 
2
+# copyright and related and neighboring rights to this software to the 
3
+# public domain worldwide. This software is distributed without any warranty. 
4
+# You should have received a copy of the CC0 Public Domain Dedication along 
5
+# with this software. 
6
+# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 
7
+
8
+# base-files version 4.1-1
9
+
10
+# ~/.bash_profile: executed by bash(1) for login shells.
11
+
12
+# The latest version as installed by the Cygwin Setup program can
13
+# always be found at /etc/defaults/etc/skel/.bash_profile
14
+
15
+# Modifying /etc/skel/.bash_profile directly will prevent
16
+# setup from updating it.
17
+
18
+# The copy in your home directory (~/.bash_profile) is yours, please
19
+# feel free to customise it to create a shell
20
+# environment to your liking.  If you feel a change
21
+# would be benifitial to all, please feel free to send
22
+# a patch to the cygwin mailing list.
23
+
24
+# User dependent .bash_profile file
25
+
26
+# source the users bashrc if it exists
27
+if [ -f "${HOME}/.bashrc" ] ; then
28
+  source "${HOME}/.bashrc"
29
+fi
30
+
31
+# Set PATH so it includes user's private bin if it exists
32
+# if [ -d "${HOME}/bin" ] ; then
33
+#   PATH="${HOME}/bin:${PATH}"
34
+# fi
35
+
36
+# Set MANPATH so it includes users' private man if it exists
37
+# if [ -d "${HOME}/man" ]; then
38
+#   MANPATH="${HOME}/man:${MANPATH}"
39
+# fi
40
+
41
+# Set INFOPATH so it includes users' private info if it exists
42
+# if [ -d "${HOME}/info" ]; then
43
+#   INFOPATH="${HOME}/info:${INFOPATH}"
44
+# fi
45
+
46
+
47
+
48
+#=========#
49
+# Aliases #
50
+#=========#
51
+
52
+# Shortcuts for ssh operations
53
+alias medusa='ssh medusa'
54
+alias medusa2='ssh medusa2'
55
+alias mendel='ssh mendel'
56
+
57
+# Shortcut for vim
58
+alias vi='vim'
59
+
60
+# Path to Windows home
61
+alias wh="cd /cygdrive/c/Users/$USER/"
62
+
63
+
64
+
65
+#================================================#
66
+# User specific environment and startup programs #
67
+#================================================#
68
+
69
+# Personalized PATH
70
+export PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Intel/Services/IPT:/cygdrive/c/Program Files (x86)/NTRU Cryptosystems/NTRU TCG Software Stack/bin:/cygdrive/c/Program Files/NTRU Cryptosystems/NTRU TCG Software Stack/bin:/cygdrive/c/Program Files/Dell/Dell Data Protection/Access/Advanced/Wave/Gemalto/Access Client/v5:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/OEM/12.0/DLLShared:/cygdrive/c/Program Files (x86)/Roxio/OEM/AudioCore:/usr/lib/lapack:$HOME/local/bin"
71
+
72
+# Set up the display variable to get an automatique display in the X server
73
+export DISPLAY=:0.0
74
+