Preference: Fix initial command

This commit is contained in:
zt515 2017-12-07 23:55:30 +08:00
parent c127ad172d
commit f01b75d5dd
3 changed files with 17 additions and 8 deletions

View File

@ -166,7 +166,7 @@ object NeoPreference {
shellSymlink.delete()
}
Os.symlink(loginProgramPath, NeoTermPath.NEOTERM_SHELL_PATH)
Os.chmod(NeoTermPath.NEOTERM_SHELL_PATH, 448 /*Decimal of 0700 */)
Os.chmod(NeoTermPath.NEOTERM_SHELL_PATH, 448 /* Decimal of 0700 */)
} catch (e: ErrnoException) {
NLog.e("Preference", "Failed to symlink login shell: ${e.localizedMessage}")
e.printStackTrace()
@ -182,6 +182,14 @@ object NeoPreference {
return loadInt(NeoPreference.KEY_FONT_SIZE, DefaultPreference.fontSize)
}
fun getInitialCommand(): String {
return loadString(R.string.key_general_initial_command, DefaultPreference.initialCommand)
}
fun isEnableBell(): Boolean {
return loadBoolean(R.string.key_general_bell, DefaultPreference.enableBell)
}
// fun storeWindowSize(context: Context, width: Int, height: Int) {
// store(KEY_FLOATING_WIDTH, width)
@ -190,7 +198,7 @@ object NeoPreference {
//
// fun storeWindowLocation(context: Context, x: Int, y: Int) {
// store(KEY_FLOATING_WINDOW_X, x)
// store(KEY_FLOATING_WINDOW_Y, y)
// store(KEY_FLOATING_WINDOW_Y, y)Se
// }
//
// fun applySavedWindowParameter(context: Context, layout: WindowManager.LayoutParams) {

View File

@ -30,5 +30,7 @@ class ShellProfile {
profileColorScheme = colorComp.getCurrentColorSchemeName()
loginShell = NeoPreference.getLoginShellPath()
initialCommand = NeoPreference.getInitialCommand()
enableBell = NeoPreference.isEnableBell()
}
}

View File

@ -16,10 +16,9 @@ import java.io.File
open class ShellTermSession private constructor(shellPath: String, cwd: String,
args: Array<String>, env: Array<String>,
changeCallback: SessionChangedCallback,
shellProfile: ShellProfile)
private val shellProfile: ShellProfile)
: TerminalSession(shellPath, cwd, args, env, changeCallback) {
var initialCommand: String? = null
var exitPrompt = App.get().getString(R.string.process_exit_prompt)
override fun initializeEmulator(columns: Int, rows: Int) {
@ -47,8 +46,8 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
}
private fun sendInitialCommand() {
val initCommand = initialCommand
if (initCommand != null && initCommand.isNotEmpty()) {
val initCommand = shellProfile.initialCommand
if (initCommand.isNotEmpty()) {
write(initCommand + '\r')
}
}
@ -168,8 +167,8 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
}
val result = mutableListOf<String>()
env.mapTo(result, { "${it.first}=${it.second}" })
return result.toTypedArray()
return env.mapTo(result, { "${it.first}=${it.second}" })
.toTypedArray()
}