#!/bin/bash #!/bin/bash # Function to display the file explorer display_files_and_head() { # Clear the screen clear # Get the current directory local current_dir=$(pwd) # Get the number of rows and columns in the terminal local rows=$(tput lines) local cols=$(tput cols) # Split the terminal into two panes local left_pane=$((cols/2)) local right_pane=$((cols-left_pane)) # Print the file listing in the left pane echo -ne "\033[1;32m" # Orange color ls -1 | nl -w2 -s ' ' | awk -v c=$left_pane '{ printf "%-*s", c, $0 }' echo -ne "\033[0m" # Reset color echo # Print the head of the selected file in the right pane echo -ne "\033[1;33m" # Yellow color head -n10 $1 | awk -v c=$right_pane '{ printf "%-*s", c, $0 }' echo -ne "\033[0m" # Reset color echo echo -ne "\033[1;36m" # Cyan color # Print the menu options at the bottom echo "1) Copy file" echo "2) Move file" echo "3) Rename file" echo "4) Edit file" echo "5) Run shell command" echo "6) Exit" echo -ne "\033[0m" # Reset color echo # Print the time and date at the bottom echo $(date +"%T %D") } # Start the file explorer # Get the file listing file_list=($(ls -1)) num_files=${#file_list[@]} file_index=0 while true; do # Get the current file file=${file_list[$file_index]} display_files_and_head $file # Wait for input read -sn1 input case $input in 'A') # Up arrow if [[ $file_index -gt 0 ]]; then ((file_index--)) fi ;; 'B') # Down arrow if [[ $file_index -lt $((num_files-1)) ]]; then ((file_index++)) fi ;; 'C') # Right arrow if [[ -d $file ]]; then cd $file file_list=($(ls -1)) num_files=${#file_list[@]} file_index=0 fi ;; 'D') # Left arrow if [[ $(pwd) != '/' ]]; then cd .. file_list=($(ls -1)) num_files=${#file_list[@]} file_index=$((num_files-1)) fi ;; '1') # Copy file echo "Enter the destination path:" read dest_path cp $file $dest_path ;; '2') # Move file echo "Enter the destination path:" read dest_path mv $file $dest_path ;; '3') # Rename file echo "Enter the new name:" read new_name mv $file $new_name ;; '4') # Edit file nano $file ;; '5') # Run shell command echo "Enter the command:" read command eval $command ;; 6) # Exit exit ;; esac done