How to stop/cancel 'git log' command in terminal? [duplicate] - terminal

This question already has answers here:
How to exit a 'git status' list in a terminal?
(16 answers)
Closed 6 years ago.
In terminal, I ran this command git log . It displayed a list of log but it seems that because it is long, the terminal is not displaying everything. Below logs there is : that I can see more logs when I hit enter key.
How do I terminate a command, and show the prompt for running another one.
Based on my search, I realized that ctrl+c should be used, but it doesn't work for me. I tried to enter ! and it stopped that task and I returned to $. But I'm not sure this is correct way because when hit !, from ./a/b/c moved me to ./a/b/

You can hit the key q (for quit) and it should take you to the prompt.
Please see this link.

Related

How to see bash script executed command? [duplicate]

This question already has answers here:
How can I debug a Bash script? [closed]
(12 answers)
Closed 2 years ago.
I'm not sure I address this problem correctly, but I've search and search over the net and found nothing, yet.
I'm writing a bash script and I want to see what the script is really doing when being executed, like a log of all the commands, one by one, what are executed - this way, I'll be able to see why my script is falling.
Note : I've post similar question in the past, someone told me I run my bash script with sh -xe script.sh but it doesn't give me enough information to debug properly.
Please advise. Thanks!
Adding set -x at the beginning of the script displays, in the terminal, all the commands sent by the script as the terminal received it. It was exactly what I needed and it working perfectly.

How to execute an .exe file including blank spaces in it [duplicate]

This question already has answers here:
How to create batch file in Windows using "start" with a path and command with spaces
(7 answers)
Closed 2 years ago.
So normally I have several *.bat files to automate some things in my computer.
But I'm kinda stuck in this call...
cd "C:\Users\user\AppData\Local\Programs\program2Execute"
start program has spaces.exe
I don't get the app executed, instead I get a cmd window with the cd command result, nothing else. I tried to quote "program has spaces.exe" but it doesn't get executed I get the window duplicated instead.
Apologize if this is kinda dumb to ask, but I have spent quite time looking for the answer.
Thanks in advance.
If you use the start command:
start "" "a program with spaces.exe"
start will use the first double quoted string as the title and the 2nd as the command.
Or don't use start:
"a program with spaces.exe"

Basic Ubuntu Bash Script Not Running [duplicate]

This question already has answers here:
How do I run a shell script without using "sh" or "bash" commands?
(13 answers)
Add a bash script to path
(5 answers)
How to make a shell script global?
(9 answers)
Closed 4 years ago.
As I'm sure you'll all tell very soon, I'm no expert when it comes to this sort of thing. However, when trying to look at results, I've not been able to come across anything quite like what I need - so I decided to ask here.
BACKGROUND: When I log into my server, I need to cd into a folder and run some commands based on one of the 3 things I want to do:
1) Stop the server
2) Start the server
3) Rebuild the server
AIM: Rebuilding the server takes 2 commands, one of them (to rebuild) takes some time and instead of me having to cd into the directory, stop the server, rebuild the script, then start it again... I'm trying to create a bash file to do it for me, so I can simply login and execute one command.
The directory I need to CD into is: /var/www/website/
The stop process I need to enter is: pm2 stop 0
The Rebuild process I need to enter is: yarn run build -- --release
The start process I need to enter is: pm2 start build/server.js
When I created a restartserver.sh file, I created it as follows:
#!/bin/bash
cd /var/www/website
pm2 stop 0
yarn run build -- --release
pm2 start build/server.js
When i try to run it by typing 'restartserver.sh' I get the error:
-bash: restartserver.sh: command not found
I'm sure this is really easy for someone who has any idea about this sort of thing... but for my... I've no idea. Can anyone please help?
Thanks
P

bash script, execute command line and keep going the next for loop [duplicate]

This question already has answers here:
Loop background job
(3 answers)
Closed 4 years ago.
Is it possible to run a command in a for loop without waiting for that command ended, while keeping going to the next iteration?
Because I have to send multi-files at the same time asap via many ssh connections, therefore I couldn't wait until the command ended one by one.
Maybe is it related to something like 'xterm' or 'gnome-terminal'?
Yes, you can execute the command in background by adding & at its end.
So the syntax looks like programName [arguments] & (at least for bourne compatible shells)

Is there a way to make my bash shell on mac enter a line break after each command? [duplicate]

This question already has an answer here:
Insert new line to bash prompts
(1 answer)
Closed 6 years ago.
I just started programming and find it hard to read through the lines of code to find where to start right after my command so it'd be nice to see line breaks before each prompt reappears.
in, ~/.bash_profile, set PS1 to change the prompt. Start it with a newline, and then your terminal output will have a blank line between the last line of the command output and the prompt.
More details on how you can customize the prompt: here

Resources