However, if you’re like me and often working in a git repository, it’s nice to have your current branch displayed in your prompt. bash_prompt.Īt this point, your Terminal should look something like this: To apply your changes, simply execute the command. Remember, to exit and save your file, press Ctrl+X, then Y, then the Return key. Add this under your PS1 line: export PS1 Let’s export that and see what it looks like. The syntax might seem a bit weird, but it’s interesting to learn about if you’re curious! Basically, we’re getting the current username with \u, wrapping that in a specific colour, 0 93m, and adding in the proper escape sequences. bash_prompt file: # TERMINAL PROMPT PS1="\\u\" # username PS1 is the primary prompt displayed in the Terminal before each command. Let’s start setting up our prompt.There are a few different prompts you can customize, but we’ll stick to PS1 for this tutorial. Now, we’re going to want to make sure colours are enabled so our prompt looks nice! Add these 2 lines to do that: export CLICOLOR=1 export LSCOLORS=ExFxBxDxCxegedabagacadĬLICOLOR turns colours on, and LSCOLORS customizes them. Add this line to the top of your file: #!/usr/bin/env bash The layout I like for my prompt is - name directory (git-branch) > |įirst, let’s put a shebang at the top of our file so our system knows it’s bash. Now open up the file in the nano editor: nano. This is definitely a personal preference, so make sure to customize it to your liking!įirst, create your. bash_prompt file is going to contain the commands to set a custom bash prompt. That’s it! To save, simply press Ctrl+X, then Y, then the Return key, then apply your changes with the command. With the nano editor open, add these lines: source ~/.bash_prompt source ~/.aliases bash_profile for is to source the other dotfiles. You could add all the configuration information in this file if you wanted, but I like to split it up for better maintainability. The nano editor should open with your new. To edit your file, run the command: nano. bash_profile file, run the command: touch. Let’s make sure we’re in the home directory. This is the first file that is read and executed when you open up your Terminal, so it’s important!
CREATE FILE ON MAC COMMAND LINE FREE
Feel free to use vim, emacs, or whatever editor you’re most comfortable with! To edit these files, we’ll just be using the nano editor as we only need to add and save a few lines. Over the next few steps, we’ll be creating some dotfiles to configure our Terminal experience. If you want to improve it even more though, keep following along! Step 3: Configuring. And, in case you want to stop a command you've input, you can do that by tapping the window (if it isn't already selected) and holding down the "control" key and hitting "c." Or, if you want to repeat a command, simply use the up arrow key to cycle through previously used commands and, when you see the one you want, press "return."ĭon't worry if you make a mistake in your command pathways: You'll just get a message back saying something along the lines of, "No such file or directory exists.If you wanted to leave it here, you definitely could! It looks a bit better than the default. If you need to get to your Terminal's settings, hold down the command key while tapping the comma button. Note that the file pathway is also fundamental here. Open -a "APP NAME" Open a text-based file using the text editor: Open Open a file using an application you specify:Īgain, you'll need the file pathway to use this command. In either case, hit the spacebar following the app name and then the command would take hold.
CREATE FILE ON MAC COMMAND LINE FULL
Even though the latter appears to only copy the actual file name, it actually captures the full pathway. To do so, you can either drag the file to the Terminal window to add to the line, or right click the file and select "Copy " and then use the Command+V shortcut to paste it into the Terminal. Open -a "APPLICATION NAME" Open a file using the default application:įor this, you'll have to know the command pathway for the file you want to access. Or, if the application has a space in its name: If you input this exact phrasing, Terminal will open your Spotify app.