diff --git a/tabby-core/src/api/profileProvider.ts b/tabby-core/src/api/profileProvider.ts index 33433054..7f592720 100644 --- a/tabby-core/src/api/profileProvider.ts +++ b/tabby-core/src/api/profileProvider.ts @@ -46,6 +46,10 @@ export abstract class ProfileProvider

{ abstract getNewTabParameters (profile: PartialProfile

): Promise> + getSuggestedName (profile: PartialProfile

): string|null { + return null + } + abstract getDescription (profile: PartialProfile

): string quickConnect (query: string): PartialProfile

|null { diff --git a/tabby-local/src/profiles.ts b/tabby-local/src/profiles.ts index 4849e968..07b02888 100644 --- a/tabby-local/src/profiles.ts +++ b/tabby-local/src/profiles.ts @@ -84,6 +84,10 @@ export class LocalProfilesService extends ProfileProvider { } } + getSuggestedName (profile: LocalProfile): string { + return this.getDescription(profile) + } + getDescription (profile: PartialProfile): string { return profile.options?.command ?? '' } diff --git a/tabby-serial/src/profiles.ts b/tabby-serial/src/profiles.ts index b5457ea7..4be40151 100644 --- a/tabby-serial/src/profiles.ts +++ b/tabby-serial/src/profiles.ts @@ -8,6 +8,7 @@ import { SerialProfileSettingsComponent } from './components/serialProfileSettin import { SerialTabComponent } from './components/serialTab.component' import { SerialService } from './services/serial.service' import { BAUD_RATES, SerialProfile } from './api' +import { profileEnd } from 'console' @Injectable({ providedIn: 'root' }) export class SerialProfilesService extends ProfileProvider { @@ -92,6 +93,10 @@ export class SerialProfilesService extends ProfileProvider { } } + getSuggestedName (profile: SerialProfile): string { + return this.getDescription(profile) + } + getDescription (profile: SerialProfile): string { return profile.options.port } diff --git a/tabby-settings/src/components/profilesSettingsTab.component.ts b/tabby-settings/src/components/profilesSettingsTab.component.ts index 58772eb3..06f2de00 100644 --- a/tabby-settings/src/components/profilesSettingsTab.component.ts +++ b/tabby-settings/src/components/profilesSettingsTab.component.ts @@ -63,12 +63,20 @@ export class ProfilesSettingsTabComponent extends BaseComponent { })), ) } - const profile = deepClone(base) - profile.id = null - profile.name = `${profile.name} copy` + const profile: PartialProfile = deepClone(base) + delete profile.id + if (base.isTemplate) { + profile.name = '' + } else if (!base.isBuiltin) { + profile.name = `${base.name} copy` + } profile.isBuiltin = false profile.isTemplate = false await this.editProfile(profile) + if (!profile.name) { + const cfgProxy = this.profilesService.getConfigProxyForProfile(profile) + profile.name = this.profilesService.providerForProfile(profile)?.getSuggestedName(cfgProxy) ?? `${base.name} copy` + } profile.id = `${profile.type}:custom:${slugify(profile.name)}:${uuidv4()}` this.config.store.profiles = [profile, ...this.config.store.profiles] await this.config.save() diff --git a/tabby-ssh/src/profiles.ts b/tabby-ssh/src/profiles.ts index fe607dfd..4dbf66be 100644 --- a/tabby-ssh/src/profiles.ts +++ b/tabby-ssh/src/profiles.ts @@ -81,6 +81,10 @@ export class SSHProfilesService extends ProfileProvider { } } + getSuggestedName (profile: SSHProfile): string { + return `${profile.options.user}@${profile.options.host}:${profile.options.port}` + } + getDescription (profile: PartialProfile): string { return profile.options?.host ?? '' } diff --git a/tabby-telnet/src/profiles.ts b/tabby-telnet/src/profiles.ts index 5089fd63..588b8eda 100644 --- a/tabby-telnet/src/profiles.ts +++ b/tabby-telnet/src/profiles.ts @@ -62,6 +62,10 @@ export class TelnetProfilesService extends ProfileProvider { } } + getSuggestedName (profile: TelnetProfile): string|null { + return this.getDescription(profile) || null + } + getDescription (profile: TelnetProfile): string { return profile.options.host ? `${profile.options.host}:${profile.options.port}` : '' }