mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-08 03:24:04 +08:00
introduce a property for configuring default working directory
Issue https://github.com/termux/termux-app/issues/1192.
This commit is contained in:
@@ -652,7 +652,14 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
.setPositiveButton(android.R.string.ok, null).show();
|
.setPositiveButton(android.R.string.ok, null).show();
|
||||||
} else {
|
} else {
|
||||||
TerminalSession currentSession = getCurrentTermSession();
|
TerminalSession currentSession = getCurrentTermSession();
|
||||||
String workingDirectory = (currentSession == null) ? null : currentSession.getCwd();
|
|
||||||
|
String workingDirectory;
|
||||||
|
if (currentSession == null) {
|
||||||
|
workingDirectory = mSettings.mDefaultWorkingDir;
|
||||||
|
} else {
|
||||||
|
workingDirectory = currentSession.getCwd();
|
||||||
|
}
|
||||||
|
|
||||||
TerminalSession newSession = mTermService.createTermSession(null, null, workingDirectory, failSafe);
|
TerminalSession newSession = mTermService.createTermSession(null, null, workingDirectory, failSafe);
|
||||||
if (sessionName != null) {
|
if (sessionName != null) {
|
||||||
newSession.mSessionName = sessionName;
|
newSession.mSessionName = sessionName;
|
||||||
|
@@ -78,6 +78,7 @@ final class TermuxPreferences {
|
|||||||
boolean mBackIsEscape;
|
boolean mBackIsEscape;
|
||||||
boolean mDisableVolumeVirtualKeys;
|
boolean mDisableVolumeVirtualKeys;
|
||||||
boolean mShowExtraKeys;
|
boolean mShowExtraKeys;
|
||||||
|
String mDefaultWorkingDir;
|
||||||
|
|
||||||
ExtraKeysInfos mExtraKeys;
|
ExtraKeysInfos mExtraKeys;
|
||||||
|
|
||||||
@@ -227,6 +228,14 @@ final class TermuxPreferences {
|
|||||||
mUseFullScreenWorkAround = false;
|
mUseFullScreenWorkAround = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaultWorkingDir = props.getProperty("default-working-directory", TermuxService.HOME_PATH);
|
||||||
|
File workDir = new File(mDefaultWorkingDir);
|
||||||
|
if (!workDir.exists() || !workDir.isDirectory()) {
|
||||||
|
// Fallback to home directory if user configured working directory is not exist
|
||||||
|
// or is a regular file.
|
||||||
|
mDefaultWorkingDir = TermuxService.HOME_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
String defaultExtraKeys = "[[ESC, TAB, CTRL, ALT, {key: '-', popup: '|'}, DOWN, UP]]";
|
String defaultExtraKeys = "[[ESC, TAB, CTRL, ALT, {key: '-', popup: '|'}, DOWN, UP]]";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user