Created
October 2, 2023 08:52
-
-
Save mamemomonga/52d1544f9f51035925b3266c7feea651 to your computer and use it in GitHub Desktop.
長いパスのショートカットを作る
This file contains 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 | |
# https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced | |
is_sourced() { | |
if [ -n "$ZSH_VERSION" ]; then | |
case $ZSH_EVAL_CONTEXT in *:file:*) return 0;; esac | |
else # Add additional POSIX-compatible shell names here, if needed. | |
case ${0##*/} in dash|-dash|bash|-bash|ksh|-ksh|sh|-sh) return 0;; esac | |
fi | |
return 1 # NOT sourced. | |
} | |
if is_sourced; then | |
cd /path/to/super/long/long/long/long | |
else | |
echo "以下のように実行して下さい" | |
echo " . ./cd-longlonglong.sh" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment