How do I run an interpreter with command history support? - linux

I know there is a way to run an interactive console with command history support (even though the program does not inherently support it). However, I don't remember the command. Can anyone help me?

Try ledit.
E.g.
$ ledit mycommand

Install the package rlwrap and run it like
$ rlwrap foo
to get command line history for the command foo.

Related

Using 'help' for Linux commands on Git for Windows BASH

I installed Git for Windows. The available help in the BASH terminal gives me help only for Git commands.
$ help
$ man and
$ info
DO NOT WORK.
Entering $ help gets me a long list of things, but none of the underlying Linux commands. Here's the entire 'L' section from $ help:
let arg [arg ...]
local [option] name[=value] ...
logout [n]
I'm sure I can look up an online reference of linux commands and keep that open while using BASH. But it would be awfully handy if I could I could type $ man ls and actually get something useful instead of
bash: man: command not found
Anyone know if there's a simple way to sort of add that in to the Git for Windows application? Or if there's another tool that's as easy to use on Windows that has the feature built in? I'm not very tech savvy, but I'm very, very slowly warming up.

Can't run ghci in Terminal

every time I type ghci into the terminal or a command I would execute through ghci it tells me zsh: command not found: ghci.
I'm super new to this and don't really know what to do?
Commands like cd and so on that are for the items on my Mac work just fine.
It sounds like bash was your shell when you installed GHC, but Apple later switched you to zsh. The problem is that it was only added to your path for bash. Look for a line in ~./bashrc or ~/.bash_profile that looks something like this:
[ -f "${GHCUP_INSTALL_BASE_PREFIX:=$HOME}/.ghcup/env" ] && source "${GHCUP_INSTALL_BASE_PREFIX:=$HOME}/.ghcup/env"
It might not look quite like that, but the important part is the reference to .ghcup/env. Once you find that line, copy it and add it to the end of ~/.zshrc. Then restart your shell and try again.
Here's the GUI version of it.
Open Ghcup GUI with the command
ghcup tui
You would notice something like this
GCHUP GUI:
For me when the ghc or ghci command was not working, there was a single tick beside GHC option.
Go to that option and press s to set. It worked for me.
You could try wirte . ~/.ghcup/env in the ~/.zshrc file. Another thing is restarting the terminal.

Vim + zshell, "zsh suspended" after running a Vim external command

Vim newbie here (has worked with zsh for a few months now). I think I install too many dotfiles or have a wrong configuration because whenever I attempt an external command (even thing such as :!rm TEST, Vim exits with a message zsh: suspended (tty output) vim .. How do I fix this?
The dotfiles: https://github.com/daryllxd/dotfiles. (I got them from someone else).
Try to comment this out:
set shellcmdflag=-ci
If this doesn't work for you look at the following.
From the manual:
Commands are first read from /etc/zshenv; this cannot be overridden.
[...]
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a
login shell, commands are read from /etc/zprofile and then
$ZDOTDIR/.zprofile. Then, if the shell is interactive,
commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally,
if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are
read.
From what I understand,
set shell=zsh\ -i
should work.
if u want back to the vim by suspended,u could use fg,just like this:
fg %vim\ [u viming file]
this title maybe help u:http://ytliu.info/blog/2013/09/28/ttyde-na-xie-shi-er/

Linux command to DOS

I have a file include some linux command and I want to run in on windows (DOS command).
The command is:
cat tmp/$id/index.html | sed -e 's/ID/$id/g' > a;mv a tmp/$id/index.html
What is the similar command in MS-DOS?
Thank you!
The problem is that natively there is no equivalent command to sed. You have two options from my point of view. Either create a vb script that does what you want (It will not take 1 line though - more like 10-15 I guess), or use something like GnuWin32 that gives you the option to run unix commands in windows terminal.
You could consider using powershell to do approximately the same thing. It supports cat and mv and you can get a sed like equivalent by using %{_ -replace "expression", "replace"}. Details here http://blogs.msdn.com/b/zainnab/archive/2007/07/09/grep-and-sed-with-powershell.aspx
Or consider using a linux like command prompt like bash which should be available through cygwin
I think this is impossible to do in "bare" command line (as you called DOS command), because cat and sed are separate utilities. If you want to port this script from Linux command shell to windows command line, I would advise you to download and install CygWin
DOS itself does not have support for that. You could try with a port of SED for DOS available here. If you can get Powershell, that's an option. Here's an example of using grep/sed with Powershell.
There are many options.
You can try to install cygwin or download and install Git and use Git-bash or add the bin directory to your PATH so you can run this command on your CMD prompt.
There is no such command(s) for MS-DOS.

Want to understand what's going on with linux command

I am installing a virtualenv and want to understand what's going on.
$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
- I understand curl fine
$ python virtualenv.py my_new_env
- Understand this, too
$ . my_new_env/bin/activate
- Here's where I get lost. What is the period doing here?
(my_new_env)$ pip install ...
- What does it mean to have the parentheses here? Does this use tell me I'm in a folder?
The dot is a command that means to read and execute the contents of the given script in the current shell (normally running a shell script runs it in a new process.) Evaluating the script in the current shell can change the environment variables of the current shell, so the behavior of subsequent commands is affected.
I don't know for sure about the parentheses, but I don't think they're meant to be syntax you type. As they come before the '$' prompt, perhaps that's literally what you'll get as your new prompt after running the activate script, to show you that your environment has been changed?
The dot is essentially an "execute" command — execute the commands in my_new_env/bin/activate as though they were typed into your prompt, essentially.
The parentheses shown in the prompt (at least in the tutorial instructions) then indicate that you're typing commands in your new virtual environment, and not in your original (real) environment.

Resources