Now I'm going to walk you
through the process of
getting your workspace set up on Mac.
And the process on Linux is similar.
There are also written instructions
in the instructor notes.
If you're using Windows, there
are instructions in the previous video.
First I'm going to download
two files that are needed for
the set up I just showed you,
one to enable tab completion, and
want to enable the special
Git features in the prompt.
So I'll go to the webpage
with the first file and
you can find the link to this
file in the instructor's notes.
Then I'll right-click anywhere
on the page and select Save As.
And I'll save the file in
my Downloads directory.
Now I want to make sure that
Hide extension is unchecked, so
that I can see the exact name
the file is being given.
And by default,
it's suggesting Redirecting.txt.
But I want to change this
to git-completion.bash, and
then I'll Save the file.
Now I want to move the file
to my home directory,
which I'll do using the Terminal.
Now when I first open the Terminal,
I start out in my home directory, or
I can type cd ~ to get to
the home directory if I need to.
Now I'll use the command mv,
which stands for
move, to move the file I just
saved into my home directory.
The first argument is
the file I want to move,
which is in my Downloads directory and
it's named git-completion.bash.
And I want to move it into the current
directory while keeping the same name.
Then I'll go through the same process
to save the second file linked in
the instructor's notes as git-prompt.sh.
Next, I'm going to create
a file called .bash_profile,
which contains configuration for
the Terminal.
I recommend using the configuration file
that I used when filming this course.
To do that, you can download the file
called bash_profile_course in
the downloadables section.
Next, use the Terminal to move
this file to your home directory.
You should name it .bash_profile and
don't forget the dot at the beginning.
Now if you already have a bash profile,
then don't run this command, and
instead you can copy and
paste the content from this file
into your existing bash profile.
And if you're running Linux,
then you might need to name this file
.bashrc instead of .bash_profile.
Now I don't see any changes made to my
prompt yet, and that's because I'll
need to close and reopen the Terminal
before the changes take effect.
I'll do that at
the the end of the video.
In case you're curious about
what's in this bash profile, or
if you'd like to pick and
choose just the lines you're interested
in, I'll go through what each line does.
Now, don't worry if you don't
understand how each line works though.
Even experienced Unix programmers
frequently copy and paste this kind of
thing from their friends,
rather than writing it from scratch.
This first line loads one of
the files you downloaded earlier and
enables tab completion.
These lines define some colors,
which will be used in your prompt.
This line loads the other
file you downloaded earlier.
And it's necessary for
the git related stuff like commit
IDs to show up in your prompt.
This line is what makes sure that
the asterisk will be shown in your
prompt if you make changes
in a git repository.
And this line actually defines
what the prompt will be.
The prompt will show
your username in purple,
the commit you currently have checked
out or other git related stuff in green.
And the director URN followed
by a dollar sign in blue.
Then any text after that will be
displayed in the default color.
If you're curious to learn more
about how prompts work in bash,
check out the link in the instructor's
notes, but it's not necessary for
the rest of this course.
Next, it's important to make sure
you can launch your favorite text
editor from the Terminal so
that you'll be able to set it as
your default editor within git.
I'll show how to do this for Sublime.
If you're using another text editor,
I recommend that you Google to figure
out how to use it from the Terminal.
Now, I can launch Sublime from the
Terminal by running this long command.
Where this is where Sublime
is stored on my computer, but
I'd like to have a shortcut.
To create one I'll use Sublime to
add a line to my bash profile.
Files with a dot at the beginning of
the name don't usually show up in
file system explorers, so
I'm going to have trouble opening
my batch profile with Sublime.
To fix this I'll use the trick
of moving my bash profile
to a file without a dot at
the beginning of the name.
Then to open the file in Sublime, I'll
first navigate to my home directory,
which I can do by pressing Cmd+Shift+H.
And then I'll select
the file bash_profile.
Then I'll add this line to it to
make the subl command stand for
the same command that you
saw me enter earlier.
You can copy and
paste this line from the instructor's
notes if you're using Sublime.
Now I'll save the file and
I'll change the name back to have a dot
at the beginning using the Terminal.
If I don't do this,
then the bash profile won't take
effect when I open the Terminal.
Again, this command won't work
until I've restarted the Terminal.
Now I'll configure git to
use Sublime as my editor for
things like commit messages.
To do that I'll run git config
--global core.editor and
here I need to put in double quotes
the command to open my text editor.
For Sublime that's subl -n -w.
Where -n will open
Sublime in a new window,
and -w will wait until you close
your file before continuing.
If you use a different editor,
you will need to modify this part of the
command to use the editor that you like.
See the instructor's notes for
more details.
Next I'll run these two
git config commands,
which will come in handy
later in the course.
Please copy and
paste these commands from
the instructor's notes and run them.
Finally I'll close the Terminal and
reopen it.
Now I can see that my prompt has
changed to become more colorful.
And if I want to view my
bash profile using Sublime,
I can run subl .bash_profile.
Remember to close and reopen your
Terminal when you're finished, or
your changes won't take effect.
والآن سأصحبكم في جولة
خلال عملية
.إعداد مساحة العمل على جهاز Mac
.كما أن العملية مماثلة على نظام Linux
هناك أيضًا إرشادات مكتوبة
.في ملاحظات المدرب
وإذا كنتم تستخدمون نظام Windows، فهناك
.إرشادات موجودة في الفيديو السابق
في البداية سأقوم بتنزيل
ملفين ضروريين
،لعملية الإعداد التي عرضتها عليكم للتو
،أحدهما لتمكين إكمال علامة التبويب
والثاني لتمكين ميزات
.Git الخاصة في موجه الأوامر
لذا سأنتقل إلى صفحة الويب
التي تشتمل على الملف الأول
وبإمكانكم العثور على رابط لهذا
.الملف في ملاحظات المدرب
ثم سأنقر بزر الماوس الأيمن في أي مكان
.على الصفحة وأحدد Save As
وسأحفظ الملف في
.دليل Downloads الخاص بي
والآن أريد أن أتأكد من
عدم تحديد Hide extension حتى
أتمكن من الاطلاع على اسم الملف
.الجاري تحديده بدقة
،وعلى نحو افتراضي
.يتم اقتراح الاسم Redirecting.txt
ولكنني أريد أن أغيره
،إلى الاسم git-completion.bash
.ثم أضغط Save لحفظ الملف
والآن أريد أن أنقل الملف
،إلى دليلي الرئيسي
.وهذا ما سأفعله باستخدام الوحدة الطرفية
،والآن سأفتح أولاً الوحدة الطرفية
وأبدأ من دليلي الرئيسي، أو
أكتب cd ~ لكي أنتقل إلى
.الدليل الرئيسي إذا دعت الحاجة
،والآن سأستخدم الأمر mv
والذي يعني
نقل، لنقل الملف الذي حفظته
.لتوي على دليلي الرئيسي
تتمثل الوسيطة الأولى في
،الملف الذي أريد نقله
والموجود على دليل Downloads الخاص بي
.ويسمى git-completion.bash
وأريد أن أنقله إلى الدليل
.الحالي مع الاحتفاظ بنفس الاسم
ثم سأفعل نفس العملية
لحفظ الملف الثاني الموجود رابطه في
.ملاحظات المدرب بالاسم git-prompt.sh
ثم سأنشئ
ملفًا باسم .bash_profile
يحتوي على تكوين
.للوحدة الطرفية
وأنصح باستخدام ملف التكوين
.المستخدم عند تسجيل هذه الدورة التدريبية
لتنفيذ ذلك، بإمكانكم تنزيل الملف
الذي يسمى bash_profile_course في
.قسم المواد القابلة للتنزيل
ثم تستخدمون الوحدة الطرفية لنقل
.هذا الملف إلى دليلكم الرئيسي
يجب أن تسمونه بالاسم .bash_profile
.ولا تنسوا وضع النقطة في بدايته
،أما الآن فإذا كنتم بالفعل لديكم bash profile
،فلا تشغلوا هذا الأمر
ولكن بدلاً من ذلك يمكنكم نسخ
المحتوى من هذا الملف ولصقه
.في bash profile الموجود
،وإذا كنتم تعملون على نظام Linux
فقد يلزمكم تسمية هذا الملف بالاسم
..bashrc بدلاً من .bash_profile
والآن أنا لم أر بعد أي تغييرات حدثت على موجه الأوامر
الخاص بي، وذلك لأنني
سأضطر إلى إغلاق الوحدة الطرفية وإعادة فتحها
.قبل تطبيق التغييرات
وسأقوم بذلك في
.نهاية هذا الفيديو
إن كنتم تتوقون لمعرفة
ماذا يوجد في bash profile هذا، أو
إذا كنتم ترغبون في انتقاء
،مجرد السطور التي تريدونها
.فسوف أشرح لكم ما يفعله كل سطر منها
فلا تنزعجوا إن كنتم لا
.تفهمون طبيعة عمل كل سطر على حده
بل إن مبرمجي Unix ذوي الخبرة
ينسخون هذا النوع من الأشياء من أصدقائهم
،ويلصقونه
.بدلاً من كتابته من البداية
يُحمّل هذا السطر الأول أحد
،الملفات التي قمتم بتنزيلها مسبقًا
.ويقوم بتمكين إكمال علامة التبويب
أما هذه الأسطر فتحدد بعض الألوان
.التي سيتم استخدامها في موجه الأوامر الخاص بك
وهذا السطر يحمّل الملف
.الآخر الذي قمت بتنزيله مسبقًا
ومن الضروري
للأشياء ذات الصلة بـ git مثل معرفات التثبيت
.أن تظهر في موجه الأوامر
هذا السطر هو ما يؤكد على أن
العلامة النجمية ستظهر في
موجه الأوامر إذا أجريت تغييرات
.على مستودع Git
كما أن هذا السطر يحدد بالفعل
.ما سيكون عليه موجه الأوامر
سيعرض موجه الأوامر
،اسم المستخدم باللون الأرجواني
أما التثبيت الذي استكشفته في الحال
.أو الأشياء الأخرى ذات الصلة بـ Git فستظهر باللون الأخضر
ثم يظهر URN الموجِّه متبوعًا
.بعلامة الدولار باللون الأزرق
ثم سيظهر أي نص بعد ذلك
.باللون الافتراضي
إذا كنتم تتوقون لمعرفة المزيد
،عن كيفية عمل موجهات الأوامر في bash
فعليكم استكشاف الرابط ذي الصلة الموجود في ملاحظات
المدرب، ولكن ذلك غير ضروري بالنسبة
.لبقية هذه الدورة التدريبية
بعد ذلك، من المهم التأكد
من أنكم قمتم بتشغيل محرر النصوص
المفضل من الوحدة الطرفية حتى
تتمكنوا من تعيينه
.كمحرركم الافتراضي داخل Git
.سأريكم كيف تفعلون ذلك مع Sublime
،أما من كان منكم يستخدم محرر نصوص آخر
فأنا أنصحكم بالبحث على Google لمعرفة
.كيفية استخدامه من المحطة الطرفية
والآن، سأشغل Sublime من
.من الوحدة الطرفية عن طريق تشغيل هذا الأمر الطويل
فها هو المكان الذي يختزن عليه Sublime
على جهاز الكمبيوتر، ولكنني
.أريد أن أختصر الأمر
لإنشاء مكان آخر، سأستخدم Sublime لإضافة
.سطر إلى bash profile
يُذكر أن الملفات التي تبدأ أسماؤها
بنقطة لا تظهر بالضرورة في
مستكشفات أنظمة الملفات، لذلك
سأواجه مصاعب في فتح
.bash profile باستخدام Sublime
وللتغلب عليها، سأستخدم حيلة
نقل bash profile
إلى ملف لا يشتمل على نقطة في
.أول اسمه
ثم سأفتح الملف في Sublime، حيث
،سأتنقل أولاً إلى دليلي الرئيسي
.وذلك عن طريق الضغط على المفاتيح Cmd+Shift+H
ثم سأحدد
.الملف bash_profile
ثم سأضيف هذا السطر إليه
لجعل الأمر subl يعني
نفس الأمر الذي
.رأيتموني أدخله من قبل
يمكنكم نسخ هذا السطر
ولصقه من ملاحظات المدرب
.إذا كنتم تستخدمون Sublime
والآن سأحفظ الملف
وسأغير اسمه مرة أخرى لكي أضع له نقطة
.في أوله باستخدام الوحدة الطرفية
،إذا لم أفعل ذلك
فلن يتم تفعيل bash profile
.عند فتح الوحدة الطرفية
ومرة أخرى أؤكد أن هذا الأمر لن يعمل
.إلا بعد أن أُعيد تشغيل الوحدة الطرفية
والآن سأكوّن Git لاستخدام
Sublime كمحرري الخاص
.مع أشياء مثل رسائل التثبيت
ولإجراء ذلك، سأشغل الأمر git config
global core.editor--
وهنا أحتاج إلى وضع علامتي اقتباس
.بالأمر لفتح محرر النصوص الخاص بي
.وبالنسبة إلى Sublime نكتب subl -n -w
حيث تفتح -n
،محرر النصوص Sublime في نافذة جديدة
وستنتظر -w حتى تغلقوا
.ملفاتكم قبل المتابعة
،أما إذا كنتم تستخدمون محررًا مختلفًا
فستحتاجون إلى تعديل هذا الجزء من الأمر
.لاستخدام المحرر الذي ترغبون فيه
راجعوا ملاحظات المدرب لمعرفة
.المزيد من التفاصيل
ثم سأشغل أمري
،git config هذين
واللذين سيتم شرحهما بشكل وافٍ
.فيما بعد خلال الدورة التدريبية
يرجى نسخ هذين
الأمرين ولصقهما من
.ملاحظات المدرب، ثم تشغيلهما
وفي النهاية، سأغلق الوحدة الطرفية ثم
.أعيد فتحها
والآن يمكنني رؤية التغييرات التي حدثت على موجه الأوامر
.ليصبح أغنى بالألوان
وإذا أردت أن أرى
،bash profile باستخدام Sublime
.فيمكنني تشغيل subl .bash_profile
لا تنسوا إغلاق الوحدة الطرفية
وإعادة فتحها عند الانتهاء، وإلا
.فلن يتم تنفيذ التغييرات التي أجريتموها
Mac 환경에서 작업 공간을
설정하는 과정을
함께 해 보도록 하겠습니다
Linux 도 이와 유사합니다
강의 노트에도
지시 사항이 있습니다
윈도우를 사용한다면
이전 영상을 참고하세요
먼저 전에 보여드린
설정에 필요한
파일을 두개 다운로드 하는데
하나는 탭 완성이고
다른 하나는 프롬프트 설정입니다
파일을 다운로드하기 위해
웹페이지로 가겠습니다
파일 링크는
강의노트를 참고하세요
우 클릭을 한 후
다른 이름으로 저장을 합니다
파일을 다운로드 디렉터리에
저장하겠습니다
확장자 숨기기를 해제해서
파일의 전체 이름을
보려고 합니다
기본적으로 .txt 파일로
이름이 바뀌어 있지만
이름을
git-completion.bash 로
바꾸고 저장하겠습니다
터미널을 사용해서
홈 디렉터리에 저장한
파일을 옮겨보겠습니다
터미널을 실행하면
홈 디렉터리에 위치하는데
cd ~ 를 입력하면
홈 디렉터리로 이동할 수 있습니다
이제 move 의 약자인
mv 명령어를 사용해
홈 디렉터리에 저장한
파일을 옮겨보겠습니다
첫 번째 인자는
옮기려고 하는 파일입니다
다운로드 디렉터리에 있는
git-completion.bash 파일이죠
이 파일을 현재 디렉터리에
같은 이름으로 이동하려고 합니다
같은 방식으로
강의 노트에 있는
git-prompt.sh 파일을
옮기겠습니다
다음으로 Terminal 의
설정을 담고있는
.bash_profile 파일을
만들어 보겠습니다
이 과정을 촬영할 때 사용한
설정 파일을 사용하길 권장합니다
다운로드 섹션에서
bash_profile_course
파일을 다운로드할 수 있습니다
그런 다음 Terminal 를 사용해서
홈 디렉터리로 옮겨줍니다
.bash_profile 이름의 맨 앞에
. 이 있다는 것에 주의하세요
이미 bash 개요 파일이 있다면
이 단계는 하지 마세요
대신에 원한다면
파일의 내용만
복사해서 붙여 넣어도 됩니다
만약 Linux 를 사용한다면
파일 이름을
.bashrc 로 해주세요
아직 프롬프트에
아무 변화도 없는데
효과가 나타나려면
Terminal 을 재 시작해야 합니다
영상의 마지막에
해 보겠습니다
bash profile 이
어떤 내용인지 궁금하거나
각 줄이 어떤 기능인지
궁금하실지 몰라서
앞으로 설명해 드리겠습니다
각 줄이 어떻게 작동하는지
이해가 안 돼도 너무 걱정하지 마세요
숙련된 UNIX 프로그래머도
때때로 직접 작성하기보다는
친구로부터 복사해서
쓰기도 하니까요
첫 번째 줄은
탭 완성을 위해 다운로드한
파일을 불러옵니다
이 줄은 프롬프트에 사용할
색을 설정합니다
이 부분은 다운로드한
다른 파일을 불러오는 부분인데
이 파일은 Git 과 관련해서
커밋 ID 를 보여주는
기능을 합니다
이 부분은 저장소에
변경점이 있을 때
프롬프트에 * 기호가
나타나는 부분입니다
프롬프트를 설정하는 부분입니다
사용자 이름을 보라색으로
현재 체크아웃한 커밋을 녹색으로
현재 디렉터리 URN 을
$ 뒤에 파란색으로 보여줍니다
이 외의 것들은
기본 값으로 보여줍니다
bash 에서 프롬프트가
작동하는 원리를 더 알고싶다면
강의노트의 링크를 참조하세요
이번 코스에서 필수는 아닙니다
다음으로 자주 사용하는
텍스트 편집기를
Terminal 에서 실행해서
Git 에서도 기본값으로
사용할 수 있도록 합니다
Sublime 을 사용하도록
설정해 보겠습니다
다른 텍스트 편집기를 사용한다면
Terminal 에서 사용 방법을
구글을 통해 찾아보세요
이 긴 명령어를 실행하면
Terminal 에서 Sublime 을 실행합니다
이 부분은 컴퓨터에
Sublime이 설치된 위치인데
좀 더 간단하게
사용하고 싶습니다
bash profile 에 추가해서
Sublime 을 사용해 보겠습니다
이름 앞에 . 이 있는 파일은
숨김 파일이기 때문에
파일 탐색기에서
보이지 않습니다
따라서 bash profile 을 여는 것이
조금 까다로울 수 있습니다
bash profile 파일에서
이름의 맨 앞에 있는
. 을 없애는 방식을
사용하겠습니다
Sublime 을 실행해서
파일을 열어주는데
Cmd + Shift + H 를 눌러
홈 디렉터리로 이동해서
bash_profile 파일을
선택합니다
이제 subl 이라는 명령어를
추가해 주는데
전에 봤던 명령어와
같은 명령어 입니다
Sublime 을 사용한다면
강의 노트에서 복사해서 쓰세요
파일을 저장한 다음에는
Terminal 을 사용해서
파일 이름에 다시 .을 추가합니다
만약 이 작업을 하지 않으면
Terminal 을 실행할 때
아무 효과가 없을 것입니다
이 명령들은 Terminal을
재 시작해야 효과가 있습니다
Git 에서 커밋 메시지처럼
편집기를 사용하는 경우에
Sublime 을 사용하도록
설정해 보겠습니다
git config --global core.editor
입력한 다음 그 뒤에
큰 따옴표 안에 편집기를 실행하는
명령어를 넣어줍니다
Sublime 의 실행은
subl -n - w 입니다
-n 은 편집기를
새 창에서 연다는 의미이고
-w 는 계속 하기 전에
편집기를 닫아야 한다는 의미입니다
만약 다른 편집기를 사용한다면
해당 편집기를 실행하는
명령어로 바꿔줘야 합니다
강의 노트에서
자세한 내용을 확인하세요
그다음 두 가지 명령어를
더 추가해 주는데
이 코스의 나중에
편리하게 사용할 것입니다
강의 노트에서 복사해서
그대로 실행해 주세요
마지막으로 Terminal 을
재시작 하겠습니다
프롬프트에 색이
들어간 것을 볼 수 있습니다
Sublime 을 통해서
bash profile을 보려면
subl .bash_profile
명령어면 가능합니다
설정을 바꾸고 난 다음
재시작을 해야 한다는 것을
기억하세요
Agora, vou mostrar
o processo de configuração de
seu espaço de trabalho no Mac.
E o processo no Linux é semelhante.
Também há instruções por escrito
nas Notas do instrutor.
Se você está usando o Windows,
as instruções estão no vídeo anterior.
Primeiro, vou baixar
dois arquivos que são necessários para
a configuração que acabei de mostrar;
um para habilitar a conclusão de guia
e outro para habilitar os recursos especiais
do Git no prompt.
Então, vou para a página da Web
com o primeiro arquivo;
você encontra o link para esse
arquivo nas Notas do instrutor.
Depois, clico com o botão direito em qualquer lugar
da página e seleciono Save As.
Vou salvar o arquivo no
meu diretório Downloads.
Agora quero assegurar que
a opção Hide extension esteja desmarcada,
de forma que possa ver o nome exato
que o arquivo terá.
Por padrão,
ele sugere Redirecting.txt.
Mas quero alterar esse nome
para git-completion.bash;
depois, eu salvo o arquivo.
Agora, quero mover o arquivo
para meu diretório raiz,
o que vou fazer usando o Terminal.
Quando abro o Terminal pela primeira vez,
inicio em meu diretório raiz,
ou posso digitar cd ~
para chegar a ele, se necessário.
Vou usar o comando mv,
que quer dizer mover,
para mover o arquivo que acabei de
salvar para meu diretório raiz.
O primeiro argumento é
o arquivo que quero mover,
que está no meu diretório Downloads,
e se chama git-completion.bash.txt.
Quero movê-lo para o diretório atual,
mantendo o mesmo nome.
Em seguida, seguirei o mesmo processo
para salvar o segundo arquivo, vinculado às
Notas do instrutor como git-prompt.sh.
Depois vou criar
um arquivo chamado .bash_profile,
que contém a configuração
para o Terminal.
Eu recomendo o uso do arquivo de configuração
que usei ao filmar o curso.
Para fazer isso, você pode baixar o arquivo
bash_profile_course na
seção de downloads.
Em seguida, use o Terminal para mover
este arquivo para seu diretório raiz.
Chame-o de .bash_profile e
não se esqueça do ponto no início.
Se você já tem um .bash_profile,
não execute este comando;
em vez disso você pode copiar e
colar o conteúdo deste arquivo
no .bash_profile existente.
Se você está executando o Linux,
talvez seja necessário nomear esse arquivo como
.bashrc, em vez de .bash_profile.
Ainda não vejo as alterações feitas em meu prompt,
isso ocorre porque preciso
fechar e reabrir o Terminal
para que as alterações tenham efeito.
Vou fazer isso
no final do vídeo.
Caso você esteja curioso sobre
o que há neste .bash_profile
ou queira escolher apenas
as linhas de seu interesse,
vou dizer o que cada linha faz.
Mas não se preocupe se você não
entende como cada linha funciona.
Até mesmo programadores experientes em Unix
copiam e colam esse tipo de
coisa de seus amigos com frequência,
em vez de escrevê-lo do zero.
A primeira linha carrega um dos
arquivos que você baixou antes e
habilita a conclusão de guia.
Estas linhas definem algumas cores
que serão usadas no seu prompt.
Esta linha carrega o outro
arquivo que você baixou antes.
E é necessária para que
as coisas relacionadas ao git,
como IDs de commit, apareçam em seu prompt.
Esta linha é o que garante que
o asterisco apareça no prompt
se você fizer alterações
em um repositório git.
E esta linha realmente
define como será o prompt.
O prompt mostrará
seu nome de usuário em roxo,
o commit do qual você fez check-out
ou outros itens relacionados ao git em verde.
E o diretório no qual você está
seguido de um cifrão em azul.
Todo o texto que vem depois disso
será exibido na cor padrão.
Se você estiver curioso para saber mais
sobre como os prompts funcionam no bash,
confira o link nas Notas do instrutor,
mas não é necessário fazer isso
para o restante do curso.
Em seguida, é importante garantir
que você possa iniciar seu
editor de texto favorito a partir do
Terminal, de forma que possa defini-lo
como editor padrão no git.
Vou mostrar como fazer isso para o Sublime.
Se você está usando outro editor de texto,
recomendo procurar no Google para descobrir
como usá-lo a partir do Terminal.
Eu posso iniciar o Sublime de dentro do
Terminal executando este longo comando.
Este é o local onde o Sublime
está armazenado em meu computador,
mas eu gostaria de ter um atalho.
Para criar um, vou usar o Sublime para
adicionar uma linha ao meu .bash_profile.
Normalmente, os arquivos com um ponto
no início do nome não aparecem nos
exploradores do sistema de arquivos.
Por isso, vou ter problemas para abrir
meu .bash_profile com o Sublime.
Para corrigir isso, vou usar o truque
de mover meu .bash_profile
para um arquivo sem um ponto
no início do nome.
Depois, para abrir o arquivo no Sublime,
primeiro navego até meu diretório raiz,
o que posso fazer pressionando Cmd+Shift+H.
Então, seleciono
o arquivo bash_profile.
Vou adicionar esta linha a ele para
fazer o comando subl corresponder
ao mesmo comando que você
me viu inserir antes.
Você poderá copiar e colar
esta linha das Notas do instrutor,
se estiver usando o Sublime.
Agora vou salvar o arquivo e
mudar seu nome novamente usando o Terminal
para que haja um ponto no início do nome.
Se eu não fizer isso,
o .bash_profile não terá
efeito quando eu abrir o Terminal.
Novamente, este comando não funcionará
até que eu reinicie o Terminal.
Agora, vou configurar o git para
usar o Sublime como meu editor de
coisas como mensagens de commit.
Para fazer isso, vou executar git config
--global core.editor e,
aqui, preciso inserir, entre aspas duplas,
o comando para abrir meu editor de texto.
Para o Sublime, é subl -n -w.
Onde -n abrirá o
Sublime em uma nova janela,
e -w aguardará até você fechar
seu arquivo para continuar.
Se você usar outro editor,
precisará modificar esta parte do
comando para usar o editor desejado.
Veja as Notas do instrutor
para obter mais detalhes.
Em seguida, vou executar
estes dois comandos git config,
que serão úteis
mais adiante neste curso.
Copie e cole
esses comandos das
Notas do instrutor e execute-os.
Por fim, vou fechar e reabrir
o Terminal.
Agora, posso ver que meu prompt mudou,
tornando-se mais colorido.
Se quiser ver meu perfil
bash usando o Sublime,
posso executar subl .bash_profile.
Lembre-se de fechar e
reabrir o Terminal quando terminar, ou
suas alterações não terão efeito.
现在我将为你演示
在 Mac 上设置工作区
的流程
该流程与在 Linux 上的设置流程类似
教师笔记中也有
相关说明
如果你使用的是 Windows
先前视频中也有说明
首先 我会下载两个文件
这两个文件是我
为你演示设置时需要用到的文件
一个用于启用 tab 补全
还要启用提示符中的
特殊 Git 功能
所以 我转到第一个
文件所在的网页
你可以在教师笔记中
找到此文件的链接
然后右键单击页面上的
任何位置并选择“另存为”
由此可将文件保存在
我的下载目录中
现在 我要确保取消选中
“隐藏扩展名” 以便
我可以看到此文件的
确切名称
默认情况下
建议使用 Redirecting.txt
但是 我要将其更改
为 git-completion.bash
然后保存文件
现在 我要将文件
移动到我的主目录中
我会使用终端执行此操作
首次打开终端时
我会进入我的主目录
如有必要 我可以输入 cd ~ 获取
主目录
现在 我会使用命令 mv
该命令表示
移动 来移动我刚刚保存
在我的主目录中的文件
第一个参数是
我要移动的文件
它位于我的下载目录中
其名称为 git-completion.bash
我要将其移动到当前的目录
同时保留相同的名称
随后 我会通过相同的流程
将通过教师笔记中的链接下载的
第二个文件另存为 git-prompt.sh
接下来 我要创建一个文件
将其命名为 .bash_profile
此文件包含终端的
配置
我推荐使用我在录制
本课程时使用的配置文件
为此 你可以在“可下载内容”部分
下载名为 bash_profile_course 的
文件
然后使用终端将此文件
移动到你的主目录
你可以将其命名为 .bash_profile
不要忘记前面的圆点
如果你已经有了 bash 配置文件
则不要运行此命令
你可以复制
此文件中的内容 再粘贴到
现有的 bash 配置文件
如果你正在运行 Linux
那么可能需要将此文件命名
为 .bashrc 而不是 .bash_profile
现在 我看到我的提示符未进行
任何更改 这是因为我
需要关闭终端 然后再重新打开
这样 更改才会生效
我会在视频结束时
演示此操作
如果你想知道
此 bash 配置文件的内容
或者如果你要挑选
你感兴趣的行
那么 我会展示每行的内容
所以 不要担心
你不了解每行的工作原理
即使是经验丰富的 Unix 程序员
也会频繁地复制和粘贴
其朋友的内容
而不是自己从头编写
第一行加载了你之前下载
的一个文件 并
启用了 tab 补全
这些行定义了一些颜色
你可能会在提示符中用得到
这一行加载了你之前下载
的另一个文件
并且它对于要在
你的提示符中显示一些 git 相关
内容来说是十分必要的 如提交 ID
这一行用于确保在你
对 git 存储库进行更改时
可以在你的提示符中
显示星号
而这一行实际上定义了
提示符的内容
提示符用紫色
显示你的用户名
你当前检出的提交或
其他 git 相关内容为绿色
美元符号后面的
控制器 URN 为蓝色
之后的任何文本
均为默认的颜色
如果你想了解
如何在 bash 中使用提示符
请检出教师笔记中的链接
但是 这对于本课程的
剩余部分来说并不是必要的
接下来 重要的是确保
你可以通过终端启动
你所喜爱的文本编辑器
这样 你便能够在 git 中将其
设置为你的默认编辑器
我会介绍对于 Sublime 该如何操作
如果你正在使用其他文本编辑器
我建议你通过 Google 搜索其
在终端中的使用方法
现在 我通过运行这个长命令便
可以在终端启动 Sublime
Sublime 存储在我计算机中
的这个位置 但是
我比较喜欢创建一个快捷方式
要创建快捷方式 我需要使用 Sublime 将
行添加到我的 bash 配置文件
名称前面有圆点的文件
通常不会显示在
文件系统管理器中
这就是说 我在使用 Sublime 打开
我的批处理配置文件时出现了问题
要修复此问题 我需要使用一个小窍门
将我的 bash 配置文件移动到
名称前面没有圆点
的文件中
然后在 Sublime 中打开此文件
我会首先通过按 Cmd+Shift+H 键
导航到我的主目录
然后选择
文件 bash_profile
再将此行添加到文件中
以便用 subl 命令表示
我之前输入的
相同命令
如果你正在使用 Sublime
你可以复制教师标记
中的此行 然后进行粘贴
现在 我会保存文件
再使用终端将其名称改回
之前带有圆点的名称
如果我不这样做
那么在我打开终端之后
bash 配置文件便不会生效
再强调一次 无法使用此命令
除非我们重启终端
我现在将 git 配置为
将 Sublime 用作编辑器
来编辑如提交消息之类的文本
要执行此操作 我需要运行 git config
--global core.editor
在这里 我需要将命令加上双引号
来打开我的文本编辑器
对于 Sublime 来说 命令是 subl -n -w
其中 -n 是在新窗口中
打开 Sublime
而 -w 是在你关闭文件之后
再继续操作
如果你使用不同的编辑器
你需要对命令的此部分进行修改
以使用你喜爱的编辑器
请参阅教师笔记了解
更多详细信息
接下来 我会运行
这两个 git config 命令
在本课程的后面部分
将会用到它
请复制和粘贴
教师笔记中的这些命令
以便稍后运行
最后 我会关闭终端
然后再重新打开
现在我可以看到我的提示符
颜色更加丰富了
如果要使用 Sublime 查看
我的 bash 配置文件
我可以运行 subl .bash_profile
切记在你完成之后关闭终端 然后
再将其重新打开 否则
你的更改不会生效