Browse Source

Move nf command to separate file

George Jones 6 months ago
parent
commit
4f854820ad
1 changed files with 0 additions and 52 deletions
  1. 0 52
      .bashrc

+ 0 - 52
.bashrc

@@ -403,58 +403,6 @@ function lss() { ls -A1s $color ${*:-} | sort -n; }
 # List Sort Size Reverse
 function lssr() { ls -A1s $color ${*:-} | sort -nr; }
 
-
-# Usage: nf [#] [DIRECTORY]
-# list the newest file in the current directory (or $1)
-nf() (
-
-  NUM=1
-  DIR="$PWD"
-
-  if [[ "$1" =~ ^[0-9]+$ ]]; then
-    NUM="$1"
-  fi
-
-  if [[ "$2" =~ ^[0-9]+$ ]]; then
-    NUM="$2"
-  fi
-
-  if [ -d "$1" ]; then
-    DIR="$1"
-  fi
-
-  if [ -d "$2" ]; then
-    DIR="$2"
-  fi
-
-  # TODO fix case where invoked as
-  #
-  #      nf GARBAGE
-  #
-  # should fail with no directory
-
-  if [[ "$NUM" == 0 ]]; then
-     NUM=1
-  fi
-
-  if [ -d "$DIR" ]; then
-    # Check if the argument is a valid directory
-    \cd "$DIR" || die "$DIR is not a directory"
-    # Use find to locate only files, not directories, and list them by modification time
-    latest_file=$(find . -maxdepth 1 -type f -exec stat -c "%Y %n" {} + | sort -n -r | head -n $NUM | awk '{print $2}')
-
-    if [ -n "$latest_file" ]; then
-      echo "$latest_file"
-    else
-      warn "No files found in the $DIR"
-    fi
-  else
-    info "Usage: $PROGNAME DIRECTORY"
-    warn "$DIR is not a directory"
-    return 1
-  fi
-)
-
 if [[  ! -z "`which xdg-open`" ]]; then
     alias open='xdg-open ';
     export OPEN='xdg-open ';