aboutsummaryrefslogtreecommitdiff
path: root/.config/fish/functions/bass.fish
blob: 2b3af165d6a1255b9a5098b1f5e1163a11db6cb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function bass
  set -l bash_args $argv
  set -l bass_debug
  if test "$bash_args[1]_" = '-d_'
    set bass_debug true
    set -e bash_args[1]
  end

  set -l script_file (mktemp)
  if command -v python3 >/dev/null 2>&1
    command python3 -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
  else
    command python -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
  end
  set -l bass_status $status
  if test $bass_status -ne 0
    return $bass_status
  end

  if test -n "$bass_debug"
    cat $script_file
  end
  source $script_file
  command rm $script_file
end

function __bass_usage
  echo "Usage: bass [-d] <bash-command>"
end