Announcement

Collapse
No announcement yet.

Konsole command -e How to get to the Dollar prompt

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Konsole command -e How to get to the Dollar prompt

    Kubuntu 18.04.01.

    If I enter:
    Code:
    Code:
    konsole --separate --hold --workdir /
    I get a new Konsole window with the cursor positioned to the right of the Dollar prompt, as expected at the root directory.

    If I type this command:
    Code:
    Code:
    konsole --separate --hold --workdir / -e ls
    it gives the expected output but no Dollar prompt.

    So my question is how to modify the 2nd command to produce the output and then present the Dollar prompt.

    #2
    konsole -e runs a command instead of a shell (which gives the prompt). So the -e has to run ls and a shell. One way to do this would be
    Code:
    konsole --separate --hold --workdir / -e "$SHELL -c 'ls;$SHELL'"
    I'm scratching my head as to why you'd want to do that.

    Better maybe, to get away from the tricky quoting issues, and make it more flexible, would be to make a script, called, say, lssh, with
    Code:
    #!/bin/bash
    ls
    exec $SHELL
    chmod +x lssh and put it somewhere in your $PATH, then use -e lssh
    Regards, John Little

    Comment


      #3
      @jlittle, thank you very much for your reply. The "ls" example I gave is just for simplicity, getting the dollar prompt was the important thing. What I am doing is creating a desktop launcher for a CLI only windows program I need to run with wine. Just running a 1 liner from the launcher I find to be preferable to creating a script so I went with:
      Code:
      Exec=konsole --separate --hold --workdir ~/.wine -e bash -c "WINEPREFIX=~/.wine/eac3to wine cmd"
      which puts me in a new window at the z: prompt.

      Another application is to use a script with K-shutdown that displays the the command to cancel it in a new window, ready to go. Good for when I am half asleep and watching the news.

      As an aside, the --separate option, the console reference book https://docs.kde.org/trunk5/en/appli...e-options.html states:

      --separate, --noforkRun the new instance of Konsole in a separate process.

      Should this be interpreted as running the process in a new shell?

      Comment


        #4
        Originally posted by shag00 View Post
        As an aside, the --separate option, the console reference book https://docs.kde.org/trunk5/en/appli...e-options.html states:

        --separate, --noforkRun the new instance of Konsole in a separate process.

        Should this be interpreted as running the process in a new shell?
        No. For efficiency with multiple konsole windows it is supposed to run with one instance managing all the windows, and with --nofork you get an independent process. (I say "supposed" because without --nofork I still get lots of processes.) There's still a new shell running in each window. Shells achieve efficiency for lots of them in other ways, though some are better at it than others; IME multiple zsh instances are slower than multiple bash ones (only relevant if you start many of them, dozens or hundreds, like some people do tabs in a browser).
        Regards, John Little

        Comment


          #5
          Originally posted by jlittle View Post
          No. For efficiency with multiple konsole windows it is supposed to run with one instance managing all the windows, and with --nofork you get an independent process. (I say "supposed" because without --nofork I still get lots of processes.) There's still a new shell running in each window. Shells achieve efficiency for lots of them in other ways, though some are better at it than others; IME multiple zsh instances are slower than multiple bash ones (only relevant if you start many of them, dozens or hundreds, like some people do tabs in a browser).
          OK thanks, that's what I found as well.

          Comment

          Working...
          X