ionide/ionide-vscode-fsharp

Read ~/.bashrc When Running A .fsx Script?

eatobin opened this issue · 7 comments

Hello -

Is there a way to have your ~/.bashrc read when running a .fsx script? I'm trying to set my terminal prompt correctly and I've included a screenshot of the current output - which I'd like to change to reflect my PS1.

Thank you!

prompt

To me it looks like there is a mix happening here. Because, you are trying to setup a Powershell configuration from inside a .bashrc which is in general associated to bash and not Powershell.

I think customisation of Powershell should be done inside the $PROFILE code.

Exemple: notepad $PROFILE

https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#choose-and-apply-a-powershell-prompt-theme

@MangelMaxime Thank you - but I don't understand. Where does Powershell come in? I am on Linux (Ubuntu) and use bash. Is Powershell used by Ionide-VSCode to run a .fsx script?

Oops sorry I thought PS1 was related to PowerShell as when quickly looking at the screenshot I thought that the window I took for a window terminal (Sublime Text) looked similar to Windows Terminal.

I was probably not properly awake this morning 😅

We don't spawn the terminal ourself, it is given to use by VSCode API.

let private start () =
promise {
let ctok = vscode.CancellationTokenSource.Create().token
let! profile =
match provider.provideTerminalProfile (ctok) with
| None -> promise.Return None
| Some work -> work |> Promise.ofMaybeThenable Some
let profile =
match profile with
| Some opts -> opts
| None ->
window.showErrorMessage ("Unable to spawn FSI") |> ignore
failwith "unable to spawn FSI"
// this coercion could be to either type - TerminalOptions _or_ ExtensionTerminalOptions
// we don't actually care here so I picked the first Case on the U2 here.
let terminal = window.createTerminal (!!profile.options: TerminalOptions)
// Wait for the new terminal to be ready
let! newTerminal =
Promise.create (fun resolve reject ->
window.onDidOpenTerminal.Invoke(fun (terminal: Terminal) ->
if terminal.name = fsiNetCoreName || terminal.name = fsiNetFrameworkName then
// It can happens that a new terminal is created before the old one is closed
// In that case, we need to close the old one first
// This case occures when user invoke "FSI: Start" commands with an existing FSI terminal
match fsiTerminal with
| Some fsiOutput -> fsiOutput.dispose ()
| None -> ()
// Return the new terminal
resolve terminal
None)
|> ignore)

I don't know if there any arguments or configuration can be made for it.

@MangelMaxime Thank you. I'll just live with it. :-)

Bye.