Como alternar entre dois diretórios na linha de comando do Linux

00_lead_toggling_between_two_directories

Se você estiver trabalhando com arquivos no Terminal e alternando entre dois diretórios, vamos economizar algum tempo. Existe um comando de atalho que permite alternar entre dois diretórios na linha de comando.

Primeiro, como de costume, mude para o primeiro diretório digitando o seguinte comando no prompt e pressionando Enter.

CD Primeiro / Diretório /

Onde First/Directory/ é o nome do diretório para o qual você deseja mudar.

You can also use tab completion to enter the directory name by typing a few characters in the name and then pressing Tab to finish entering the name.

01_changing_to_first_directory

Now, we want to switch to a second directory, so we use the cd command and tab completion again.

02_changing_to_second_directory

Now, instead of typing the first directory name to go back to that directory, you can type the following command at the prompt and press Enter.

cd -

That’s simply the cd command followed by a space and then a dash. The name of the directory you’re toggling to displays and then you’re taken to that directory.

03_changing_back_to_first_directory

To toggle back to the second directory again, use the cd - command again.

04_changing_back_to_second_directory

You can also press the up arrow key once to access the last command used from the command line history, which in this case was cd -. So, at this point, to toggle back and forth between these two directories, all you do it press the up arrow key and Enter. That’s quicker than typing out the path each time, even when you use tab completion.

Recomendado:  Os pequenos botões do menu de contexto do Windows 11 vão confundir as pessoas