Update function mycd

Change name from cdls

Update cd alias

If cd fails and the first parameter is a file, it will try and open it
in vim
Jonathan Hodgson 7 years ago
parent ba399343fb
commit 47a6b3c315
  1. 17
      shells/functions

@ -34,14 +34,25 @@ function old() {
mv "$1" "$1.old"
}
function cdls() {
cd "$@"
function mycd() {
cd "$@" 2> /dev/null
if [ $? = 0 ]; then
# If we get here cd was successful
if [ ! $TMUX ]; then
pwd > ~/.current-folder
fi
ls
else
# If we get here, cd was not successful
if [ -f "$1" ]; then
vim "$1"
else
echo "Can't cd"
exit 1
fi
fi
}
alias cd="cdls"
alias cd="mycd"
function mkcd() {
mkdir -p "$1"

Loading…
Cancel
Save