mirror of https://github.com/termux/termux-app
introduce a property for configuring default working directory
Issue https://github.com/termux/termux-app/issues/1192.
This commit is contained in:
parent
407e4e003a
commit
496da3f877
|
@ -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;
|
||||
|
||||
|
@ -113,7 +114,7 @@ final class TermuxPreferences {
|
|||
} catch (NumberFormatException | ClassCastException e) {
|
||||
mFontSize = defaultFontSize;
|
||||
}
|
||||
mFontSize = clamp(mFontSize, MIN_FONTSIZE, MAX_FONTSIZE);
|
||||
mFontSize = clamp(mFontSize, MIN_FONTSIZE, MAX_FONTSIZE);
|
||||
}
|
||||
|
||||
boolean toggleShowExtraKeys(Context context) {
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue