When I am in the terminal, if is there a way to set shortcuts for commands? For example, if I type "g" make it equal "git", and if I type "gs" make it equal "git status". etc?
            Asked
            
        
        
            Active
            
        
            Viewed 1,202 times
        
    1 Answers
5
            You can use the bash alias command.
Edit your ~/.bash_profile file (for Mac) and add the following to the end.
alias g="git"
alias gs="git status"
Changes will take any effect for any new terminals, but not ones that are already open.
 
    
    
        njha
        
- 1,118
- 1
- 13
- 24
- 
                    @njha I think Nikos comment is correct. It works in bash_profile but not in .profile. – SilentDev Mar 13 '19 at 02:10
- 
                    1`.bash_profile` will override `.profile`. Also, it's not sourced for `sh`, only for `bash`, which makes it a good idea to put aliases in `.bash_profile` instead of `.profile` since you don't want aliases to interfere with scripts that use `#!/bin/sh`. – Nikos C. Mar 13 '19 at 02:10
- 
                    It should be noted that changes to `~/.bash_profile` will only take effect in new terminal windows. In other words, windows that were opened before the modification won't see those aliases. – focorner Mar 13 '19 at 02:17
- 
                    1@focorner that's true. You can manually reload the profile in the current terminal session with `source ~/.bash_profile`, as detailed in the answer https://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line – Jamin Kortegard Mar 13 '19 at 02:24
- 
                    1
