celljilo.blogg.se

Service open in terminal
Service open in terminal








service open in terminal
  1. #Service open in terminal manual#
  2. #Service open in terminal code#

I mean regardless if ~/ gets expanded before foot runs, or by foot (I totally don't know if foot even tries), or by our special-purpose bash, it should work. This means you can use the above (or similar) command even in a context where tilde expansion does not occur. If bash gets ~/ inside the option-argument to -rcfile, it will expand it on its own.

service open in terminal

(I use konsole and in my case it is konsole -e bash -rcfile ….) Judging solely by what you posted, I say the command may be: foot bash -rcfile ~/.single_command_bashrc You need to tell your terminal emulator to run bash -rcfile ~/.single_command_bashrc. I could achieve a similar result just by adding false at the end of ~/.single_command_bashrc, but if for any reason set -e would be active at the time, then this false would make the shell exit prematurely. Because before the first prompt there's also a successful command, the helper variable named BASH_LATE_ENOUGH is used to make sure exit is not performed before the very first prompt.

#Service open in terminal code#

The code makes the shell exit just before it would otherwise print the prompt after a successful command. Inside this Bash the shell code stored in PROMPT_COMMAND will be executed every time a prompt is about to be printed. Now if you run bash -rcfile ~/.single_command_bashrc then the newly opened interactive Bash will source /etc/bash.bashrc and ~/.bashrc (like interactive Bash invoked without -rcfile would) but additionally it will configure itself to do what you want.

service open in terminal

To exit conditionally you need something more complex.Ĭreate a file ~/.single_command_bashrc and put the following code in it: if then bash -t exits regardless of the exit status of the command. This answer uses Bash.īash -t exits after reading and executing one command, possibly complex command, one command "line" that may be quite a huge (and even multi-line) piece of shell code. Shell also insists on interpreting line embedded \ characters, unless -r is also specified, thus we do that.Įven then, you will have problems with shell's stupid auto-splitting on arguments with spaces, typed directly into the read command input.īut I hope my snippet is sufficient for your purposes. Shell insists on always splitting the line read into multiple variables by $IFS characters, so IFS="" code tries to prevent that (there are corner cases when shell will split anyway because it's stupid). Unfortunately shell is really bad "reader" or rather shell's read is really shitty general line editor. So I would do something like this: $ cat test.shĮxec foot sh -c "IFS=\"\" read -p \"Type in a command:\" -r line_input exec \$" Third, you need to read-in the line to execute, and then to replace the foot invoked shell with your command/line.

#Service open in terminal manual#

Second read up dash(1) manual page about read builtin (I hope you are using dash, if you are aiming for proper sh, bash is unreliable to be used as sh, it simply cannot follow POSIX standard emulation). In urxvt the invocation sequence would be urxvt -e command args.įirst problem you have that is not how read shell builtin works! I assume foot is your terminal emulator and it accepts command as-is as arguments.










Service open in terminal