Skip to content

Instantly share code, notes, and snippets.

@orymate
Created May 22, 2012 22:26
Show Gist options
  • Save orymate/2772045 to your computer and use it in GitHub Desktop.
Save orymate/2772045 to your computer and use it in GitHub Desktop.
my interactive zsh functions
# change to temp dir
t() {
if [ ${1:-0} -eq 0 ]
then
mkdir -p ~/temp/$(date -d "${1:-0} days ago" +%Y%m%d)
fi
cd ~/temp/$(date -d "${1:-0} days ago" +%Y%m%d)
}
# scp if any arguments contain a colon
scp () {
for i in $*
do case $i in
*:*) command scp $*
return $?
esac
done
echo No remote path parameter. Aborting.
return 1
}
# change to previous directory
p() {
cur=$(basename "$PWD")
cd $(dirname "$PWD")/$(ls $(dirname "$PWD") -a |grep -EB1 "^${cur}/?$"|head -1)
}
# change to next directory
n() {
cur=$(basename "$PWD")
cd $(dirname "$PWD")/$(ls $(dirname "$PWD") -a |grep -EA1 "^${cur}/?$"|tail -1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment