GithubHelp home page GithubHelp logo

bass's People

Contributors

alex7kom avatar baco avatar crshoverride avatar daveyarwood avatar edc avatar elijahlynn avatar evanrelf avatar fabioantunes avatar jimt avatar jorgebucaran avatar josephfrazier avatar junaid-shahid avatar kouk avatar maksathanja avatar markcial avatar mojotx avatar neominik avatar nirvdrum avatar paparomeo avatar popbones avatar rouge8 avatar shouya avatar tbodt avatar thatneat avatar zavorka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bass's Issues

Pass bash options through bass

Some scripts depend on the current shell options $- in their logic. Is there a way to pass all the bash options i.e. login, interactive, etc when executed using bass?

Replacing colons with whitespace causes issues

I just installed nvm. When I start a new fish session $NVM_NODEJS_ORG_MIRROR is not set. If I run nvm ls-remote it works as you would expect. But during execution $NVM_NODEJS_ORG_MIRROR gets set to https //nodejs.org/dist, because bass replaces : with whitespace, which breaks things.

Is there a way to assign a colon-separated string to a variable? If we do bass export foo="foo:bar" then foo becomes a list of two items, but I expect to get a string. I'm kind of new to fish and never bothered to learn bash, but I figured we are replacing colons with whitespace, so that we can properly convert $PATH, right? Could we do it only for $PATH and leave all other colons alone?

fisher: I couldn't find `bass` in the index.

Hey guys,

I'm using fish shell w/fisherman. When I attempted to follow the instructions on your README.md, I ran into an error:

» fisher install bass
fisher: I couldn't find 'bass' in the index
No plugins were installed

Any idea why fisherman might not be able to see bass?

Python version

Some linuxen have python3 as default, some have python2. Is the code here python2/3 compatible? If not, can it be? Otherwise, could this script use the PYTHON=/path/to/python env var if available?

set: Tried to change the read-only variable “_”

I'm getting this error when I run bass from config.fish using fish 3.0.0, Mac OS X 10.13.6's Terminal:

set: Tried to change the read-only variable “_”

In config.fish: bass source ~/.profile

in .profile:

export MAVEN_HOME=/Library/Maven/Home
export M2_HOME=$MAVEN_HOME
export TOMCAT_HOME=/Library/Tomcat/Home
#export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
export JAVA_HOME=$(/usr/libexec/java_home)
export JRE_HOME=$JAVA_HOME

PATH=$MAVEN_HOME/bin:~/bin:$PATH

# MacPorts Installer addition on 2016-01-09_at_17:31:59: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

Python:

python -V
Python 2.7.10

Coloured output is not working

When I run something like bass git status the output is of one colour. I know that the example doesn't demonstrate the use case well but I have some scripts that output some useful information. Is it possible to pass colour codes to standard output so that it's correctly displayed?

Thanks for the tool, it's great in any case

Open source?

Is this project open source? If so, would you mind attaching a license? Thanks!

ValueError when using a particular command

I saw this error and I expect that bass should not give a Python traceback.

~> bass 'cat <<EOF > mke-options.json
           {
               "service": {
                   "service_account": "kubernetes",
                   "service_account_secret": "kubernetes/sa"
               }
           }
           EOF'
unknown error: need more than 1 value to unpack
Traceback (most recent call last):
  File "/Users/adam/.config/fish/functions/__bass.py", line 90, in <module>
    script = gen_script()
  File "/Users/adam/.config/fish/functions/__bass.py", line 45, in gen_script
    stdout, new_env, alias = output.split(divider, 2)
ValueError: need more than 1 value to unpack
Bass encountered an error!

bass: fish: Unknown command 'source'

I installed bass per the instructions in README.md. I ran the example:

> bass export X=3
fish: Unknown command 'source'
/Users/mgadda/.config/fish/functions/bass.fish (line 13):     source $__script
                                                              ^
in function 'bass',
    called on standard input,
    with parameter list 'export X=3'

According to the fish documentation, there is no source command, only .. When I updated ~/.config/fish/functions/bass.fish and replaced the reference to source with . the example succeeded.

Close Failed in File Object Destructor

I'm getting the following error when trying to use bass to run some nvm commands:

The command:

