Skip to content

Instantly share code, notes, and snippets.

@melaniehoff
Last active September 24, 2024 20:20
Show Gist options
  • Save melaniehoff/32b14210b7ea6f605f625eabdf8b3968 to your computer and use it in GitHub Desktop.
Save melaniehoff/32b14210b7ea6f605f625eabdf8b3968 to your computer and use it in GitHub Desktop.
Bash & Terminal Commands (For Folder Poetry)

🎲 Bash & Terminal commands

Command Description
cd change directory
cd .. change directory one level back
ls list contents of directory
pwd print working directory
mkdir foldername create a folder named foldername
touch dandelion.txt create a file named dandelion.txt
echo "woof woof" > kitty.txt creates a text file called kitty.txt that contains the words, "woof woof"
cat filename.txt print contents of file
atom filename.txt Opens file in atom (this is why we installed the shell commands!)
source ~/.bash_profile (macOS) restart your terminal config file
source ~/.bashrc (Windows) restart your terminal config file
rm -rf filename.txt . remove a file or folder this way (BE CAREFUL TO NOT DELETE ANYTHING UNINTENDED
mv filename.txt newfilename.txt rename a file
open . (macOS) open the current folder in Finder
explorer . (Windows) open the current folder in Explorer
open filename.txt (macOS) opens file in Text Edit
notepad.exe filename.txt (Windows) opens file in Notepad
cp filename.txt filename2.txt copy file
say "hello, what is poetic computation?" (macOS) speak out loud
https://superuser.com/questions/223913/os-x-say-command-for-windows (Windows) speak text out loud
man cd show the manual for 'cd'. Press q to quit
curl wttr.in check the weather in our local locations!⛅️🌧🌈

Keyboard Terminal Shortcuts

Command Description
Up + Down Arrow keys scroll through history
Tab Key autocomplete
CMD + CTRL + SPACE Emoji Keyboard (Mac OS) 🍒🦋💌🥬

Editing a text file

command Description
echo "woof woof" > kitty.txt creates a text file called kitty.txt that contains the words, "woof woof"
nano textfile.txt open file in the nano text editor
CTRL + X , y , ENTER exit and save changes

Editing your Bash config file

  • In these steps, we are using terminal and nano to open and edit a file called ~./bash_profile
  • In steps 2-4, the lines of code are meant to be pasted into nano when editing the ~./bash_profile
  • In the other steps, the commands are entered in terminal

The ~./bash_profile or ~./bashrc is a configuration file for the terminal.

First make sure you are running bash instead of zsh by running this command: chsh -s /bin/bash

You can use an editor called nano that is built into terminal instead of using a separate editor like vs code

  • Macs:

    • Nano: nano ~/.bash_profile
    • Vs code: code ~/.bash_profile
  • Windows: nano ~/.bashrc

    • This command will open your ~./bashrc in nano

Remember to reboot your terminal

Mac:source ~/.bash_profile Windows: source ~/.bashrc

OR close and reopen terminal : ) OR if you created an alias for this, enter sp (short for source profile) : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment