You can achieve something similar by abusing the --rcfile
option:
bash --rcfile <(echo "export PS1='> ' && ls")
From bash manpage:
–rcfile file
Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive
Related Contents:
- Command substitution: backticks or dollar sign / paren enclosed? [duplicate]
- Bash conditional based on exit code of command
- How do I check if a directory exists or not in a Bash shell script?
- Run one command after another, even if I suspend the first one (Ctrl-z)
- Correct Bash and shell script variable capitalization
- How can I debug a Bash script? [closed]
- What is the difference between $(command) and `command` in shell programming?
- Reading quoted/escaped arguments correctly from a string
- When do we need curly braces around shell variables?
- Can I export a variable to the environment from a Bash script without sourcing it?
- Can a shell script set environment variables of the calling shell? [duplicate]
- How to store standard error in a variable
- How to convert a string to lower case in Bash?
- Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
- How can I compare numbers in Bash?
- How can I detect if my shell script is running through a pipe?
- Capture stdout and stderr into different variables
- How do I escape the wildcard/asterisk character in bash?
- Ubuntu says “bash: ./program Permission denied” [closed]
- How to echo shell commands as they are executed
- Checking from shell script if a directory contains files
- How to reload .bashrc settings without logging out and back in again?
- Exit Shell Script Based on Process Exit Code [duplicate]
- Count occurrences of a char in a string using Bash
- How to split one string into multiple strings separated by at least one space in bash shell?
- Get current directory name (without full path) in a Bash script
- Escape dollar sign in string by shell script
- What does the Bash operator
- Test if a command outputs an empty string
- Remove duplicate entries in a Bash script [duplicate]
- Use sed to replace all backslashes with forward slashes
- Can colorized output be captured via shell redirect? [duplicate]
- Variable expansion is different in zsh from that in bash
- Why start a shell command with a backslash?
- How to pass in password to pg_dump?
- How to parse a CSV in a Bash script?
- printf in bash: “09” and “08” are invalid numbers, “07” and “06” are fine
- Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?
- How can you run a command in bash over and over until success?
- What does “export” do in shell programming? [duplicate]
- What is the most elegant way to remove a path from the $PATH variable in Bash?
- How to schedule to run first Sunday of every month
- Variables as commands in Bash scripts
- Execute command containing quotes from shell variable [duplicate]
- Hexadecimal To Decimal in Shell Script
- How to kill all subprocesses of shell?
- Passing arguments by reference
- Is there an elegant way to store and evaluate return values in bash scripts?
- Subtract two variables in Bash
- Convert Unix timestamp to a date string