bass source $NVM_DIR/nvm.sh --no-use ';' nvm use --lts --delete-prefix
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
unknown error: Unterminated string starting at: line 1 column 791 (char 790)
Traceback (most recent call last):
  File "/Users/bbatsche/.config/fish/functions/__bass.py", line 82, in <module>
    script = gen_script()
  File "/Users/bbatsche/.config/fish/functions/__bass.py", line 43, in gen_script
    new_env = json.loads(new_env)
  File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Unterminated string starting at: line 1 column 791 (char 790)
Bass encountered an error!

What's weird is that some other (less useful) nvm commands are still working. If I do bass source $NVM_DIR/nvm.sh --no-use ';' nvm ls I get the expected output.

  • fish --version
    • fish, version 2.4.0
  • python --version
    • Python 2.7.12

Functions are not available in shell when run in source

My current project requiters me to compile android. to accomplish this I will need to run the following command.

source envsetup.sh

The envsetup.sh file can be retrieved from the platform build repo

once this command is ran multiple functions defined in the shell scrip should become available to the user in the shell. this include the mmm function

running the following should achieve the same thing. but i understand why it does not.

bass source envsetup.sh

I tried running

source bass source envsetup.sh

but i get the following error

source: Error encountered while sourcing file "bass":
source: No such file or directory

Is there a way around this,?

Bass does not track unset variables

I'm building some tooling around bass, and I noticed that when sourcing a bash script that unsets environment variables (e.g. for clearing sensitive information once it's no longer needed), bass does not remove the variable from the fish environment.

I'm happy to contribute a PR if needed -- I took a quick look at __bass.py, and it looks like we're taking a JSON dump of the environment before and after running the script, so it ought to just be a matter of iterating through each var in old_env that does not exist in new_env and adding set -e $var_name to the script to be sourced in the fish environment.

while sourcing nvm command works, npm and node command are not working properly

Hi,
So ive put the nvm function in the config.fish and installed node with nvm. however, i always get fish: Unknown command 'node' on shell startup, so is npm. they will work after i execute a nvm command though, such as nvm ls.

if nvm is already sourced, how come node wont work?

ps: tested in bash. node and npm work normally.

my config.fish:

# Fisherman config
set fisher_home ~/.local/share/fisherman
set fisher_config ~/.config/fisherman
source $fisher_home/config.fish

# Initial config file contents, which adds /usr/local/bin to the PATH environment variable.
set -g -x PATH /usr/local/bin $PATH

# Homebrew
set -g -x PATH /usr/local/sbin $PATH

# pyenv
status --is-interactive; and . (pyenv init -|psub)

function nvm
    bass source ~/.nvm/nvm.sh ';' nvm $argv
end



# Will eliminate the Fish welcome message that appears by default
set -g -x fish_greeting ''

Publish a release tag so this can be added to Homebrew

If you publish a release on GitHub (and keep doing as you release updates), then this can go into the Homebrew package manager, which would be really handy. I'd be happy to do the packaging work once a release tag is pushed. Thanks!

fisher install bass

Do I do something wrong? I want to install bass with this command:

fisher i bass

but it tries to fetch from a 404 repo http://github.com/fisherman/bass . Here is the output (ignore my set warnings there):

 ~  fisher i bass                                                                        6.3s  Sa 23 Apr 18:44:59 2016
INFO Installing 1 plugin/s
set: Warning: universal scope selected, but a global variable 'LSCOLORS' exists.
set: Warning: universal scope selected, but a global variable 'CLICOLOR' exists.
set: Warning: universal scope selected, but a global variable 'TERM' exists.
Warning! PATH is not properly set up, '/Users/marvin/.rvm/gems/ruby-2.2.1/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.2.1'.
ARGH Fetching bass → github.com/fisherman/bass
ARGH There was an error cloning bass or more plugin/s.
INFO Try using a namespace before the plugin name: omf/bass

Or is the bass readme outdated with the command fisher install bass ?

Unable to source a bash file

I found this bash file online and am trying to source it with bass. It basically allows anaconda and ROS to coexist together; basically just modified python path and path env variables. However it doesnt seem to working when used with bash. Is the script to complicated to being converted for bass?

Script:

#!/bin/bash

### This script wraps all executables in the anaconda bin folder so that they can be used without adding Anaconda
### to the path which would break some functionality of ROS (Robot Operating System)
###
### The commands e.g. jupyter notebook will cause the script to add anaconda to the path, start jupyter notebook
### and after jupyter notebook terminated remove anaconda from the path again
###
### Notable commands:
### * release-the-snake       Adds conda to the path and removes all aliases defined by this script
###                           Conda will stay in the PATH until the end of the session (terminal is closed) or
###                           until "cage-the-snake" is called
### * cage-the-snake          Removes conda from the path and redefines all aliases for anaconda executables
### * source activate [env]   Works just like with anaconda in the PATH, will activate the environment or (root) and
###                           Anaconda will stay in the PATH for the remaining session or until "source deactivate" is run
### * source deactivate       Deactivates the environment and if Anaconda wasn't released manually using release-the-snake
###                           Anaconda will be removed from the PATH again.

if [ -z ${_ROS_CONDA_ADDED+x} ]
then
  _ROS_CONDA_PATH=~/miniconda3/bin
  _ROS_CONDA_ADDED=0
  _ROS_CONDA_ALIASES=''
  _ROS_CONDA_RELEASED_MANUALLY=0
  _ROS_CONDA_PYTHONPATH_WITHOUT_ROS=$PYTHONPATH
fi

function _ROS_CONDA_addAliases {
  if [[ $_ROS_CONDA_ALIASES != '' ]]
  then
    echo "ROS Conda Wrapper: Error! Aliases already defined!"
    _ROS_CONDA_removeAliases
  fi
  
  for file in $_ROS_CONDA_PATH/*
  do
    local name
    name=${file##*/}
    if ! [ -x "$(command -v $name)" ]
    then
      alias $name='_ROS_CONDA_runWithConda '$name' $@'
      _ROS_CONDA_ALIASES=$_ROS_CONDA_ALIASES" "$name
    fi
  done
}

function _ROS_CONDA_removeAliases {
  for cmd in $_ROS_CONDA_ALIASES
  do
    unalias $cmd
  done
  _ROS_CONDA_ALIASES=''
}

function _ROS_CONDA_runWithConda {
  _ROS_CONDA_ensureCondaInPath
  command $@
  _ROS_CONDA_removeCondaFromPath
}

function _ROS_CONDA_ensureCondaInPath {
  if [ $_ROS_CONDA_ADDED -eq 1 ]
  then
    return 1 # false
  fi
  _ROS_CONDA_ADDED=1

  # Check that the path doesn't start, end or contain the ros conda path
  if [[  $PATH != $_ROS_CONDA_PATH":"* && $PATH != *":"$_ROS_CONDA_PATH && $PATH != *":"$_ROS_CONDA_PATH":"* ]]
  then
    export PATH=$_ROS_CONDA_PATH:$PATH
    # Backup and clear python path to keep ros from checking ros directories for python modules
    _ROS_CONDA_PYTHONPATH_BACKUP=$PYTHONPATH
    export PYTHONPATH=$_ROS_CONDA_PYTHONPATH_WITHOUT_ROS

    # Unalias the stuff
    _ROS_CONDA_removeAliases

    return 0 # true
  fi
  return 1
}

