mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Add preserveCWD option
This commit is contained in:
parent
cc550b7c73
commit
f79006bae1
4 changed files with 19 additions and 3 deletions
|
|
@ -163,6 +163,9 @@ module.exports = {
|
|||
// set to true to enable screen reading apps (like NVDA) to read the contents of the terminal
|
||||
screenReaderMode: false,
|
||||
|
||||
// set to true to preserve working directory when creating splits or tabs
|
||||
preserveCWD: true,
|
||||
|
||||
// for advanced config flags please refer to https://hyper.is/#cfg
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
|
|||
import {decorateSessionOptions, decorateSessionClass} from '../plugins';
|
||||
import {enable as remoteEnable} from '@electron/remote/main';
|
||||
import {configOptions} from '../../lib/config';
|
||||
import {getWorkingDirectoryFromPID} from 'native-process-working-directory';
|
||||
|
||||
export function newWindow(
|
||||
options_: BrowserWindowConstructorOptions,
|
||||
|
|
@ -129,10 +130,21 @@ export function newWindow(
|
|||
if (extraOptions[key] !== undefined) extraOptionsFiltered[key] = extraOptions[key];
|
||||
});
|
||||
|
||||
let cwd = '';
|
||||
if (cfg.preserveCWD === undefined || cfg.preserveCWD) {
|
||||
const activePID = extraOptionsFiltered.activeUid && sessions.get(extraOptionsFiltered.activeUid)?.pty?.pid;
|
||||
try {
|
||||
cwd = activePID && getWorkingDirectoryFromPID(activePID);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
cwd = cwd && isAbsolute(cwd) ? cwd : '';
|
||||
}
|
||||
|
||||
// remove the rows and cols, the wrong value of them will break layout when init create
|
||||
const defaultOptions = Object.assign(
|
||||
{
|
||||
cwd: workingDirectory,
|
||||
cwd: cwd || workingDirectory,
|
||||
splitDirection: undefined,
|
||||
shell: cfg.shell,
|
||||
shellArgs: cfg.shellArgs && Array.from(cfg.shellArgs)
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ export function requestTermGroup(activeUid: string) {
|
|||
dispatch({
|
||||
type: TERM_GROUP_REQUEST,
|
||||
effect: () => {
|
||||
const {ui} = getState();
|
||||
const {ui, sessions} = getState();
|
||||
const {cwd} = ui;
|
||||
rpc.emit('new', {
|
||||
isNewGroup: true,
|
||||
cwd,
|
||||
activeUid
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
1
lib/config.d.ts
vendored
1
lib/config.d.ts
vendored
|
|
@ -50,6 +50,7 @@ export type configOptions = {
|
|||
cmdIsMeta: boolean;
|
||||
};
|
||||
padding: string;
|
||||
preserveCWD: boolean;
|
||||
quickEdit: boolean;
|
||||
screenReaderMode: boolean;
|
||||
scrollback: number;
|
||||
|
|
|
|||
Loading…
Reference in a new issue