a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

.bashrc and source command

Open iansinnott opened this issue 5 years ago • 15 comments

Hey, I’m wondering if it’s currently possible to create aliases. I added a .bashrc file and a .profile file and neither one seems to get sourced when I open the app. There is also no source command available.

Just wondering if I’m missing something or if this is currently not possible. Thanks!

iansinnott avatar Apr 27 '20 01:04 iansinnott

You did not miss anything. It is currently not possible to add aliases, but it's on the todo list.

holzschu avatar Apr 27 '20 06:04 holzschu

Is bash even available? If I execute echo $SHELL, a-shell prints /bin/sh.

Related question: What kind of shebang should we then put into shell scripts that go into one of the bin directories? #!/bin/sh?

JayBrown avatar May 01 '20 15:05 JayBrown

No, bash is not available. a-shell pretends to run /bin/sh, but is not actually running it (because coding that would be even harder, and for performance reasons). "Running a full shell" is on the TODO list, but it's a distant goal (see https://github.com/holzschu/a-shell/projects/1 ). Although the recent introduction of webAssembly might change that.

Shell scripts in the bin directory are not executed (I'd love to, but that is still too difficult), but python, lua and webAssembly files are executed. Since there are no real path for executable, the shebang rule is: "begins with "#!" and "contains the interpreter name".

holzschu avatar May 01 '20 15:05 holzschu

Oh damn… I thought I could just throw in some nice shell scripts. ;)

JayBrown avatar May 01 '20 15:05 JayBrown

Hi, just an update. With version 1.5:

  • the ".profile" file is now executed at the beginning of each session (if it exists).
  • a-Shell can be controlled with Shortcuts, and shortcuts can take a file (with a list of commands) as input; they can also have "if" branches and "for" loops.

On the other hand:

  • there are still no way to alias a command to another,
  • and still no way to execute shell programs from inside the App.

holzschu avatar Jun 07 '20 19:06 holzschu

Hi, another update. With version 1.6.6, we now have "alias".

holzschu avatar Jan 25 '21 11:01 holzschu

Hi, another update. With version 1.6.6, we now have "alias".

I created an alias for ls which works great however an alias for vi to vim does not. The file opens in vim however the key bindings seem broken. I have not been able to figure out how to exit in this state so have to kill a-shell. Any ideas what might be happening in this case?

tompropst avatar Apr 24 '21 14:04 tompropst

Ah, yes, that makes sense. There are two types of commands: "interactive" commands, that listen to stdin continuously, and "standard" commands, that listen to stdin once you press enter. The former is: less, more, vim, ssh, scp, ipython, man, the latter is anyone else. The detection is made based on the command name, so since vi is not in the list, it's not interactive (you could, maybe, escape vi by typing :wq + Enter).

I don't have a short-term fix for that. In implementing sftp, I've had the first command that changes state (starts as interactive for password entering, until you're connected, then becomes standard). I could probably revert that for aliases to interactive commands.

Update: alias vi vim now works.

holzschu avatar Apr 24 '21 14:04 holzschu

Just a little question for .profile : It's normally vim ~/.profile to create and open it ? Because when I want to write to it I have "Can't open file for writing" when I try to save.

Mara-Li avatar Sep 17 '21 08:09 Mara-Li

One specificity of iOS is that you cannot write in ~, only in ~/Documents. So all configuration files, including .profile, have been moved to ~/Documents. It's ~/Documents/.profile, ~/Documents/.vimrc, ~/Documents/.ssh, etc.

holzschu avatar Sep 17 '21 08:09 holzschu

Okay ! Thank you a lot :)

Mara-Li avatar Sep 17 '21 14:09 Mara-Li

Okay, little update. I try to set an alias with alias key=command but it doesn't seem to work. I also try alias key command, but I have the same result. What I am doing wrong ?

Mara-Li avatar Sep 17 '21 18:09 Mara-Li

Both syntax should work. Two questions: does it work in the terminal and fail in the .profile, and can you provide the actual command you tried?

holzschu avatar Sep 18 '21 05:09 holzschu

Okay, I retry today on my IPAD (Ipad OS15) and, now, the alias work ! So thank you !

Mara-Li avatar Sep 18 '21 21:09 Mara-Li

It seems that now both source command and alias work, so maybe this issue is ripe for closing?

Note that . does not work with the standard shell, while in contrast dash uses . and not source. It seems that . is POSIX and source is not. https://stackoverflow.com/questions/11588583/is-the-shells-source-posix-standard

bjornbm avatar Mar 04 '25 13:03 bjornbm