how can I set default editor to emacs in unix - unix

how to make emacs as default editor in bash shell? I tried setenv EDITOR emacs. It gave me the error message "setenv: command not found".

When changing profiles, make sure you always use full paths, just in case PATH is not yet set at that point. Double check if you do have setenv:
# find / -name setenv
If so, just enter its full path in your profile. Furthermore: a unix flavor would be nice for people to know, not all flavors work with the same file names.

Related

vi can't set paste(turn off auto indent while paste) in BusyBox

vi version is BusyBox v1.20.2 (2014-08-27 12:48:18 PDT) multi-call binary, which run on esxi machine.
Can't paste text without auto indent by these methods:
:set paste in vi editor
configure set noautoindent in .vimrc which located in $HOME directory.
How could I achieve that?
BusyBox's vi is tiny and doesn't know what paste is.
It also isn't VIM, so won't read .vimrc, but will read $HOME/.exrc if it exists and is only owned and writable by the user. You should be able to put set noautoindent there in a more recent version.
You also have the option of placing commands in the EXINIT environment variable, or passing them as an additional parameter with -c "some_command" (both of which should be implemented in the version you're using, and both of which allow multiple commands separated by \n).
I'll note that all of the above depends on vi having been built with the SETOPTS, SET and COLON features enabled (though -c should work without COLON), which should be the default.
The set of options supported by a current version appears to be:
autoindent
expandtab
flash
ignorecase
showmatch
tabstop

How to set up your path so you can call 'julia' via the Terminal?

This is more of a n00b Unix question regarding how to set up paths correctly. It is also not a question that is specific to julia, but rather how to set up paths correctly in general (I suspect).
At the moment, the only way I can start julia via the Terminal is by using the command:
$ exec '/Applications/Julia-0.4.0.app/Contents/Resources/julia/bin/julia'
rather than $ julia
How can I set this up correctly?
Change to your home directory and find the file .bash_profile (note the . at the start: this is a hidden file. You can do ls -a to see if it is there, or just try to open it with an editor.)
Create the .bash_profile file if it doesn't already exist (e.g. using your favourite text editor).
Add the following line somewhere:
alias julia="/Applications/Julia-0.4.1.app/Contents/Resources/julia/bin/julia"
Open a new terminal window and enjoy!
(Note that 0.4.1 is the current latest stable version, which is what I have used here.)

How to change global variable in Solaris?

I've tried to change global variable DSQUERY in Solaris with this command:
setenv DSQUERY "SYBSERVER"
but it wasn't persisted. When I entered again in the machine the value was set to the older one.
How can I persist this change?
You have to put this line in your profile file. This file is read when you start a shell, and allows you to set-up some specific settings.
The filename depends on the shell you use and how you connect (with a direct connexion or with a su for example).
It seems you use csh, so you will have to change $HOME/.cshrc and.or $HOME/.login files.
Add your SetEnv command to .cshrc and .login file will do the job.
You have to do it in the user profile files, depending on the shell being used (.login, .cshrc, .bashrc, etc) so that when you log in again, it's executed automatically. There are global versions of those files under /etc for some shells, in case you want that to be applied to all users.
Rgds,
Daniel

Error "Invalid Parameter" fom ImageMagick convert on Windows

I am trying to convert a PDF document into a PNG file using ImageMagick command line tools from a ASP.NET website. I create a new shell process and ahve it execute the following command:
convert -density 96x96 "[FileNameAndPath].pdf" "[FileNameAndPath].png"
This runs well when testing the website on my local machine with the ASP.NET Develeopment Server of VS and the command also works well when manually entered into the shell. When running from the programatically created shell in ASP.NET there is the following error message:
Invalid Parameter - 96x96
Does anybody know why that happens and what to do?
I have tested the command while being logged in on the server via RDP with a different user account than the ASP.NET process. I have used exactly the same ImageMagick and Ghostscript installation files as on my local machine and have activated adding the ImageMagick installation path to the enironment variables during installing. The server has not been rebooted since than.
convert is also the name of a windows executable which converts FAT filesystem to NTFS. When you do not specify the full path of an executable, quote:
...the system first searches the current working directory and then
searches the path environment variable, examining each
directory from left to right, looking for an executable filename that
matches the command name given.
"C:\Windows\System32" is generally present in the beginning of %PATH% variable, causing the Windows convert utility to launch, which fails with "Invalid Parameter" error as expected.
Try specifying the full path of the ImageMagick's convert.exe like so:
"C:\Program Files\ImageMagick\convert.exe" -density 96x96 "path_and_filename.pdf" "path_and_filename.png"
As others have stated convert points to a different program in your PATH. Instead preface your command with magick. So your command would instead be:
magick convert -density 96x96 "[FileNameAndPath].pdf" "[FileNameAndPath].png"
In Window actually exists a "convert.exe" in system32 - make sure your script doesn't start that one (maybe the environment paths on your development machine are set differently).
I am only answering this late because imagemagick was updated. Now, if you wish to use the "convert" command, you do it like this:
magick convert "image.png" "document.pdf"
or
magick convert "image_00*.png" "document.pdf"
for multiple images.
Same syntax for command, just add magick before it
A couple more options for fixing this:
Edit your Path system variable to contain the path to imagemagick
as it's first content and then add the rest after it. This will make
windows always find the imagemagic convert first before it finds
the other convert program. So something like this: C:\Program Files\ImageMagick-6.9.2-Q16;C:\Program Files\Haskell Platform\2014.2.0.0\lib\extralibs\bin;...
Another option is to create a dedicated folder somewhere on your machine where you will place shortcuts for some of these name clashes. Then what you do is that you rename those shortcuts to meaningful names, for example convert_image_magick, then add the path to this folder to your system path. So now as you hit tab more, you will finally find the right program you want to run
yes! if you launch an Administrator command window it defaults to C:\windows\sytem32\ ... as long as you're not in that directory the command will pickup the ImageMagick convert.exe
My issue was I was using the "FORFILES" command which is tricky because it requires using
"cmd /c" and passing the convert command with #path and #file parameters and it does some escaping of slashes... needless to say it's caused me hours and hours of headache. It even parses hex characters, like if your filepath has the combination 0x00 in it, it will think that's a hex value and mangle your path. I had a filepath named C:\ImageRes3000x3000
and FORFILES interprets that literally and it caused a strange path issue. Sorry if this is a long useless post but it's meant to be FYI, if someone runs across this, maybe it will help them. That being said, FORFILES and "convert.exe" are a powerful and simple image renaming line script combo.
here's my full 3 line image renaming script
robocopy D:\SRC_DIR\ D:\DEST_DIR\_staging *.jpg /e /MAXAGE:2
FORFILES /P D:\DEST_DIR\_staging\ /S /M *.jpg /C "cmd /c convert.exe #path -quality 65 -resize 1500 D:\RESIZED_DIR\\#file"
DEL D:\DEST_DIR\_staging\*.* /S /Q

How do I get vim's :sh command to source my bashrc?

Whenever I start a shell in vim using :sh, it doesn't source my ~/.bashrc file. How can I get it to do this automatically?
See :help 'shell'. You can set this string to include -l or --login, which will source your .bashrc file. So, you might have a line like this in your .vimrc:
set shell=bash\ --login
Note that this will alter everything that invokes the shell, including :!. This shouldn't be much of a problem, but you should be aware of it.
The value of this command can also be changed by setting the $SHELL environment variable.
If it doesn't source your .bashrc file, it may still source your .bash_profile file. I usually make one of them a symlink to the other. If your .bashrc performs some particularly odd one-time operations, you may have to edit it to only perform those operations with a login shell, but I've never had problems with it.
~/.vimrc
cmap sh<CR> !bash --login<CR>
If you quickly enter "sh<Enter>" in command-line, you can start bash with sourcing ~/.bashrc. So dirty.

Resources