Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #78 from dylanaraps/select_all
Browse files Browse the repository at this point in the history
general: Added select all
  • Loading branch information
dylanaraps authored Jan 28, 2019
2 parents 9dfd1be + 3249a6d commit 63891ac
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ y: mark copy
m: mark move
d: mark trash (~/.cache/fff/trash/)
b: mark bulk rename

Y: mark all for copy
M: mark all for move
D: mark all for trash (~/.cache/fff/trash/)
B: mark all for bulk rename

p: paste/move/delete/bulk_rename
c: clear file selections

Expand Down Expand Up @@ -232,6 +238,11 @@ export FFF_KEY_MOVE="m"
export FFF_KEY_TRASH="d"
export FFF_KEY_BULK_RENAME="b"

export FFF_KEY_YANK_ALL="Y"
export FFF_KEY_MOVE_ALL="M"
export FFF_KEY_TRASH_ALL="D"
export FFF_KEY_BULK_RENAME_ALL="B"

export FFF_KEY_PASTE="p"
export FFF_KEY_CLEAR="c"

Expand Down
45 changes: 32 additions & 13 deletions fff
Original file line number Diff line number Diff line change
Expand Up @@ -330,26 +330,37 @@ mark() {
[[ $PWD != "$mark_dir" ]] &&
marked_files=()

if [[ ${marked_files[$1]} == "${list[$1]}" ]]; then
unset 'marked_files[scroll]'
if [[ $1 == all ]]; then
if ((${#marked_files[@]} != ${#list[@]})); then
marked_files=("${list[@]}")
mark_dir="$PWD"
else
marked_files=()
fi

redraw
else
marked_files[$1]="${list[$1]}"
mark_dir="$PWD"
fi
if [[ ${marked_files[$1]} == "${list[$1]}" ]]; then
unset 'marked_files[scroll]'

else
marked_files[$1]="${list[$1]}"
mark_dir="$PWD"
fi

# Clear line before changing it.
printf '\e[K'
print_line "$1"
# Clear line before changing it.
printf '\e[K'
print_line "$1"
fi

# Find the program to use.
case "$2" in
y) file_program=(cp -iR) ;;
m) file_program=(mv -i) ;;
y|Y) file_program=(cp -iR) ;;
m|M) file_program=(mv -i) ;;

# These are 'fff' functions.
d) file_program=(trash) ;;
b) file_program=(bulk_rename) ;;
d|D) file_program=(trash) ;;
b|B) file_program=(bulk_rename) ;;
esac

status_line
Expand All @@ -368,7 +379,7 @@ trash() {
"$FFF_TRASH_CMD" "${@:1:$#-1}"

else
cd "$FFF_TRASH" && "mv" "$@"
cd "$FFF_TRASH" && mv "$@"

# Go back to where we were.
cd - &>/dev/null ||:
Expand Down Expand Up @@ -709,6 +720,14 @@ key() {
mark "$scroll" "$1"
;;

# Mark all files for operation.
"${FFF_KEY_YANK_ALL:=Y}"|\
"${FFF_KEY_MOVE_ALL:=M}"|\
"${FFF_KEY_TRASH_ALL:=D}"|\
"${FFF_KEY_BULK_RENAME_ALL:=B}")
mark all "$1"
;;

# Do the file operation.
"${FFF_KEY_PASTE:=p}")
[[ ${marked_files[*]} ]] && {
Expand Down
11 changes: 11 additions & 0 deletions fff.1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ y: mark copy
m: mark move
d: mark trash (~/\.cache/fff/trash/)
b: mark bulk rename

Y: mark all for copy
M: mark all for move
D: mark all for trash (~/\.cache/fff/trash/)
B: mark all for bulk rename

p: paste/move/delete/bulk_rename
c: clear file selections

Expand Down Expand Up @@ -164,6 +170,11 @@ export FFF_KEY_MOVE="m"
export FFF_KEY_TRASH="d"
export FFF_KEY_BULK_RENAME="b"

export FFF_KEY_YANK_ALL="Y"
export FFF_KEY_MOVE_ALL="M"
export FFF_KEY_TRASH_ALL="D"
export FFF_KEY_BULK_RENAME_ALL="B"

export FFF_KEY_PASTE="p"
export FFF_KEY_CLEAR="c"

Expand Down

0 comments on commit 63891ac

Please sign in to comment.