mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 18:55:31 +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();
|
||||
} else {
|
||||
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);
|
||||
if (sessionName != null) {
|
||||
newSession.mSessionName = sessionName;
|
||||
|
@@ -78,6 +78,7 @@ final class TermuxPreferences {
|
||||
boolean mBackIsEscape;
|
||||
boolean mDisableVolumeVirtualKeys;
|
||||
boolean mShowExtraKeys;
|
||||
String mDefaultWorkingDir;
|
||||
|
||||
ExtraKeysInfos mExtraKeys;
|
||||
|
||||
@@ -227,6 +228,14 @@ final class TermuxPreferences {
|
||||
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]]";
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user