Last active
June 28, 2022 20:07
-
-
Save kidpixo/ea63b48d16e995fdfce98b138a5ac4c9 to your computer and use it in GitHub Desktop.
quickly symlink current directory to /tmp/
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
link_to_tmp() { | |
# define colors | |
local RED = '\033[31m' # mode 31 = red forground | |
local GREEN = '\033[32m' # mode 32 = green forground | |
local RESET = '\033[0m' # mode 0 = reset | |
# no input given | |
if [ $# -eq 0 ] | |
then | |
local INPUT=$PWD | |
local OUTPUT=/tmp/$(basename $PWD) | |
# 1 input given assume OUTPUT | |
elif [ $# -eq 1 ] | |
then | |
local INPUT=$PWD | |
local OUTPUT=/tmp/$1 | |
# 2 input given assume INPUT OUTPUT | |
elif [ $# -eq 2 ] | |
then | |
local INPUT=$1 | |
local OUTPUT=/tmp/$2 | |
# more than 2 input: undifined! | |
else | |
echo "link_to_tmp" | |
echo "===========" | |
echo | |
echo "Symlink ${GREEN}INPUT-PATH${RESET} to ${RED}/tmp/OUTPUT-PATH${RESET}" | |
echo | |
echo "Usage:" | |
echo '1. link_to_tmp : assume INPUT=$PWD | OUTPUT=/tmp/$(basename $PWD)' | |
echo '2. link_to_tmp outdir : assume INPUT=$PWD | OUTPUT=/tmp/$outdir' | |
echo '3. link_to_tmp inpath outdir : assume INPUT=$inpath | OUTPUT=/tmp/$outdir' | |
fi | |
# execute the command | |
ln -s $INPUT $OUTPUT | |
echo "Symlink ${GREEN}${INPUT}${RESET} to ${RED}${OUTPUT}${RESET}" | |
} | |
alias lntmp='link_to_tmp' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment