-
- Create ez-alias.sh file
-
- Add directory of the ez-alias script file to export PATH (ex: export PATH=:/$HOME/BASH)
-
- Add the command
source $HOME/BASH/aliases.sh
to $HOME/.bash_profile file and source it
- Add the command
-
- Go to any directory and launch command
ez-alias.sh
and type in the name of your alias then reboot the terminal
- Go to any directory and launch command
- Done !
Last active
May 30, 2017 21:55
-
-
Save pimeo/f7257db45366d38b428e to your computer and use it in GitHub Desktop.
command to add dynamic alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# file: $HOME/BASH/aliases.sh | |
# description: contains all directory aliases | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#file: ez-alias.sh | |
# directory of the bash script | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# directory where the bash script is called | |
ALIAS_DIR=$(pwd) | |
echo "Name of the alias: " | |
read aliasName | |
# save alias into bash file | |
echo "alias ez-$aliasName=\"cd $ALIAS_DIR\"" >> "$HOME"/Bash/ez-alias/aliases.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment