@@ -28,33 +28,25 @@ export function addCommands(
2828 const { commands, shell } = app ;
2929
3030 /**
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
3432 */
3533 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 ' ,
3836 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-
4737 const main = ( await commands . execute (
4838 'terminal:create-new' ,
4939 args
5040 ) ) as MainAreaWidget < ITerminal . ITerminal > ;
5141
52- const terminal = main . content ;
5342 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+ }
5850
5951 return main ;
6052 } catch ( e ) {
0 commit comments