From 68b2a3730e5f9dcac1c4c2152c454d5f333c78b5 Mon Sep 17 00:00:00 2001 From: Friedrich Clausen Date: Fri, 28 Oct 2016 11:56:17 +1100 Subject: [PATCH 01/10] Quick save current directory as bookmark name if no name specified --- zshmarks.plugin.zsh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 7ee1ebc6..7d2ab5fc 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -40,25 +40,22 @@ DeletionDate="`date +"%Y-%m-%dT%H:%M:%S"`" function bookmark() { local bookmark_name=$1 if [[ -z $bookmark_name ]]; then - echo 'Invalid name, please provide a name for your bookmark. For example:' - echo ' bookmark foo' - return 1 - else + bookmark_name="${PWD##*/}" + fi cur_dir="$(pwd)" # Replace /home/uname with $HOME if [[ "$cur_dir" =~ ^"$HOME"(/|$) ]]; then - cur_dir="\$HOME${cur_dir#$HOME}" + cur_dir="\$HOME${cur_dir#$HOME}" fi # Store the bookmark as folder|name bookmark="$cur_dir|$bookmark_name" if [[ -z $(grep "$bookmark" $BOOKMARKS_FILE 2>/dev/null) ]]; then - echo $bookmark >> $BOOKMARKS_FILE - echo "Bookmark '$bookmark_name' saved" - else - echo "Bookmark already existed" - return 1 - fi - fi + echo $bookmark >> $BOOKMARKS_FILE + echo "Bookmark '$bookmark_name' saved" + else + echo "Bookmark already existed" + return 1 + fi } __zshmarks_zgrep() { From 665f64c1d322c511dd06a6fd5005d541d1538457 Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Tue, 7 Mar 2017 21:36:16 -0600 Subject: [PATCH 02/10] Added fuzzy to jump and multiple deletes to deletemark --- zshmarks.plugin.zsh | 144 +++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 63 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 7d2ab5fc..f4252563 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -13,7 +13,7 @@ fi # Check if $BOOKMARKS_FILE is a symlink. if [[ -L $BOOKMARKS_FILE ]]; then - BOOKMARKS_FILE=$(readlink $BOOKMARKS_FILE) + BOOKMARKS_FILE=$(readlink $BOOKMARKS_FILE) fi # Create bookmarks_file it if it doesn't exist @@ -21,41 +21,45 @@ if [[ ! -f $BOOKMARKS_FILE ]]; then touch $BOOKMARKS_FILE fi +fzfcmd() { + [ ${FZF_TMUX:-1} -eq 1 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" +} + _zshmarks_move_to_trash(){ - if [[ $(uname) == "Linux"* || $(uname) == "FreeBSD"* ]]; then - label=`date +%s` - mkdir -p ~/.local/share/Trash/info ~/.local/share/Trash/files - \mv "${BOOKMARKS_FILE}.bak" ~/.local/share/Trash/files/bookmarks-$label - echo "[Trash Info] + if [[ $(uname) == "Linux"* || $(uname) == "FreeBSD"* ]]; then + label=`date +%s` + mkdir -p ~/.local/share/Trash/info ~/.local/share/Trash/files + \mv "${BOOKMARKS_FILE}.bak" ~/.local/share/Trash/files/bookmarks-$label + echo "[Trash Info] Path=/home/"$USER"/.bookmarks DeletionDate="`date +"%Y-%m-%dT%H:%M:%S"`" ">~/.local/share/Trash/info/bookmarks-$label.trashinfo - elif [[ $(uname) = "Darwin" ]]; then - \mv "${BOOKMARKS_FILE}.bak" ~/.Trash/"bookmarks"$(date +%H-%M-%S) - else - \rm -f "${BOOKMARKS_FILE}.bak" - fi + elif [[ $(uname) = "Darwin" ]]; then + \mv "${BOOKMARKS_FILE}.bak" ~/.Trash/"bookmarks"$(date +%H-%M-%S) + else + \rm -f "${BOOKMARKS_FILE}.bak" + fi } function bookmark() { local bookmark_name=$1 if [[ -z $bookmark_name ]]; then - bookmark_name="${PWD##*/}" - fi - cur_dir="$(pwd)" - # Replace /home/uname with $HOME - if [[ "$cur_dir" =~ ^"$HOME"(/|$) ]]; then - cur_dir="\$HOME${cur_dir#$HOME}" - fi - # Store the bookmark as folder|name - bookmark="$cur_dir|$bookmark_name" - if [[ -z $(grep "$bookmark" $BOOKMARKS_FILE 2>/dev/null) ]]; then - echo $bookmark >> $BOOKMARKS_FILE - echo "Bookmark '$bookmark_name' saved" - else - echo "Bookmark already existed" - return 1 - fi + bookmark_name="${PWD##*/}" + fi + cur_dir="$(pwd)" + # Replace /home/uname with $HOME + if [[ "$cur_dir" =~ ^"$HOME"(/|$) ]]; then + cur_dir="\$HOME${cur_dir#$HOME}" + fi + # Store the bookmark as folder|name + bookmark="$cur_dir|$bookmark_name" + if [[ -z $(grep "$bookmark" $BOOKMARKS_FILE 2>/dev/null) ]]; then + echo $bookmark >> $BOOKMARKS_FILE + echo "Bookmark '$bookmark_name' saved" + else + echo "Bookmark already existed" + return 1 + fi } __zshmarks_zgrep() { @@ -75,6 +79,10 @@ __zshmarks_zgrep() { function jump() { local bookmark_name=$1 + if [ $# -eq 0 ]; then + local jumpline=$(cat ${BOOKMARKS_FILE} | $(fzfcmd) --bind=ctrl-y:accept --tac) + eval cd "${jumpline%%|*}" + else local bookmark if ! __zshmarks_zgrep bookmark "\\|$bookmark_name\$" "$BOOKMARKS_FILE"; then echo "Invalid name, please provide a valid bookmark name. For example:" @@ -87,50 +95,60 @@ function jump() { local dir="${bookmark%%|*}" eval "cd \"${dir}\"" fi +fi } # Show a list of the bookmarks function showmarks() { - local bookmark_file="$(<"$BOOKMARKS_FILE")" - local bookmark_array; bookmark_array=(${(f)bookmark_file}); - local bookmark_name bookmark_path bookmark_line - if [[ $# -eq 1 ]]; then - bookmark_name="*\|${1}" - bookmark_line=${bookmark_array[(r)$bookmark_name]} - bookmark_path="${bookmark_line%%|*}" - bookmark_path="${bookmark_path/\$HOME/~}" - printf "%s \n" $bookmark_path - else - for bookmark_line in $bookmark_array; do - bookmark_path="${bookmark_line%%|*}" - bookmark_path="${bookmark_path/\$HOME/~}" - bookmark_name="${bookmark_line#*|}" - printf "%s\t\t%s\n" "$bookmark_name" "$bookmark_path" - done - fi + local bookmark_file="$(<"$BOOKMARKS_FILE")" + local bookmark_array; bookmark_array=(${(f)bookmark_file}); + local bookmark_name bookmark_path bookmark_line + if [[ $# -eq 1 ]]; then + bookmark_name="*\|${1}" + bookmark_line=${bookmark_array[(r)$bookmark_name]} + bookmark_path="${bookmark_line%%|*}" + bookmark_path="${bookmark_path/\$HOME/~}" + printf "%s \n" $bookmark_path + else + for bookmark_line in $bookmark_array; do + bookmark_path="${bookmark_line%%|*}" + bookmark_path="${bookmark_path/\$HOME/~}" + bookmark_name="${bookmark_line#*|}" + printf "%s\t\t%s\n" "$bookmark_name" "$bookmark_path" + done + fi } # Delete a bookmark function deletemark() { - local bookmark_name=$1 - if [[ -z $bookmark_name ]]; then - printf "%s \n" "Please provide a name for your bookmark to delete. For example:" - printf "\t%s \n" "deletemark foo" - return 1 - else - local bookmark_line bookmark_search - local bookmark_file="$(<"$BOOKMARKS_FILE")" - local bookmark_array; bookmark_array=(${(f)bookmark_file}); - bookmark_search="*\|${bookmark_name}" - if [[ -z ${bookmark_array[(r)$bookmark_search]} ]]; then - eval "printf '%s\n' \"'${bookmark_name}' not found, skipping.\"" - else - \cp "${BOOKMARKS_FILE}" "${BOOKMARKS_FILE}.bak" - bookmark_line=${bookmark_array[(r)$bookmark_search]} - bookmark_array=(${bookmark_array[@]/$bookmark_line}) - eval "printf '%s\n' \"\${bookmark_array[@]}\"" >! $BOOKMARKS_FILE - _zshmarks_move_to_trash - fi + local bookmark_name=$1 + if [[ -z $bookmark_name ]]; then + local marks_to_delete line + marks_to_delete=$(cat $BOOKMARKS_FILE | $(fzfcmd) -m --bind=ctrl-y:accept,ctrl-t:toggle-up --tac) + + if [[ -n ${marks_to_delete} ]]; then + while read -r line; do + perl -p -i -e "s#${line}\n##g" $BOOKMARKS_FILE + done <<< "$marks_to_delete" + + echo "** The following marks were deleted **" + echo "${marks_to_delete}" + fi + else + local bookmark_line bookmark_search + local bookmark_file="$(<"$BOOKMARKS_FILE")" + local bookmark_array; bookmark_array=(${(f)bookmark_file}); + bookmark_search="*\|${bookmark_name}" + if [[ -z ${bookmark_array[(r)$bookmark_search]} ]]; then + eval "printf '%s\n' \"'${bookmark_name}' not found, skipping.\"" + else + \cp "${BOOKMARKS_FILE}" "${BOOKMARKS_FILE}.bak" + bookmark_line=${bookmark_array[(r)$bookmark_search]} + bookmark_array=(${bookmark_array[@]/$bookmark_line}) + eval "printf '%s\n' \"\${bookmark_array[@]}\"" >! $BOOKMARKS_FILE + _zshmarks_move_to_trash + fi fi +fi } From ef84229dbfc8a7008f0232c86b1066791aa0f078 Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Tue, 7 Mar 2017 23:17:47 -0600 Subject: [PATCH 03/10] Added autocompletion of saved marks --- zshmarks.plugin.zsh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index f4252563..576a9a38 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -113,8 +113,8 @@ function showmarks() { for bookmark_line in $bookmark_array; do bookmark_path="${bookmark_line%%|*}" bookmark_path="${bookmark_path/\$HOME/~}" - bookmark_name="${bookmark_line#*|}" - printf "%s\t\t%s\n" "$bookmark_name" "$bookmark_path" + bookmark_name="${bookmark_line##*|}" + printf "%-40s%-25s\n" "$bookmark_name" "$bookmark_path" done fi } @@ -149,6 +149,18 @@ function deletemark() { _zshmarks_move_to_trash fi fi -fi } + +_zshmark_completions() { + COMPREPLY=() + local session="${COMP_WORDS[COMP_CWORD]}" + local bookmark_file="$(<"$BOOKMARKS_FILE")" + local bookmark_array; bookmark_array=(${(f)bookmark_file}); + local bookmarks=${bookmark_array[@]##*|} + + # For autocomplete, use both existing sessions as well as directory names. + #local sessions=( $(compgen -W "$(tmux list-sessions 2>/dev/null | awk -F: '{ print $1 }')" -- "$session") ) + + COMPREPLY=( ${bookmarks[@]} ) +} \ No newline at end of file From 41bf9066f47dc565c65506987d4aa45af8304094 Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Thu, 30 Mar 2017 18:11:22 -0500 Subject: [PATCH 04/10] added fzf search and workspace search to bookmarks --- zshmarks.plugin.zsh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 576a9a38..b7d33a5e 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -85,11 +85,20 @@ function jump() { else local bookmark if ! __zshmarks_zgrep bookmark "\\|$bookmark_name\$" "$BOOKMARKS_FILE"; then - echo "Invalid name, please provide a valid bookmark name. For example:" - echo " jump foo" - echo - echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):" - echo " bookmark foo" + local code_root_dirs=$(echo $CODE_ROOT_DIRS | sed 's/:/ /g') + local matching_dirs=( $(find $code_root_dirs -name "$bookmark_name" -type d -maxdepth 4) ) + if [ $# -ne 0 ]; then + local jumpline=$(find $code_root_dirs -name "*$bookmark_name*" -type d -maxdepth 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) + fi + if [[ $jumpline ]]; then + eval cd ${jumpline:=\"$PWD\" } && clear + else + echo "Invalid name, please provide a valid bookmark name. For example:" + echo " jump foo" + echo + echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):" + echo " bookmark foo" + fi return 1 else local dir="${bookmark%%|*}" From 59cf449a3b72a3667bfe4e139a231ec55682a092 Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Sun, 30 Apr 2017 12:56:43 -0500 Subject: [PATCH 05/10] Fixed error while deleting bookmarks with fzf --- zshmarks.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index b7d33a5e..79ea845f 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -137,7 +137,7 @@ function deletemark() { if [[ -n ${marks_to_delete} ]]; then while read -r line; do - perl -p -i -e "s#${line}\n##g" $BOOKMARKS_FILE + sed -i "" "\#${line}#d" $BOOKMARKS_FILE done <<< "$marks_to_delete" echo "** The following marks were deleted **" From 1d52c8892f776d57f417f496ee667d974cfcdd3d Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Wed, 13 Jun 2018 16:29:15 -0500 Subject: [PATCH 06/10] Added feature to fzf search for all bookmarks folders if bookmark is not found --- zshmarks.plugin.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 79ea845f..f435ca0a 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -86,9 +86,12 @@ function jump() { local bookmark if ! __zshmarks_zgrep bookmark "\\|$bookmark_name\$" "$BOOKMARKS_FILE"; then local code_root_dirs=$(echo $CODE_ROOT_DIRS | sed 's/:/ /g') - local matching_dirs=( $(find $code_root_dirs -name "$bookmark_name" -type d -maxdepth 4) ) + local search_dirs="$code_root_dirs" + while IFS='' read -r line || [[ -n "$line" ]]; do + search_dirs+=" ${line%%|*}" + done < $BOOKMARKS_FILE if [ $# -ne 0 ]; then - local jumpline=$(find $code_root_dirs -name "*$bookmark_name*" -type d -maxdepth 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) + local jumpline=$(eval fd $bookmark_name $search_dirs -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) fi if [[ $jumpline ]]; then eval cd ${jumpline:=\"$PWD\" } && clear @@ -102,7 +105,7 @@ function jump() { return 1 else local dir="${bookmark%%|*}" - eval "cd \"${dir}\"" + eval "cd \"${dir}\"" && clear fi fi } From 24612409f8b4a419c68a6be9fff88939dd145b3d Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Fri, 22 Jun 2018 16:06:47 -0500 Subject: [PATCH 07/10] Updated to search even hidden folders --- zshmarks.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index f435ca0a..3362adec 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -91,7 +91,7 @@ function jump() { search_dirs+=" ${line%%|*}" done < $BOOKMARKS_FILE if [ $# -ne 0 ]; then - local jumpline=$(eval fd $bookmark_name $search_dirs -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) + local jumpline=$(eval fd $bookmark_name $search_dirs -H -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) fi if [[ $jumpline ]]; then eval cd ${jumpline:=\"$PWD\" } && clear From f21de7891337d9f6a512a05da369ce340a66aa81 Mon Sep 17 00:00:00 2001 From: Revanth Revoori Date: Mon, 24 Dec 2018 01:05:47 -0600 Subject: [PATCH 08/10] Handle spaces in folders better --- zshmarks.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 3362adec..7276d7af 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -94,7 +94,7 @@ function jump() { local jumpline=$(eval fd $bookmark_name $search_dirs -H -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) fi if [[ $jumpline ]]; then - eval cd ${jumpline:=\"$PWD\" } && clear + eval "cd \"${jumpline:=\"$PWD\" }\"" && clear else echo "Invalid name, please provide a valid bookmark name. For example:" echo " jump foo" From 39d5833c227e224bf8e7a3e21e49672fdf1d2fed Mon Sep 17 00:00:00 2001 From: Revoori Sai Revanth Date: Tue, 3 Nov 2020 23:20:15 -0800 Subject: [PATCH 09/10] Update zshmarks.plugin.zsh --- zshmarks.plugin.zsh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index 7276d7af..d5332154 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -22,7 +22,7 @@ if [[ ! -f $BOOKMARKS_FILE ]]; then fi fzfcmd() { - [ ${FZF_TMUX:-1} -eq 1 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" + [ ${FZF_TMUX:-1} -eq 1 ] && echo "fzf -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" } _zshmarks_move_to_trash(){ @@ -52,7 +52,7 @@ function bookmark() { cur_dir="\$HOME${cur_dir#$HOME}" fi # Store the bookmark as folder|name - bookmark="$cur_dir|$bookmark_name" + bookmark="$cur_dir|" if [[ -z $(grep "$bookmark" $BOOKMARKS_FILE 2>/dev/null) ]]; then echo $bookmark >> $BOOKMARKS_FILE echo "Bookmark '$bookmark_name' saved" @@ -66,11 +66,11 @@ __zshmarks_zgrep() { local outvar="$1"; shift local pattern="$1" local filename="$2" - local file_contents="$(<"$filename")" - local file_lines; file_lines=(${(f)file_contents}) + mapfile -t file_lines < $filename for line in "${file_lines[@]}"; do - if [[ "$line" =~ "$pattern" ]]; then - eval "$outvar=\"$line\"" + echo $line + if [[ $line =~ $pattern ]]; then + $outvar=\"$line\" return 0 fi done @@ -81,17 +81,17 @@ function jump() { local bookmark_name=$1 if [ $# -eq 0 ]; then local jumpline=$(cat ${BOOKMARKS_FILE} | $(fzfcmd) --bind=ctrl-y:accept --tac) - eval cd "${jumpline%%|*}" + eval "cd \"${jumpline%%|*}\"" && clear else local bookmark if ! __zshmarks_zgrep bookmark "\\|$bookmark_name\$" "$BOOKMARKS_FILE"; then local code_root_dirs=$(echo $CODE_ROOT_DIRS | sed 's/:/ /g') - local search_dirs="$code_root_dirs" + local search_dirs="\"$code_root_dirs\"" while IFS='' read -r line || [[ -n "$line" ]]; do - search_dirs+=" ${line%%|*}" + search_dirs+=" \"${line%%|*}\"" done < $BOOKMARKS_FILE if [ $# -ne 0 ]; then - local jumpline=$(eval fd $bookmark_name $search_dirs -H -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac) + local jumpline=$(eval "fd $bookmark_name $search_dirs -H -t d -d 4 | $(fzfcmd) --bind=ctrl-y:accept --tac") fi if [[ $jumpline ]]; then eval "cd \"${jumpline:=\"$PWD\" }\"" && clear @@ -105,6 +105,7 @@ function jump() { return 1 else local dir="${bookmark%%|*}" + echo $dir eval "cd \"${dir}\"" && clear fi fi @@ -140,7 +141,8 @@ function deletemark() { if [[ -n ${marks_to_delete} ]]; then while read -r line; do - sed -i "" "\#${line}#d" $BOOKMARKS_FILE + echo $line + eval "sed -i '' '#${line}#d' $BOOKMARKS_FILE" done <<< "$marks_to_delete" echo "** The following marks were deleted **" @@ -175,4 +177,4 @@ _zshmark_completions() { #local sessions=( $(compgen -W "$(tmux list-sessions 2>/dev/null | awk -F: '{ print $1 }')" -- "$session") ) COMPREPLY=( ${bookmarks[@]} ) -} \ No newline at end of file +} From 57023f04897d88457d1d8f7077f55541372945c0 Mon Sep 17 00:00:00 2001 From: Revoori Sai Revanth Date: Tue, 3 Nov 2020 23:30:25 -0800 Subject: [PATCH 10/10] Update zshmarks.plugin.zsh --- zshmarks.plugin.zsh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/zshmarks.plugin.zsh b/zshmarks.plugin.zsh index d5332154..6142aca4 100644 --- a/zshmarks.plugin.zsh +++ b/zshmarks.plugin.zsh @@ -52,7 +52,7 @@ function bookmark() { cur_dir="\$HOME${cur_dir#$HOME}" fi # Store the bookmark as folder|name - bookmark="$cur_dir|" + bookmark="$cur_dir|$(basename "$PWD")" if [[ -z $(grep "$bookmark" $BOOKMARKS_FILE 2>/dev/null) ]]; then echo $bookmark >> $BOOKMARKS_FILE echo "Bookmark '$bookmark_name' saved" @@ -66,7 +66,7 @@ __zshmarks_zgrep() { local outvar="$1"; shift local pattern="$1" local filename="$2" - mapfile -t file_lines < $filename + local file_lines; mapfile -t file_lines < $filename; for line in "${file_lines[@]}"; do echo $line if [[ $line =~ $pattern ]]; then @@ -113,8 +113,7 @@ fi # Show a list of the bookmarks function showmarks() { - local bookmark_file="$(<"$BOOKMARKS_FILE")" - local bookmark_array; bookmark_array=(${(f)bookmark_file}); + local bookmark_array; mapfile -t bookmark_array < $BOOKMARKS_FILE; local bookmark_name bookmark_path bookmark_line if [[ $# -eq 1 ]]; then bookmark_name="*\|${1}" @@ -123,11 +122,11 @@ function showmarks() { bookmark_path="${bookmark_path/\$HOME/~}" printf "%s \n" $bookmark_path else - for bookmark_line in $bookmark_array; do + for bookmark_line in "${bookmark_array[@]}"; do bookmark_path="${bookmark_line%%|*}" bookmark_path="${bookmark_path/\$HOME/~}" bookmark_name="${bookmark_line##*|}" - printf "%-40s%-25s\n" "$bookmark_name" "$bookmark_path" + printf "$bookmark_name" "$bookmark_path" done fi }