35
loading...
This website collects cookies to deliver better user experience
git commit -m
? alias <alias name>='<the bash command to be aliased>'
'='
, your alias will not work.user:~$ alias project='cd Development/code/my-awesome-project/'
user:~$ project
user:~/Development/code/my-awesome-project$
project
in the command line. project
again, I get the following error:user:~$ project
Command 'project' not found, did you mean:
command 'projectx' from deb project-x (0.90.4dfsg-0ubuntu5)
command 'projectl' from deb projectl (1.001.dfsg1-9build3)
Try: sudo apt install <deb name>
project
was unique to the session I defined it in! alias
in your command line.cd ~
ls -a
to list all of the directory files, including system files.bash_aliases
. If it doesn't exist, create it: touch .bash_aliases
Run vi .bash_aliases
to enter the Vim text editor. The file should look something like this:
Press 'i' to enter Insert mode
Now, we can use our syntax from before to define our own, persistent aliases. Here are some simple examples:
alias a='add .'
alias cm='commit -m'
alias be='bundle exec'
alias fi-ruby='cd ~/Development/code/ruby-phase-3'
Once you're happy with your aliases, hit Ctrl + C to leave Insert mode.
To save your edits and exit Vim, type :wq!
and hit Enter.
You should be back in your terminal. Close your terminal.
Reopen the terminal and run alias
. This will print a list of all of the persistent aliases associated with your user profile. Check that the ones you just created are included among them. If not, go back through the above steps.