Install a vimball from the command line - command-line

As this post points out you can install Vimballs using the normal:
vim somevimball.vba
:so %
:q
But if you want to install a from the command line how do you do it? I ran a 'man vim' and it seems like the best "from source install" option was the '-S' option so I tried to install haskellmode with it:
wget 'http://projects.haskell.org/haskellmode-vim/vimfiles/haskellmode-20090430.vba'
vim -S haskellmode-20090430.vba
and that failed to work. It gave me the following error:
Error detected while processing function vimball#Vimball:
line 10:
(Vimball) The current file does not appear to be a Vimball!
press ENTER or type command to continue
It should be noted that using the first method I was able to successfully install the vimball. I have tried the second method on a few other vimballs and it has failed every time. Is there a way to install a vimball from the command line? It seems like a useful sort of task.
Oh, and I am running the following version of vim:
Version: 2:7.2.330-1ubuntu3
Thanks.

Use one of the following commands:
vim -c 'so %' -c 'q' somevimball.vba
or:
vim -c 'so % | q' somevimball.vba
For more information, see:
:help -c
:help :bar

Having seen this solution I decided to hide the messiness in a script that always should have existed, vim-install: http://github.com/robertmassaioli/vim-install

Related

Bun Not Found After Running Installation Script

I have ran the installation script by pasting this code:
$ curl https://bun.sh/install | bash
However, when I try to get the version of bun, it says it could not find it:
$ bun --version
Command 'bun' not found, did you mean:
command 'ben' from deb ben (0.9.0ubuntu2)
command 'bus' from deb atm-tools (1:2.5.1-4)
command 'zun' from deb python3-zunclient (4.0.0-0ubuntu1)
Try: sudo apt install <deb name>
I had the same issue running on Windows 10 WSL2 Ubuntu-22.04 with Bun v0.1.5.
The solution (and more detail just in case anyone needs it) below:
The executable for bun is in the directory "/home/username/.bun". You need to add this to your $PATH so that this can be found when typing bun commands such as "bun --help".
The bun setup process does not add this path so you need to do it yourself.
Two ways to do this :
(1) Manual method
Type in the terminal:
export BUN_INSTALL="/home/YOUR_USERNAME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
Note: This process will have to be REPEATED for every new shell you open.
(2) Automatic method
Edit the .bashrc file :
nano ~/.bashrc
at the end of this file add
BUN_INSTALL="/home/YOUR_USERNAME/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
(Remember to save your changes with Ctrl-O)
Note: You will NEED TO OPEN A NEW SHELL for this to work OR type 'source ~/.bashrc' to use in the current terminal.
You should now be able to run bun commands in any new shell.
The installation script says a message at the end telling you how to add bun to your PATH manually. Here is that output:
Manually add the directory to your $HOME/.bashrc (or similar)
BUN_INSTALL="/home/sno2/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
I advise you re-run the installation command and copy the environment variables and add them to your PATH.
export BUN_INSTALL="/Users/manendra/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
add these to your .bashrc, .zshrc or you can use export command to use for current session.
Note: Change your username place of (manendra) "/Users/manendra/.bun"
Manually add the directory to ~/.bashrc (or similar):
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
From the installer, last message is:
To get started, run
exec /bin/zsh
bun --help

second line on my system or python terminal now saying: “ -bash: zzzzz#: command not found“

I have been trying to pip install psycopg2 for some time now
I have just updated to python 3.7.4, before this problem started.
To set my path to a specific python version I used the code below.
nano .bash_profile
I thought that it would now be easy for my system to identify the path of the newly installed python, as to enable it to install psycopg2. Then the below started happening.
The second line of system terminal or python terminal is now always showing:
-bash: zzzzz#: command not found on my terminal
No matter what I type on my terminal, I am always getting command not found
This would mean you literally have "zzzzz" somewhere in the bash_profile. Bash is seeing "zzzzz" as just another command to run at startup like the rest of the profile script. As there is nothing in your PATH matching that string, bash reports the issue back to you.
Either remove the extra line from your .bash_profile. OR use a terribly wasteful work-around!
ln -s /bin/true /bin/zzzzz
This will create a symbolic link to the "true" binary (all it ever does is return true) from zzzzz. Now bash can find zzzzz and run it during start up, which does nothing. No more error and an absurd work around. You should fix the file.

Run command line via alias with zsh on MATLAB

I use the system/unix command on Matlab in order to run an external program via the command line. I want to execute it via an alias define in .zshrc on my computer. Unfortunately, the alias seems to be not available.
Example with ll
on a terminal: which ll gives ll: aliased to ls -lh
on Matlab: unix('ll') gives zsh:1: command not found: ll
I check if I used the right shell: unix('echo $SHELL') gives /usr/local/bin/zsh.
I have add setopt aliases in my .zshrc but it changes nothing. Is it possible to check which startup files is used when you open a non interactive shell?
The ~/.zshrc seems to be not loaded in the non interactive case. The solution consists in loaded aliases and added setopt aliases in ~/.zshenv. See this for instance.

Executing terminal commands in Jupyter notebook

I am trying to run the following in Jupyter notebook (with Python 2 if it makes a difference):
!head xyz.txt
and I get the following error:
'head' is not recognized as an internal or external command, operable
program or batch file.
Is there anything I need to import to be able to do this?
Might be useful for others.
Use ! followed by terminal command you want to execute. To run a shell command. E.g.,
! pip install some_package
to install the some_package.
An easier way to invoke terminal using jupyter-notebooks is to use magic function %%bash and use the jupyter cell as a terminal:
%%bash
head xyz.txt
pip install keras
git add model.h5.dvc data.dvc metrics.json
git commit -m "Second model, trained with 2000 images"
For Windows it would be %%cmd.
Write it at the beginning of the cell like this :
%%cmd
where python
myprogram "blabla" -x -y -z
You can start the cell with the magic % bash before the rest of your code. There is an example in this blog post, together with a list of some of the most useful magics.
Make sure you run your command in linux shell because there is non such command in windows.
Another option nowadays is the Jupyter kernel for Bash.
I had the same issue. Solved by running
!bash -c "head xyz.txt"

"time" command in Cygwin works, but not in NetBean

I can do this in Cygwin, adding time Command
USER#USER_PC ~
$ time ./HelloWorld
shows smthing like
Hello World!!!
real 0m0.270s
user 0m0.270s
sys 0m0.270s
I've deployed an similar C/C++ Project #NetBean7.2 #Win 7.
It shows error message at Run time, Only when I add time Command ,like:
time "${OUTPUT_PATH}"
,at the Text Field of Projcet_file-> R_Click -> Properties -> Run -> Run_Command:
,and default value ${OUTPUT_PATH} only.
Error message is
C:\ProjectFolder\time does not exist or is not an executable
,seems that NetBean consider time as an excutable
Any better ways to solve it??
full command to bash needs to be in quotes if calling from cmd shell
bash -c "time ls"
time is a builtin command of bash. On my cygwin installation the proper command is:
c:\cygwin\bin\bash -c time
You have to adjust the path to bash.