ds4mac — переключатель каталогов для macOS / Linux: скрипт

У меня есть эта программа в GitHub. Используется для перехода в каталоги через настраиваемые теги. Вот основной сценарий bash:

out_file=$(mktemp)
~/.ds/ds_engine $@ > $out_file
command_type=$(head -n 1 $out_file)

if [ $# -eq 0 ]; then
    next_path=$(tail -n 1 $out_file)
    ~/.ds/ds_engine --update-previous $(pwd)
    cd $next_path   
else
    if [ "$command_type" == "switch_directory" ]; then
        next_path=$(tail -n 1 $out_file)

        if [ ! -d "$next_path" ]; then
            echo 2> "Directory "$next_path" does not exist."
            exit 1
        fi

        ~/.ds/ds_engine --update-previous $(pwd)
        cd $next_path
    elif [ "$command_type" == "show_tag_entry_list" ]; then
        tail -n +2 $out_file
    else
        echo "Unknown command: $command_type"
    fi
fi

rm $out_file

Смотрите также

  1. Скрипт установщика
  2. Движок тегов

Запрос на критику

Пожалуйста, расскажите мне все, что придет в голову. ^^

0

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *