كيفية تغيير كلمة الأول بسرعة في أمر باش؟

جدول المحتويات:

فيديو: كيفية تغيير كلمة الأول بسرعة في أمر باش؟

فيديو: كيفية تغيير كلمة الأول بسرعة في أمر باش؟
فيديو: اضافة شاشة البداية (splash screen) لتطبيقك | android studio 2024, مارس
كيفية تغيير كلمة الأول بسرعة في أمر باش؟
كيفية تغيير كلمة الأول بسرعة في أمر باش؟
Anonim
إذا تم ملء سير عملك بالكثير من الإجراءات المتكررة ، فلا يؤلمك أبداً للبحث عن طرق لتحسين سير العمل الخاص بك وتبسيطه. تتضمن مشاركة SuperUser Q & A اليوم بعض الاقتراحات المفيدة للقارئ الذي يسعى لتحسين سير العمل.
إذا تم ملء سير عملك بالكثير من الإجراءات المتكررة ، فلا يؤلمك أبداً للبحث عن طرق لتحسين سير العمل الخاص بك وتبسيطه. تتضمن مشاركة SuperUser Q & A اليوم بعض الاقتراحات المفيدة للقارئ الذي يسعى لتحسين سير العمل.

تأتي جلسة الأسئلة والأجوبة اليوم مقدمة من SuperUser ، وهي قسم فرعي من Stack Exchange ، وهو عبارة عن مجموعة من المنتديات على مستوى المجتمع المحلي على مواقع الأسئلة والأجوبة.

لقطة شاشة مجاملة من مات جويس (فليكر).

السؤال

يريد عملة قارئ SuperUser معرفة كيفية تغيير الكلمة الأولى بسرعة في أمر bash:

I would like to improve my workflow in bash and realized that I often want to execute the same command to a different executable.

Some Examples

1.) Git

2.) Bash
2.) Bash
Image
Image

I know that I can hit Ctrl+a then Del to remove the first word, but I am wondering if there is a quicker way to do it.

هل هناك طريقة أسرع للعملة لتغيير الكلمة الأولى في أوامر bash؟

الاجابة

المساهمين SuperUser Spiff ، هاستور ، jjlin. وجوستافو جيرالديز لديهم الجواب بالنسبة لنا. أول ما يصل ، Spiff:

!$ expands to the last word of your previous command. So you could do:

Or
Or
Your examples happened to only repeat the last word, so !$ worked fine. If you actually had a lot of arguments that you wanted to repeat, and you just wanted to change the first word, you could use !*, which expands to all words of the previous command except the zeroth.
Your examples happened to only repeat the last word, so !$ worked fine. If you actually had a lot of arguments that you wanted to repeat, and you just wanted to change the first word, you could use !*, which expands to all words of the previous command except the zeroth.

See the “HISTORY EXPANSION” section of the bash man page. There is a lot of flexibility there.

تليها إجابة هاستور:

I would like to add a warning (see the answer from Spiff above). With !$, you do not have full visual control of the line you are running. The results can be harmful sometimes, especially if you incur a misprint. It takes what it needs from the history to expand on.

So if you write the last command with a blank space at the beginning, then this command will probably not finish from the history. When you execute your new command with !$, the shell will not take the parameters from the last command line typed, but only from the last part of the history.

Here are some more helpful words and commands.

ثم الجواب من jjlin:

Ctrl+a to go to the beginning of the line, then Alt+d to delete the first word.

وجوابنا الأخير من غوستافو غيرالديز:

The delete word shortcut is actually Meta+d, and Meta is usually mapped to Alt on Linux machines. On platforms where this is not the case, an alternative to get the Meta modifier is to use Esc as a prefix. You can read more about the Meta Key here.

هل لديك شيء تضيفه إلى الشرح؟ الصوت قبالة في التعليقات. هل ترغب في قراءة المزيد من الإجابات من مستخدمي Stack Exchange الآخرين المحترفين بالتكنولوجيا؟ تحقق من موضوع المناقشة الكامل هنا.

موصى به: