@@ -71,6 +71,22 @@ export const programmingLanguages: languageMap = {
71
71
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
72
72
}
73
73
74
+ const commonShells = [
75
+ 'sh' ,
76
+ 'bash' ,
77
+ 'zsh' ,
78
+ 'fish' ,
79
+ 'csh' ,
80
+ 'tcsh' ,
81
+ 'ksh' ,
82
+ 'dash' ,
83
+ 'cmd' ,
84
+ 'powershell' ,
85
+ 'pwsh' ,
86
+ 'shell'
87
+ // add more common shells here
88
+ ]
89
+
74
90
export const generateRandomString = ( length : number , lowercase = false ) => {
75
91
const chars = 'ABCDEFGHJKLMNPQRSTUVWXY3456789' // excluding similar looking characters like Z, 2, I, 1, O, 0
76
92
let result = ''
@@ -102,7 +118,7 @@ const CodeBlock: FC<CodeBlockProps> = memo(
102
118
}
103
119
104
120
const onRunCommand = ( ) => {
105
- if ( runShell && language === 'bash' ) {
121
+ if ( runShell && commonShells . includes ( language . toLowerCase ( ) ) ) {
106
122
runShell ( value )
107
123
}
108
124
}
@@ -115,7 +131,7 @@ const CodeBlock: FC<CodeBlockProps> = memo(
115
131
< div className = "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100" >
116
132
< span className = "text-xs lowercase" > { language } </ span >
117
133
< div className = "flex items-center space-x-1" >
118
- { runShell && language === 'bash' && (
134
+ { runShell && commonShells . includes ( language . toLowerCase ( ) ) && (
119
135
< Tooltip >
120
136
< TooltipTrigger asChild >
121
137
< Button
@@ -152,7 +168,7 @@ const CodeBlock: FC<CodeBlockProps> = memo(
152
168
) }
153
169
{ supportsOnApplyInEditorV2 &&
154
170
onApplyInEditor &&
155
- ! ( runShell && language === 'bash' ) && (
171
+ ! ( runShell && commonShells . includes ( language . toLowerCase ( ) ) ) && (
156
172
< Tooltip >
157
173
< TooltipTrigger asChild >
158
174
< Button
@@ -175,24 +191,25 @@ const CodeBlock: FC<CodeBlockProps> = memo(
175
191
</ TooltipContent >
176
192
</ Tooltip >
177
193
) }
178
- { onApplyInEditor && ! ( runShell && language === 'bash' ) && (
179
- < Tooltip >
180
- < TooltipTrigger asChild >
181
- < Button
182
- variant = "ghost"
183
- size = "icon"
184
- className = "text-xs hover:bg-[#3C382F] hover:text-[#F4F4F5] focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
185
- onClick = { ( ) => onApplyInEditor ( value , undefined ) }
186
- >
187
- < IconApplyInEditor />
188
- < span className = "sr-only" > Apply in Editor</ span >
189
- </ Button >
190
- </ TooltipTrigger >
191
- < TooltipContent >
192
- < p className = "m-0" > Apply in Editor</ p >
193
- </ TooltipContent >
194
- </ Tooltip >
195
- ) }
194
+ { onApplyInEditor &&
195
+ ! ( runShell && commonShells . includes ( language . toLowerCase ( ) ) ) && (
196
+ < Tooltip >
197
+ < TooltipTrigger asChild >
198
+ < Button
199
+ variant = "ghost"
200
+ size = "icon"
201
+ className = "text-xs hover:bg-[#3C382F] hover:text-[#F4F4F5] focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
202
+ onClick = { ( ) => onApplyInEditor ( value , undefined ) }
203
+ >
204
+ < IconApplyInEditor />
205
+ < span className = "sr-only" > Apply in Editor</ span >
206
+ </ Button >
207
+ </ TooltipTrigger >
208
+ < TooltipContent >
209
+ < p className = "m-0" > Apply in Editor</ p >
210
+ </ TooltipContent >
211
+ </ Tooltip >
212
+ ) }
196
213
< Tooltip >
197
214
< TooltipTrigger asChild >
198
215
< Button
0 commit comments