@@ -31,6 +31,7 @@ Table of contents
31
31
- [ ` Sign ` car] ( #sign-car )
32
32
- [ ` Status ` car] ( #status-car )
33
33
- [ ` Time ` car] ( #time-car )
34
+ - [ Prompt forwarding via SSH] ( #prompt-forwarding-via-ssh )
34
35
- [ Author] ( #author )
35
36
- [ License] ( #license )
36
37
@@ -1225,6 +1226,39 @@ Car that displays current date and time.
1225
1226
Custom separator string for this car.
1226
1227
1227
1228
1229
+ Prompt forwarding via SSH
1230
+ -------------------------
1231
+
1232
+ It's possible to use GBT to generate prompt string and forward it to remote
1233
+ server via SSH so we can have GBT-like prompt also in the remote shell. The
1234
+ main limitation is that the text of the cars can only be dynamic if only prompt
1235
+ [ escape sequences] ( http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html )
1236
+ recognized by the remote shell are used.
1237
+
1238
+ As most of the remote servers have Bash as their default shell, we need to
1239
+ create Bash-compatible ` PS1 ` string.
1240
+
1241
+ ``` shell
1242
+ # Create file which we will use to configure the output of locally executed GBT
1243
+ # as the `PS1` for the remote server. Notice that we are using Bash escape
1244
+ # sequences as the text content of the cars (e.g. \u for the user name).
1245
+ cat << END > ~/.gbt.ssh
1246
+ export GBT_CARS='Os, Time, Hostname, Dir, Sign'
1247
+ export GBT_CAR_OS_NAME='cloud'
1248
+ export GBT_CAR_TIME_FORMAT=' \t '
1249
+ export GBT_CAR_HOSTNAME_USER_TEXT='\u'
1250
+ export GBT_CAR_HOSTNAME_HOST_TEXT='\h'
1251
+ export GBT_CAR_DIR_DIR_TEXT='\W'
1252
+ export GBT_CAR_SIGN_SYMBOL_FORMAT='\\\$ '
1253
+ export GBT_SHELL='_bash'
1254
+ END
1255
+ # Then we can tell SSH to execute remote command which consists of locally
1256
+ # generated GBT output, which is written into a file on the remote server, and
1257
+ # the Bash command which loads that generated file as its RC file:
1258
+ ssh $@ -t " echo \" PS1='$( source ~ /.gbt.ssh; gbt) '\" > ~/.myprompt; bash --rcfile ~/.myprompt -i"
1259
+ ```
1260
+
1261
+
1228
1262
Author
1229
1263
------
1230
1264
0 commit comments