function _ROS_CONDA_removeCondaFromPath {
  if [[ $PATH = $_ROS_CONDA_PATH":"* ]]
  then
    export PATH=${PATH#$_ROS_CONDA_PATH:}
  elif [[ $PATH = *":"$_ROS_CONDA_PATH ]]
  then
    export PATH=${PATH%:$_ROS_CONDA_PATH}
  elif [[ $PATH = *":"$_ROS_CONDA_PATH":"* ]]
  then
    export PATH=${PATH//:$_ROS_CONDA_PATH:/:}
  fi

  if [ $_ROS_CONDA_ADDED -eq 1 ]
  then
    # Restore ROS PYTHONPATH
    export PYTHONPATH=$_ROS_CONDA_PYTHONPATH_BACKUP
    _ROS_CONDA_addAliases
  fi

  _ROS_CONDA_ADDED=0
}

function _ROS_CONDA_sourceWrapper {
  if [ $1 == "activate" ]
  then
    _ROS_CONDA_ensureCondaInPath
    if [ $# == 1 ]
    then
    # If only source activate call source activate root.
    # Otherwise it will fail. Don't know why though
      command source activate
    else
      command source $@
    fi
  elif [ $1 == "deactivate" ]
  then
    command source deactivate
    if [ $_ROS_CONDA_RELEASED_MANUALLY -eq 0 ]
    then
      _ROS_CONDA_removeCondaFromPath
    fi
  else
    command source $@
  fi
}

if [ $_ROS_CONDA_ADDED -eq 0 ]
then
  if [[ $_ROS_CONDA_ALIASES != '' ]]
  then
    _ROS_CONDA_removeAliases
  fi
  _ROS_CONDA_addAliases
fi

alias source='_ROS_CONDA_sourceWrapper'
alias release-the-snake='_ROS_CONDA_RELEASED_MANUALLY=1; if _ROS_CONDA_ensureCondaInPath; then echo "All hail the snake!"; else echo "The snake is in another castle!
Jk, you released it already."; fi'
alias cage-the-snake='_ROS_CONDA_RELEASED_MANUALLY=0; _ROS_CONDA_removeCondaFromPath; echo "The snake has been caged if it wasn'"'"'t already."'

Error when running bass source FILE_NAME.bash

 (line 1): $@ is not supported. In fish, please use $argv.
function activate --wraps _ROS_CONDA_runWithConda --description 'alias activate=_ROS_CONDA_runWithConda activate $@';  _ROS_CONDA_runWithConda activate $@ $argv; end
                                                                                                                                                         ^
from sourcing file -
	called on line 71 of file /usr/share/fish/functions/alias.fish

in function “alias”
	called on line 3 of file -
	with parameter list “activate=_ROS_CONDA_runWithConda activate $@”

from sourcing file -
	called on line 15 of file ~/.config/fish/functions/bass.fish

in function “bass”
	called on standard input
	with parameter list “source /home/jeremy/.anaconda_with_ros_wrapper.bash”

source: Error while reading file “-”
- (line 1): $@ is not supported. In fish, please use $argv.
function deactivate --wraps _ROS_CONDA_runWithConda --description 'alias deactivate=_ROS_CONDA_runWithConda deactivate $@';  _ROS_CONDA_runWithConda deactivate $@ $argv; end
                                                                                                                                                                 ^
from sourcing file -
	called on line 71 of file /usr/share/fish/functions/alias.fish

in function “alias”
	called on line 5 of file -
	with parameter list “deactivate=_ROS_CONDA_runWithConda deactivate $@”

from sourcing file -
	called on line 15 of file ~/.config/fish/functions/bass.fish

in function “bass”
	called on standard input
	with parameter list “source /home/jeremy/.anaconda_with_ros_wrapper.bash”

source: Error while reading file “-”
- (line 1): Expected end of the statement, but instead found a string
function release-the-snake --wraps _ROS_CONDA_RELEASED_MANUALLY=1 --description alias\ release-the-snake=_ROS_CONDA_RELEASED_MANUALLY=1\;\ if\ _ROS_CONDA_ensureCondaInPath\;\ then\ echo\ \"All\ hail\ the\ snake!\"\;\ else\ echo\ \"The\ snake\ is\ in\ another\ castle!\nJk,\ you\ released\ it\ already.\"\;\ fi;  _ROS_CONDA_RELEASED_MANUALLY=1; if _ROS_CONDA_ensureCondaInPath; then echo "All hail the snake!"; else echo "The snake is in another castle! $argv; end
                                                                                                                                                                                                                                                                                                                                                                                                                               ^
from sourcing file -
	called on line 71 of file /usr/share/fish/functions/alias.fish

in function “alias”
	called on line 6 of file -
	with parameter list “release-the-snake=_ROS_CONDA_RELEASED_MANUALLY=1; if _ROS_CONDA_ensureCondaInPath; then echo "All hail the snake!"; else echo "The snake is in another castle!
Jk, you released it already."; fi”

from sourcing file -
	called on line 15 of file ~/.config/fish/functions/bass.fish

in function “bass”
	called on standard input
	with parameter list “source /home/jeremy/.anaconda_with_ros_wrapper.bash”

source: Error while reading file “-”

Would you like to move into the fisherman organization?

Hi @edc.

fisherman just turn 2.0 and a lot of things changed, namely, we don't depend on an index anymore. In order to improve discoverability I am trying to reach out to some of the many plugin authors and ask them whether they would like to join the fisherman org and bring their plugins / themes with them.

If you enter the org, you will still be the only admin of your project, what changes is that fish-shellers browsing fisherman org will be able to find out about bass more easily.

Exception when encountering u'\u2192' character

The u2192 character is not supported.

Traceback (most recent call last):
  File "/Users/jonathanleitschuh/.local/share/omf/pkg/bass/functions/__bass.py", line 99, in <module>
    print(script, end='')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2192' in position 168: ordinal not in range(128)

Support aliases

I've come across bash scripts that define aliases, to shorten paths to executables for example, such as

# Source me
alias foobar='/path/to/some_long_executable_name.extension'

Sourcing such a script with bass does not convert the bash alias to a fish one. This can be seen interactively:

$ bass alias foobar='ls'
$ foobar
fish: Unknown command 'foobar'

As far as I can tell, bass works by comparing the output of bash's env before and after running the command passed to bass, so any aliases defined won't be captured.

bass could additionally compare the output of bash's alias, which prints all defined aliases.

variables cannot be bracketed

Trying bass with a syntax construct I knew differed between bash and fish:

$ bass echo ${PATH}
fish: Variables cannot be bracketed. In fish, please use {$PATH}.
bass echo ${PATH}
           ^

I guess this is out-of-scope for now huh 😅, or is this just a limitation of how you're working from within fish?

"Variables may not be used as commands"

The latest merge (65cb4cb) causes bass to break on my machine. Reverting to (20837aa) seems to fix the issue. I'm running Ubuntu 18.04 with fish 2.7.1. Running bass results in the error "Variables may not be used as commands, In fish, please define a function or use 'eval $python'.".
image

can't use alias

Hi,
does bass support converting bash alias?

~> bass alias gcb="git pull" bash: line 0: alias: pull: not found exit code: 1 Bass encountered an error!

If I bass the following file...
~> cat kk.sh set -x alias gcb="git pull" alias gcb
...I get:

~> bass ./kk.sh
++ alias 'gcb=git pull'
++ alias
++ gcb
./kk.sh: line 4: gcb: command not found
exit code: 127
Bass encountered an error!

I saw #21, but the problem is that
alias "xx='echo lol'"
is not valid in bash

$ type xx
xx is aliased to `'echo lol''
$ xx
-bash: echo lol: command not found

It should be :

alias xx='echo lol'
⌂66% [dpinyol:~] $ type xx
xx is aliased to `echo lol'
⌂67% [dpinyol:~] $ xx
lol

thanks

Last merge broke nvm execution with arguments

I couldn't find the reason, but running the last version of Bass (3e4c13c) isn't possible to pass arguments to nvm execution. The output says that Bass encountered an error! with exit status: 3.

I've checked out to previous commit (cba21b3) and everything back to work successfully.

Homebrew formula.

I'd love to see this package on homebrew for OSX; is there any interest in writing up a formula?

Support for sdkman

sdman is a virtualenv-like utility for the java ecosystem: http://sdkman.io/ (source: https://github.com/sdkman/sdkman-cli)

Currently, bass grabs the environment variables after running sdkman-init.sh, but does not setup the sdk command itself. I'm not sure what that is -- perhaps it has something to do with the nested source calls?

set `$SHELL` to `(which bash)`

Some tools use $SHELL to find out in which shell their running and what syntax to print. Those tools will output fish syntax in bash when $SHELL is set to fish. One of those tools is opam, the ocaml package manager (see ocaml/opam#2162):

bash: line 0: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: line 0: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: line 0: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: line 0: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: line 0: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
exit code: 2
Bass encountered an error!

The reason I want to use bass for this is, that the bash config works, whereas their shipped fish config breaks the entire shell and they won't be fixing it for the stable release, but only the next major release (ocaml/opam#2255 and ocaml/opam#2884).

I could get this to work by setting and unsetting the $SHELL variable:

  set OLD_SHELL $SHELL
  set SHELL (which bash)

# ...

  set SHELL $OLD_SHELL

Fish shell delay

In ~/.config/fish/config.fish, I have:

bass source ~/.nvm/nvm.sh ';' nvm use 0.12.2

Every time a new Fish shell terminal is opened. It takes almost a second for the shell to load. Without this line, the Fish shell loads fast.

Any pointers?

python version

I got python3 installed by default but python. when to run bass, it broke. Does it support python3? Or should I fix it.

error: dictionary update sequence element #27 has length 1; 2 is required

Hi there,

this may be a super newbie problem, but I am not afraid to ask :).

Everytime I run bass I get the error

dictionary update sequence element #27 has length 1; 2 is required

even for very simple this, e.g.

bass export X=3
dictionary update sequence element #27 has length 1; 2 is required
Bass encountered an error!

I am running bass on Mac OS 10.11 El Capitan. fish is installed via brew.

brew info fish yields

brew info fish
fish: stable 2.2.0 (bottled), HEAD
User-friendly command-line shell for UNIX-like operating systems
http://fishshell.com
/usr/local/Cellar/fish/2.1.1 (677 files, 5.4M)
  Poured from bottle
/usr/local/Cellar/fish/2.2.0 (726 files, 6.7M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/fish.rb
==> Caveats
You will need to add:
  /usr/local/bin/fish
to /etc/shells. Run:
  chsh -s /usr/local/bin/fish
to make fish your default shell.

If you are upgrading from an older version of fish, you should now run:
  killall fishd
to terminate the outdated fish daemon.

and

python --version
Python 2.7.10

Adding traceback in the error handler

except Exception as e:
    print('-')
    traceback.print_exc(file=sys.stdout)
    print('-')

yields some more information:

Traceback (most recent call last):
  File "/Users/Default/.config/fish/functions/__bass.py", line 76, in <module>
    name = gen_script()
  File "/Users/Default/.config/fish/functions/__bass.py", line 42, in gen_script
    old_env = dict([line.split('=', 1) for line in old_env])
ValueError: dictionary update sequence element #27 has length 1; 2 is required

when running e.g. python ~/.config/fish/functions/__bass.py ls

Can you help me out?

Inquiry: using exec as an alternative to bass

Hi @edc! 👋

I've been running some experiments and noticed I could use exec bash -c ... instead of bass for doing the same thing. I was wondering if you were aware of this or if I was missing something.

exec bash -c "$my_bash_cmds; exec fish"

One thing this code is missing is setting the exit status when bash fails, but I could live without that.

"source: command not found" running basic example

Using the latest version of bass from github, bass doesn't seem to work at all. No matter what I try to run with it, I get the error message "source: command not found".

~/c/bass> git clone https://github.com/edc/bass
(...)

~/c/bass> make install
install -d ~/.config/fish/functions
install functions/__bass.py ~/.config/fish/functions
install functions/bass.fish ~/.config/fish/functions

[relaunch shell, then...]
~/c/bass> bass -d export X=4
read: Unknown option “-z”
/home/jason/.config/fish/functions/bass.fish (line 8):   python (dirname (status -f))/__bass.py $__bash_args | read -z __script
                                                         ^
in function “bass”,
	called on standard input,
	with parameter list “-d export X=4”


       read - read line of input into variables

   Synopsis
       read [OPTIONS] [VARIABLES...]

read: Type “help read” for related documentation

fish: Unknown command “source”
/home/jason/.config/fish/functions/bass.fish (line 15):     echo -e "$__script" | source -
                                                                                  ^
in function “bass”,
	called on standard input,
	with parameter list “-d export X=4”

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
No command 'source' found, did you mean:
 Command 'gource' from package 'gource' (universe)
source: command not found

Example on how use bass with fish functions needed

I tried to follow the comments on the __bass.py but unfortunately it did not work.
Maybe I got lost with the 'nvm' example...

Context: I have only a bash script file with a few simple functions and variables that I would like
to make it available to fish upon starting the shell.
To achieve it I created a fish function that calls "bass source myenvs.sh" but I can see that it fails sometimes because "bass" command is not available upon start.
Any suggestion??

Thanks a lot. This small piece of awesomeness made fish usable for me again. Left zsh and never looked back.

Command 'python' not found

I have python3 installed by default. Bass returns:

~ bass                                                                                         
Command 'python' not found, but can be installed with:

sudo apt install python3         # version 3.7.5-1, or
sudo apt install python          # version 2.7.17-1
sudo apt install python-minimal  # version 2.7.17-1

You also have python3 installed, you can run 'python3' instead.

~/.local/share/omf/pkg/bass/functions/bass.fish (line 10): 
  python (dirname (status -f))/__bass.py $bash_args 3>$script_file
  ^
in function “bass”
	called on standard input

AttributeError: 'exceptions.AttributeError' object has no attribute 'returncode'

~> python --version
Python 2.6.6

~> rpm --query centos-release
centos-release-6-8.el6.centos.12.3.x86_64

~> bass source ~/.nvm/nvm.sh --no-use ';' nvm install 5
Traceback (most recent call last):
  File "/root/.config/fish/functions/__bass.py", line 77, in <module>
    print('exit code:', e.returncode, file=sys.stderr)
AttributeError: 'exceptions.AttributeError' object has no attribute 'returncode'

bass command triggers rm to remove a temp file

OS: Mac OS X 10.14.6
Fish: 3.0.2

Every time I use bass I get a prompt from rm asking if I want to remove a temporary file. (as the example below)
This might be related to the pull requested merged yesterday, since the timing fits.

Usage: bass [-d] <bash-command>
rm: remove regular file '/var/folders/s4/ffqt6x516015rf37_gl41sqm0000gn/T/tmp.S6J9IeznGP'?

Weird bash error after installing via fundle

~ $ fundle -v
0.4.0
~ $ fundle plugin 'edc/bass'
~ $ fundle install
Installing edc/bass
~ $ fundle init
~ $ bass
test: Missing argument at index 2
bash: -c: line 0: syntax error near unexpected token `;'
bash: -c: line 0: `; echo "-__-__-__bass___-env-output-__bass_-__-__-__-__"; python -c 'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))''
Command '['bash', '-c', '; echo "-__-__-__bass___-env-output-__bass_-__-__-__-__"; python -c \'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))\'']' returned non-zero exit status 2
Bass encountered an error!

No idea why bash is mentioned there, fish is the default shell on my machine. Maybe it is a fundle problem, feel free to close if so.

import bash completions through bass?

Is there a way to get bass to evaluate bash tab completions? For example, the angular-cli provides a completion script to add to .bashrc in order to get tab completions for the ng tool. I'd love to have these completions available in fish through bass if possible, but I'm not sure if it's even possible.

Error, missing file __bass.py

Running on OSX, installed bass via fisherman.

~ $ bass
test: Missing argument at index 2
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/Users/pbooth/.config/fisherman/functions/__bass.py': [Errno 2] No such file or directory
test: Missing argument at index 2
~ $ ls -l /Users/pbooth/.config/fisherman/functions
total 8
-rw-r--r--  1 pbooth  staff  389 23 Jan 15:10 bass.fish
~ $ fisher -v
fisher version 0.4.0

I also tried installing via fundle but got a different error, which I'll raise separately.

`nvm current` reverts the used node version

I noticed that when I create a nvm function, as suggested in the readme, it reverts the currently used node version (from an .nvmrc file)

ie,

In .config/fish/functions/nvm.fish

function nvm
    bass source ~/.nvm/nvm.sh ';' nvm $argv
end

In a directory where I have a .nvmrc file with iojs-v2.2.1 and I run

$ nvm use
Found /Users/ttt/Work/Dev/folder/.nvmrc with version <iojs-v2.2.1>
Now using io.js v2.2.1
$ which node
/Users/ttt/.nvm/versions/io.js/v2.2.1/bin/node

which is good. But then when I run nvm current:

$ nvm current
v4.1.1
$ which node
/Users/ttt/.nvm/versions/node/v4.1.1/bin/node

It reverts back to my default version, which in this case is v4.1.1. Same for other functions that read the status of nvm eg, nvm list

Is there a way to run current or other ready only functions without loading the default?

Doesn't work

> bass /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 1m  Sat Oct 29 12:03:18 2016
$(...) is not supported. In fish, please use '(curl)'.
fish: bass /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Printf command fails in bass if feeded with "--"

Hello,
I have several scripts that are failing inside bass with the same pattern:

printf: Unknown option “-------------------- >> begin captured logging << --------------------”
- (line 565): 
printf "-------------------- >> begin captured logging << --------------------";printf '
^
from sourcing file -
	called on line 15 of file ~/.config/fish/functions/bass.fish

in function “bass”
	called on line 1 of file -
	with parameter list “commands.sh test core”

in function “inner”
	called on standard input
	with parameter list “test core”


       printfprintf - display text according to a format string
        -

   Synopsis
       printf format [argument...]

printf: Type “help printf” for related documentation

The above output was running nosetests.

I'm using fish version 2.7.1 with fisher and bass updated.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.