Skip to content

Instantly share code, notes, and snippets.

@p1nesap
Created December 14, 2014 00:35
Show Gist options
  • Save p1nesap/2442748e8cde4b541f80 to your computer and use it in GitHub Desktop.
Save p1nesap/2442748e8cde4b541f80 to your computer and use it in GitHub Desktop.
Fun with operators, conditionals and exported functions.
#!/bin/bash
#Fun with operators, conditionals and exported functions. Notes below.
y=$(date +%Y)
d=$(date +%d)
m=$(date +%m)
u=`whoami`
s=`pwd`
if [ $d -lt 25 ] && [ $m == 12 ] && [[ "$s" == *"home/phoebe/shell"* ]]
then
echo "Hi $u, it's before Christmas, and you're in shell directory!"
else [ $m -lt 12 -a $m -ge 1 ] || [[ "$s" != *"home/phoebe/shell"* ]]
echo "Hi $u, it's past Christmas, or you're not in shell directory."
echo -n "Type which directory, shell or Videos: "
read directory
if [[ $directory == "shell" ]]
then
cdshell
elif [[ $directory == "Videos" ]]
then
cdVideos
else
echo "Invalid choice."
fi
fi
: '
Open file with . /path to free source, in ~/.bashrc:
function cdshell() {
cd /home/phoebe/shell "$@"
}
export -f cdshell`
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment