Can't run subl command in Cmder bash - bash

I followed the steps outlined here https://laravel.io/forum/02-24-2014-a-neat-way-integrate-cmder-and-sublime-text-seamlessly, which are:
Create a new folder called 'Sublime Text 3' in the '/cmder/vendor/' location. You should also see the folders /clink, /conemu-maximus5, and /mysgit.
Download a portable version of Sublime Text 3 from their website and unzip the content into the newly created Sublime Text 3 folder.
Then, in the aliases file under /cmder/config/aliases, add: subl="%CMDER_ROOT%\vendor\Sublime Text 3\sublime_text.exe" $1 -new_console:s75V
Now I can use the subl command in a normal cmd window, but when I switch to a bash shell I get the same error, 'bash: subl: command not found'

On Windows, if you want to run some command directly in the console, you have to add the directory where it resides to the system PATH variable. There is no need to follow the instruction given in the link you provided.
solution
Find the directory where subl.exe resides and add that directory to system PATH.
see this post on how to set the path.

Related

Script for copying a folder somewhere using Git Bash

I want to copy a folder ~/Projects/LocalProject onto my server //VM-Server/ServerProject.
I know that I can use GitBash:
cp -r directory-name-1 directory-name-2
But what I'm curious about is, can I create a script to do that by double clicking that script, or adding it as a command to my GitBash, cause I will need that alot?
--Edit--
Tried nothing, as I don't know how to do that. Yes there are hidden files, I don't want them to be copied. There shouldn't be newer files on the destination. I need to manually run it, I thought that's clear as I mentioned the option to have a executable script / or a terminal command.
Option 1: Batch file
You don't even need git-bash; you can make a batch file in any text editor, name it copy to server.bat, and type in cp C:\Users\<Your username>\Projects\LocalProject \\VM-Server\ServerProject.
You can also make a .sh file for use in bash. The command is the same, just make note that Windows uses \, while bash uses / for directory tree
Option 2: Alias
Open your bash_profile file (it's in your git bash install location).
Add a line at the end of the file that says alias copyToServer = 'cp ~/Projects/LocalProject //VM-Server/ServerProject'. Then close git-bash, reopen it and use the command by typing copyToServer as a bash command. (It doesn't need to be named copyToServer)

How to find where my PATH variable is being generated and how to edit it in Mac OSX Terminal?

Currently I am in Mac OSX and when I try to find what my PATH is via Terminal, I get:
> echo $PATH
/Users/User1/google-cloud-sdk/bin:/usr/local
/bin:/usr/local/sbin:/usr/local/bin:
/usr/bin:/bin:/usr/sbin:/sbin:
/Library/TeX/texbin:/opt/X11/bin:
/Applications/Wireshark.app/Contents/MacOS
I would like to remove google-cloud-sdk, wireshark, and tex from PATH, but have no idea how to do it. When I look inside my etc/profile file, none of these apps are listed. Is there a way to clean up by $PATH? Thanks.
I just found the Wireshark path file in :
/etc/paths.d/
Go to your home directory. If you open a fresh Terminal window/session, this will probably have you in your home directory.
Type,
ls -al
This should give you a list of the files in your home directory, including invisible files. Check there is a file called .bash_profile. The "." means it is an invisible file.
If that exists (as it should) type:
nano .bash_profile
This will open this file in the text editor program called "nano". In this file you should find statements like:
export PATH="/Library/Frameworks ....
There should be similar PATH statement for the options you want to remove.
Delete those lines and then exit nano by ^O for writing out, and you need to print Y to save. Then ^X to exit nano.

How to enable Git terminal begin with home directory in Windows? [duplicate]

This question already has answers here:
How to make Git-bash command line start up with home directory?
(2 answers)
Closed 5 years ago.
Git-bash is starting up from the directory where the Git-bash application is installed i.e at "C:/Program Files/Git" and it is displaying these prompts right after I launch Git-bash.exe:
bash: /c/Users/Kedar/git-prompt.sh: No such file or directory
This is so insane because I definitely have placed git-prompt.sh file in that path
It is not starting from the home directory as it was expected i.e. Kedar ~ $
Yes, I can reach this directory but after I type this command - Kedar / $ cd ~/
So, my query is to how to enable Git terminal to start up with home directory i.e. Kedar ~ $ and not Kedar / $ ?
If you are on Windows, do this
Right click on the Windows shortcut that you use to launch git bash terminal i.e git-bash.exe, and click Properties.
Go to tab named Shortcut
Change the value of Start in: label to your desired workspace path i.e. C:\Users\Kedar maybe in your case
Then you should run the application as administrator!
Also assuming you use Windows, there are two ways:
Simple way: As Divyanshu Kushwaha explained, open the Properties of the shrotcut you use to launch and just place --cd-to-home behind the target path that points to your git-bash.exe file, like this: "C:\Program Files\Git\git-bash.exe" --cd-to-home.
Flexible way: You can configure the bash command line via the .bashrc file in your home folder. If the file does not exist, you can create it and then add something like this:
MoveToHome() { cd /c/<any path you want>; }
MoveToHome
This lets you define any path you want to be in on startup, by defining a MoveToHome function and calling it right on startup.

Whats different when you executable a scripts in OSX?

I have a question I have been trying to fix for a while. I want to understand what's the difference between starting a script from the command line and making it executable and then running it from the Finder.
Because this is what I am experiencing;
I have a simple script called trash-files which contains this command:
trash ~/Downloads/*
When I run from the terminal it works as expected; however if I doubleclick the shell script in the finder I see this:
/Users/xx/Desktop/trash-files: line 1: trash: command not found
I hope anyone can tell me why this doesn't work as expected
trash is not a standard command in OS X. Is it something defined in your ~/.profile or a similar file? If so, these are not run for non-login shells, such as those created to run a script.
If you're using homebrew, you could run
brew install trash
which would install the necessary scripts to have the trash command work in the way you're expecting.
There is a folder in your home folder location called
.Trash
The "dot" in front of the folder name makes it hidden while searching for it in finder. You'll have to use Terminal to execute the following command:
cd ~/
ls -la
This will change the directory to the current logged in users home folder, then second command will list files and show hidden files. You can then run:
rm .Trash/*
This will remove everything inside the Trashcan on the dock.
So open TextEdit from the /Applications folder, go to "Format" and make it "Plain Text". Paste in the two lines below.
#!/bin/sh
rm ~/.Trash/*
Save the file as "emptyTrash.sh" (uncheck use txt extension). Save it to your Desktop or wherever you'd like. Then open Terminal, cd (change directory) to where the files is and run this command to make the script executable:
chmod +x emptyTrash.sh
Then you can execute the script by cd (changing directory) to path where the script is, and run:
./emptyTrash.sh
That's it.

How to run Matlab from the command line?

Is it possible to run Matlab commands from Mac command line?
The matlab script is in the bin subdirectory of the MATLAB app bundle. On my machine, this means I can run it like so:
/Applications/MATLAB_R2012a_Student.app/bin/matlab
If you want this bin directory on your path (so that you can just run matlab, mex, etc), edit or create a new text file called .bash_profile in the top level of your home directory with the following line:
export PATH=/Applications/MATLAB_R2012a_Student.app/bin:$PATH
Replacing the "MATLAB_R2012a_Student" part with the name of your actual MATLAB app bundle. This will not come into effect for currently open terminals, but newly opened terminals should work properly.
You need the full path to the MATLAB executable, and you can use the -r option to run a command in the MATLAB that you start, as per the doc here.
As already mentioned above you need to first edit your .bash_profile file by adding the following line (replace 'MATLAB_R2020b' with your MATLAB version)
export PATH=/Applications/MATLAB_R2020b.app/bin:$PATH
Then after restarting the terminal you can open MATLAB by inserting the command
/Applications/MATLAB_R2020b.app/bin/matlab
You can also run your .m scripts by defining the working directory folder and the executable scripts and their paths. You just need to add more commands to the above.
/Applications/MATLAB_R2020b.app/bin/matlab -r "addpath(genpath('{Your working directory folder path}')); cd {Your working directory folder path}; {Your script name}; {Your other script name}; quit;"
Please find a more detailed description of MATLAB command line arguments from:
https://www.mathworks.com/help/matlab/ref/matlabmacos.html#d122e801165

Resources