0

I wonder how to add in my basic script some commands with nano, Ctrl-O, Enter, Ctrl-X, Enter. You can see what I want at the end of the script. It is after git merge, I just need to save commit changes (formality)

#!/bin/bash

## Set Local Rebase ##
git config pull.rebase true

## Update OpenWRT Scripts
./scripts/feeds update -a
./scripts/feeds install -a

## 5.4 kernel
git remote add wrt https://github.com/james/openwrt.git
git fetch james
git checkout -b wrt james/kernel5.4-qsdk10.0
git checkout master
git merge wrt
*ctrl o*
*enter*
*ctrl x*
*enter*
5
  • What do these commands achieve in nano? Do I understand correctly that you want to save the file without editing it and exit nano? Commented Feb 11, 2022 at 23:58
  • 1
    This is not impossible, but would be a lot of work, since application usually won't be running interactively in a script. Could you tell us more about why you want to do that? This seems like an instance of the XY problem. Commented Feb 11, 2022 at 23:58
  • 2
    Consider taking a look at the git merge man page and thinking about how you could use options like --no-edit. Commented Feb 11, 2022 at 23:59
  • thanks guys, yes it is after git merge, I just need to save commit changes (formality) Commented Feb 12, 2022 at 0:01
  • 1
    Does this answer your question? stop git merge from opening text editor Commented Feb 12, 2022 at 0:08

1 Answer 1

1

Instead of having to interact with your editor to set the merge commit message, you can use the -m flag to specify a commit message without opening an editor, or the --no-edit to accept the default message. You can also use git fmt-merge-msg to help generate a message to pass to -m, but that's a bit harder.

Using --no-edit:

git merge --no-edit

Using -m:

git merge -m "automated merge by my script"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.