mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 22:44:55 +00:00
open SFTP panel in the CWD
This commit is contained in:
@@ -268,16 +268,17 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
this.bellPlayer = document.createElement('audio')
|
||||
this.bellPlayer.src = require('../bell.ogg').default
|
||||
|
||||
this.contextMenuProviders.sort((a, b) => a.weight - b.weight)
|
||||
|
||||
this.pinToolbar = this.enableToolbar && (window.localStorage.pinTerminalToolbar ?? 'true') === 'true'
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
ngOnInit (): void {
|
||||
this.pinToolbar = this.enableToolbar && (window.localStorage.pinTerminalToolbar ?? 'true') === 'true'
|
||||
|
||||
this.focused$.subscribe(() => {
|
||||
this.configure()
|
||||
this.frontend?.focus()
|
||||
|
37
tabby-terminal/src/api/osc1337Processing.ts
Normal file
37
tabby-terminal/src/api/osc1337Processing.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as os from 'os'
|
||||
import { Subject, Observable } from 'rxjs'
|
||||
|
||||
const OSC1337Prefix = Buffer.from('\x1b]1337;')
|
||||
const OSC1337Suffix = Buffer.from('\x07')
|
||||
|
||||
export class OSC1337Processor {
|
||||
get cwdReported$ (): Observable<string> { return this.cwdReported }
|
||||
|
||||
private cwdReported = new Subject<string>()
|
||||
|
||||
process (data: Buffer): Buffer {
|
||||
if (data.includes(OSC1337Prefix)) {
|
||||
const preData = data.subarray(0, data.indexOf(OSC1337Prefix))
|
||||
const params = data.subarray(data.indexOf(OSC1337Prefix) + OSC1337Prefix.length)
|
||||
const postData = params.subarray(params.indexOf(OSC1337Suffix) + OSC1337Suffix.length)
|
||||
const paramString = params.subarray(0, params.indexOf(OSC1337Suffix)).toString()
|
||||
|
||||
if (paramString.startsWith('CurrentDir=')) {
|
||||
let reportedCWD = paramString.split('=')[1]
|
||||
if (reportedCWD.startsWith('~')) {
|
||||
reportedCWD = os.homedir() + reportedCWD.substring(1)
|
||||
}
|
||||
this.cwdReported.next(reportedCWD)
|
||||
} else {
|
||||
console.debug('Unsupported OSC 1337 parameter:', paramString)
|
||||
}
|
||||
|
||||
data = Buffer.concat([preData, postData])
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.cwdReported.complete()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user