@@ -28,33 +28,25 @@ export function addCommands(
28
28
const { commands, shell } = app ;
29
29
30
30
/**
31
- * Add open terminal and run command
32
- *
33
- * Argument 'cmd' can be passed at the execute function to specify the command to execute
31
+ * Add open terminal in the Git repository
34
32
*/
35
33
commands . addCommand ( CommandIDs . gitTerminalCommand , {
36
- label : 'Git Command in Terminal ' ,
37
- caption : 'Open a new terminal to perform git command ' ,
34
+ label : 'Open Terminal in Git Repository ' ,
35
+ caption : 'Open a New Terminal in the Git Repository ' ,
38
36
execute : async args => {
39
- let changeDirectoryCommand =
40
- model . pathRepository === null
41
- ? ''
42
- : 'cd "' + model . pathRepository . split ( '"' ) . join ( '\\"' ) + '"' ;
43
- let gitCommand = ( args [ 'cmd' ] as string ) || '' ;
44
- let linkCommand =
45
- changeDirectoryCommand !== '' && gitCommand !== '' ? '&&' : '' ;
46
-
47
37
const main = ( await commands . execute (
48
38
'terminal:create-new' ,
49
39
args
50
40
) ) as MainAreaWidget < ITerminal . ITerminal > ;
51
41
52
- const terminal = main . content ;
53
42
try {
54
- terminal . session . send ( {
55
- type : 'stdin' ,
56
- content : [ changeDirectoryCommand + linkCommand + gitCommand + '\n' ]
57
- } ) ;
43
+ if ( model . pathRepository !== null ) {
44
+ const terminal = main . content ;
45
+ terminal . session . send ( {
46
+ type : 'stdin' ,
47
+ content : [ `cd "${ model . pathRepository . split ( '"' ) . join ( '\\"' ) } "\n` ]
48
+ } ) ;
49
+ }
58
50
59
51
return main ;
60
52
} catch ( e ) {
0 commit comments