├── .travis.yml ├── README.md ├── bin ├── list-all └── install └── LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: asdf plugin-test tmux https://github.com/aphecetche/asdf-tmux.git 'tmux -V' 3 | before_script: 4 | - git clone https://github.com/asdf-vm/asdf.git 5 | - . asdf/asdf.sh 6 | os: 7 | - linux 8 | - osx 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # asdf-tmux [![Build Status](https://travis-ci.org/aphecetche/asdf-tmux.svg?branch=master)](https://travis-ci.org/aphecetche/asdf-tmux) 2 | 3 | [tmux](https://github.com/tmux/tmux) plugin for [asdf](https://github.com/asdf-vm/asdf) version manager 4 | 5 | ## Install 6 | 7 | ``` 8 | asdf plugin-add tmux https://github.com/aphecetche/asdf-tmux.git 9 | asdf install tmux 10 | ``` 11 | -------------------------------------------------------------------------------- /bin/list-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #stolen from https://github.com/rbenv/ruby-build/pull/631/files#diff-fdcfb8a18714b33b07529b7d02b54f1dR942 4 | function sort_versions() { 5 | sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \ 6 | LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' 7 | } 8 | 9 | # Fetch all tag names, and get only second column. Then remove all unnecessary characters. 10 | list_of_versions=$( 11 | git ls-remote --heads --tags https://github.com/tmux/tmux.git \ 12 | | awk '!/({})/ {print $2}' \ 13 | | awk 'gsub("(refs/tags/)|(v)", "")' \ 14 | | sort_versions \ 15 | ) 16 | 17 | echo $list_of_versions 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Laurent Aphecetche 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | construct_configure_options() { 4 | load_configure_options 5 | 6 | if [ "$TMUX_CONFIGURE_OPTIONS" = "" ]; then 7 | local configure_options="--prefix=$install_path" 8 | 9 | if [ "$TMUX_EXTRA_CONFIGURE_OPTIONS" != "" ]; then 10 | configure_options="$configure_options $TMUX_EXTRA_CONFIGURE_OPTIONS" 11 | fi 12 | else 13 | local configure_options="$TMUX_CONFIGURE_OPTIONS --prefix=$install_path" 14 | fi 15 | 16 | echo "$configure_options" 17 | } 18 | 19 | load_configure_options() { 20 | local asdf_tmux_configure_options="${HOME}/.asdf-tmux-configure-options" 21 | 22 | if [[ ! -r "$asdf_tmux_configure_options" ]]; then 23 | return 24 | fi 25 | 26 | set -a 27 | source "$asdf_tmux_configure_options" 28 | set +a 29 | } 30 | 31 | install_tmux() { 32 | local version=$1 33 | local install_path=$2 34 | local concurrency=$3 35 | 36 | if [ "$TMPDIR" = "" ]; then 37 | local tmp_download_dir=$(mktemp -d -t tmux_build_XXXXXX) 38 | else 39 | local tmp_download_dir=$TMPDIR 40 | fi 41 | 42 | # path to the tar file 43 | local source_path=$(get_download_file_path $version $tmp_download_dir) 44 | echo $source_path 45 | download_source_file $version $source_path 46 | 47 | # running this in subshell 48 | # we don't want to disturb current working dir 49 | ( 50 | if ! type "unzip" &>/dev/null; then 51 | echo "ERROR: unzip not found" 52 | exit 1 53 | fi 54 | 55 | unzip -q $source_path -d $tmp_download_dir || exit 1 56 | 57 | cd $tmp_download_dir/tmux-${version} 58 | ./autogen.sh 59 | install_path=$install_path 60 | ./configure $(construct_configure_options) CFLAGS="-I${install_path}/include" LDFLAGS="-L${install_path}/lib -Wl,-rpath,$install_path/lib" 61 | make -j $concurrency 62 | if [[ $? -eq 0 ]]; then 63 | make install 64 | fi 65 | ) 66 | } 67 | 68 | install_libevent() { 69 | local install_path=$1 70 | local concurrency=$2 71 | 72 | if [ "$TMPDIR" = "" ]; then 73 | local tmp_download_dir=$(mktemp -d -t tmux_build_XXXXXX) 74 | else 75 | local tmp_download_dir=$TMPDIR 76 | fi 77 | cd $tmp_download_dir 78 | 79 | libevent_version="2.1.10" 80 | 81 | curl -LO https://github.com/libevent/libevent/releases/download/release-${libevent_version}-stable/libevent-${libevent_version}-stable.tar.gz 82 | tar -zxf libevent-${libevent_version}-stable.tar.gz 83 | cd libevent-${libevent_version}-stable 84 | ./configure --prefix=$install_path 85 | make -j $concurrency 86 | if [[ $? -eq 0 ]]; then 87 | make install 88 | else 89 | exit 2 90 | fi 91 | } 92 | 93 | download_source_file() { 94 | local version=$1 95 | local download_path=$2 96 | local download_url=$(get_download_url $version) 97 | 98 | curl -Lo $download_path -C - $download_url 99 | } 100 | 101 | get_download_file_path() { 102 | local version=$1 103 | local tmp_download_dir=$2 104 | 105 | echo "$tmp_download_dir/tmux-${version}.zip" 106 | } 107 | 108 | get_download_url() { 109 | local version=$1 110 | 111 | echo "https://github.com/tmux/tmux/archive/${version}.zip" 112 | } 113 | 114 | install_libevent $ASDF_INSTALL_PATH $ASDF_CONCURRENCY 115 | 116 | install_tmux $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH $ASDF_CONCURRENCY 117 | --------------------------------------------------------------------------------