re-use '~/.profile` for Fish?

Multi tool use
up vote
25
down vote
favorite
(I'm talking about the shell Fish, esp. Fish's Fish.)
For Bash/ZSH, I had ~/.profile with some exports, aliases and other stuff.
I don't want to have a separate config for environment variables for Fish, I want to re-use my ~/.profile. How?
In The FAQ, it is stated that I can at least import those via /usr/local/share/fish/tools/import_bash_settings.py, however I don't really like running that for each Fish-instance.
shell .profile fish
add a comment |
up vote
25
down vote
favorite
(I'm talking about the shell Fish, esp. Fish's Fish.)
For Bash/ZSH, I had ~/.profile with some exports, aliases and other stuff.
I don't want to have a separate config for environment variables for Fish, I want to re-use my ~/.profile. How?
In The FAQ, it is stated that I can at least import those via /usr/local/share/fish/tools/import_bash_settings.py, however I don't really like running that for each Fish-instance.
shell .profile fish
add a comment |
up vote
25
down vote
favorite
up vote
25
down vote
favorite
(I'm talking about the shell Fish, esp. Fish's Fish.)
For Bash/ZSH, I had ~/.profile with some exports, aliases and other stuff.
I don't want to have a separate config for environment variables for Fish, I want to re-use my ~/.profile. How?
In The FAQ, it is stated that I can at least import those via /usr/local/share/fish/tools/import_bash_settings.py, however I don't really like running that for each Fish-instance.
shell .profile fish
(I'm talking about the shell Fish, esp. Fish's Fish.)
For Bash/ZSH, I had ~/.profile with some exports, aliases and other stuff.
I don't want to have a separate config for environment variables for Fish, I want to re-use my ~/.profile. How?
In The FAQ, it is stated that I can at least import those via /usr/local/share/fish/tools/import_bash_settings.py, however I don't really like running that for each Fish-instance.
shell .profile fish
shell .profile fish
asked Jul 10 '12 at 2:41
Albert
2,77963043
2,77963043
add a comment |
add a comment |
                                9 Answers
                                9
                        
active
oldest
votes
up vote
18
down vote
You can use Bash to parse /etc/profile and ~/.profile, and then start fish.
 - Create - /usr/local/bin/fishloginwith contents
 
 - #!/bin/bash -l
 exec -l fish "$@"
 
 
 - Make it executable 
 
 - sudo chmod +x /usr/local/bin/fishlogin
 
 
 - Add it to /etc/shells 
 
 - echo /usr/local/bin/fishlogin | sudo tee -a /etc/shells
 
 
 - Set it as your default shell 
 
 - sudo usermod -s /usr/local/bin/fishlogin $USER
 
 
 
 
 
 
 
 
 So elegant! Should be the accepted answer IMO
 – yonix
 Mar 22 '17 at 8:11
 
 
 
 
 
 2
 
 
 
 
 Just in case anyone is wondering, the mac equivalent of- usermod -s /usr/local/bin/fishlogin $USERis- chsh -s /usr/local/fishlogin $USER
 – gloriphobia
 May 10 '17 at 9:52
 
 
 
 
 
 1
 
 
 
 
 If you get- chsh: /usr/local/bin/fishlogin: non-standard shellneed to add it to- /etc/shells
 – Ben Marten
 Jun 3 '17 at 22:06
 
 
 
 
 
 
 
 1
 
 
 
 
 To fully imitate launching fish directly,- fish "$@"should be replaced with- exec -l fish "$@".- execreplaces the bash process with fish, while- -lcauses that- argv[0]for fish is- -fish, which signals that this is a login shell.
 – azag0
 Feb 12 at 10:28
 
 
 
 
 
 1
 
 
 
 
 @Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
 – Noé Rubinstein
 Oct 3 at 11:12
 
 
 
|
show 2 more comments
up vote
14
down vote
accepted
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
    set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/1/")
    set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/2/")
    # remove surrounding quotes if existing
    set value (echo $value | sed -E "s/^"(.*)"$/1/")
    if test $var = "PATH"
        # replace ":" by spaces. this is how PATH looks for Fish
        set value (echo $value | sed -E "s/:/ /g")
        # use eval because we need to expand the value
        eval set -xg $var $value
        continue
    end
    # evaluate variables. we can use eval because we most likely just used "$var"
    set value (eval echo $value)
    set -xg $var $value
end
 
 
 3
 
 
 
 
 can you explain what this does?
 – max pleaner
 Jan 13 '17 at 18:00
 
 
 
 
 
 
 
 
 
 @maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
 – Jared Smith
 Oct 9 at 13:40
 
 
 
add a comment |
up vote
7
down vote
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
 
 
 3
 
 
 
 
 This should be the accepted solution. You could elaborate (install omf)
 – Jules Randolph
 Apr 18 at 20:36
 
 
 
 
 
add a comment |
up vote
3
down vote
I tried sourcing .profile on fish startup and it worked like a charm for me.
just do :
echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish
Restart terminal or iterm2, test an alias from .profile to test.
Note : Won't work with more complex .profile files that use syntax not available in fish - credit @erb
 
 
 
 
 
 
 Worked for me too! Running MacOSX.
 – Alexar
 Dec 6 '15 at 3:33
 
 
 
 
 
 
 
 
 
 Won't work with more complex- .profilefiles that use syntax not available in fish.
 – erb
 Oct 6 '16 at 10:12
 
 
 
 
 
 
 
 1
 
 
 
 
 @erb I agree with you, I added the caveat in the answer.
 – Eswar Rajesh Pinapala
 Oct 6 '16 at 22:54
 
 
 
 
 
add a comment |
up vote
2
down vote
Install dash and add this line to your config.fish:
env -i HOME=$HOME dash -l -c 'export -p' | sed -e "/PATH/s/'//g;/PATH/s/:/ /g;s/=/ /;s/^export/set -x/" | source
add a comment |
up vote
1
down vote
You can't. fish's syntax is too different from Bourne shell (/bin/sh) syntax. This is the same reason you can't use .profile with other non-Bourne-derived shells, such as csh and tcsh.
 
 
 
 
 
 
 I don't want to fully execute- .profile. I just want to get all- exports from there. One easy way would be to- egrep "^export"which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this- import_bash_settings.pyscript which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.
 – Albert
 Jul 11 '12 at 14:18
 
 
 
add a comment |
up vote
1
down vote
If your distribution uses PAM, you could set your environment variables in your  ~/.pam_environment file.
add a comment |
up vote
1
down vote
You can start Fish from Bash. If you do that, Fish will inherit all environment variables (export FOO=bar) from Bash. At this point, Bash will have already read your .profile (or the like).
bash-3.2$ export TEST="test"
bash-3.2$ fish
cmey@MBP ~> echo $TEST
test
add a comment |
up vote
0
down vote
Why don't you just put in your config.fish this:
bass source ~/.profile
bass is a plugin to execute bash commands in fish.
add a comment |
                                9 Answers
                                9
                        
active
oldest
votes
                                9 Answers
                                9
                        
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
18
down vote
You can use Bash to parse /etc/profile and ~/.profile, and then start fish.
 - Create - /usr/local/bin/fishloginwith contents
 
 - #!/bin/bash -l
 exec -l fish "$@"
 
 
 - Make it executable 
 
 - sudo chmod +x /usr/local/bin/fishlogin
 
 
 - Add it to /etc/shells 
 
 - echo /usr/local/bin/fishlogin | sudo tee -a /etc/shells
 
 
 - Set it as your default shell 
 
 - sudo usermod -s /usr/local/bin/fishlogin $USER
 
 
 
 
 
 
 
 
 So elegant! Should be the accepted answer IMO
 – yonix
 Mar 22 '17 at 8:11
 
 
 
 
 
 2
 
 
 
 
 Just in case anyone is wondering, the mac equivalent of- usermod -s /usr/local/bin/fishlogin $USERis- chsh -s /usr/local/fishlogin $USER
 – gloriphobia
 May 10 '17 at 9:52
 
 
 
 
 
 1
 
 
 
 
 If you get- chsh: /usr/local/bin/fishlogin: non-standard shellneed to add it to- /etc/shells
 – Ben Marten
 Jun 3 '17 at 22:06
 
 
 
 
 
 
 
 1
 
 
 
 
 To fully imitate launching fish directly,- fish "$@"should be replaced with- exec -l fish "$@".- execreplaces the bash process with fish, while- -lcauses that- argv[0]for fish is- -fish, which signals that this is a login shell.
 – azag0
 Feb 12 at 10:28
 
 
 
 
 
 1
 
 
 
 
 @Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
 – Noé Rubinstein
 Oct 3 at 11:12
 
 
 
|
show 2 more comments
up vote
18
down vote
You can use Bash to parse /etc/profile and ~/.profile, and then start fish.
 - Create - /usr/local/bin/fishloginwith contents
 
 - #!/bin/bash -l
 exec -l fish "$@"
 
 
 - Make it executable 
 
 - sudo chmod +x /usr/local/bin/fishlogin
 
 
 - Add it to /etc/shells 
 
 - echo /usr/local/bin/fishlogin | sudo tee -a /etc/shells
 
 
 - Set it as your default shell 
 
 - sudo usermod -s /usr/local/bin/fishlogin $USER
 
 
 
 
 
 
 
 
 So elegant! Should be the accepted answer IMO
 – yonix
 Mar 22 '17 at 8:11
 
 
 
 
 
 2
 
 
 
 
 Just in case anyone is wondering, the mac equivalent of- usermod -s /usr/local/bin/fishlogin $USERis- chsh -s /usr/local/fishlogin $USER
 – gloriphobia
 May 10 '17 at 9:52
 
 
 
 
 
 1
 
 
 
 
 If you get- chsh: /usr/local/bin/fishlogin: non-standard shellneed to add it to- /etc/shells
 – Ben Marten
 Jun 3 '17 at 22:06
 
 
 
 
 
 
 
 1
 
 
 
 
 To fully imitate launching fish directly,- fish "$@"should be replaced with- exec -l fish "$@".- execreplaces the bash process with fish, while- -lcauses that- argv[0]for fish is- -fish, which signals that this is a login shell.
 – azag0
 Feb 12 at 10:28
 
 
 
 
 
 1
 
 
 
 
 @Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
 – Noé Rubinstein
 Oct 3 at 11:12
 
 
 
|
show 2 more comments
up vote
18
down vote
up vote
18
down vote
You can use Bash to parse /etc/profile and ~/.profile, and then start fish.
 - Create - /usr/local/bin/fishloginwith contents
 
 - #!/bin/bash -l
 exec -l fish "$@"
 
 
 - Make it executable 
 
 - sudo chmod +x /usr/local/bin/fishlogin
 
 
 - Add it to /etc/shells 
 
 - echo /usr/local/bin/fishlogin | sudo tee -a /etc/shells
 
 
 - Set it as your default shell 
 
 - sudo usermod -s /usr/local/bin/fishlogin $USER
 
 
You can use Bash to parse /etc/profile and ~/.profile, and then start fish.
 - Create - /usr/local/bin/fishloginwith contents
 
 - #!/bin/bash -l
 exec -l fish "$@"
 
 
 - Make it executable 
 
 - sudo chmod +x /usr/local/bin/fishlogin
 
 
 - Add it to /etc/shells 
 
 - echo /usr/local/bin/fishlogin | sudo tee -a /etc/shells
 
 
 - Set it as your default shell 
 
 - sudo usermod -s /usr/local/bin/fishlogin $USER
 
 
edited Feb 28 at 17:14
answered Feb 29 '16 at 15:50
Noé Rubinstein
28025
28025
 
 
 
 
 
 
 So elegant! Should be the accepted answer IMO
 – yonix
 Mar 22 '17 at 8:11
 
 
 
 
 
 2
 
 
 
 
 Just in case anyone is wondering, the mac equivalent of- usermod -s /usr/local/bin/fishlogin $USERis- chsh -s /usr/local/fishlogin $USER
 – gloriphobia
 May 10 '17 at 9:52
 
 
 
 
 
 1
 
 
 
 
 If you get- chsh: /usr/local/bin/fishlogin: non-standard shellneed to add it to- /etc/shells
 – Ben Marten
 Jun 3 '17 at 22:06
 
 
 
 
 
 
 
 1
 
 
 
 
 To fully imitate launching fish directly,- fish "$@"should be replaced with- exec -l fish "$@".- execreplaces the bash process with fish, while- -lcauses that- argv[0]for fish is- -fish, which signals that this is a login shell.
 – azag0
 Feb 12 at 10:28
 
 
 
 
 
 1
 
 
 
 
 @Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
 – Noé Rubinstein
 Oct 3 at 11:12
 
 
 
|
show 2 more comments
 
 
 
 
 
 
 So elegant! Should be the accepted answer IMO
 – yonix
 Mar 22 '17 at 8:11
 
 
 
 
 
 2
 
 
 
 
 Just in case anyone is wondering, the mac equivalent of- usermod -s /usr/local/bin/fishlogin $USERis- chsh -s /usr/local/fishlogin $USER
 – gloriphobia
 May 10 '17 at 9:52
 
 
 
 
 
 1
 
 
 
 
 If you get- chsh: /usr/local/bin/fishlogin: non-standard shellneed to add it to- /etc/shells
 – Ben Marten
 Jun 3 '17 at 22:06
 
 
 
 
 
 
 
 1
 
 
 
 
 To fully imitate launching fish directly,- fish "$@"should be replaced with- exec -l fish "$@".- execreplaces the bash process with fish, while- -lcauses that- argv[0]for fish is- -fish, which signals that this is a login shell.
 – azag0
 Feb 12 at 10:28
 
 
 
 
 
 1
 
 
 
 
 @Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
 – Noé Rubinstein
 Oct 3 at 11:12
 
 
 
So elegant! Should be the accepted answer IMO
– yonix
Mar 22 '17 at 8:11
So elegant! Should be the accepted answer IMO
– yonix
Mar 22 '17 at 8:11
2
2
Just in case anyone is wondering, the mac equivalent of
usermod -s /usr/local/bin/fishlogin $USER is chsh -s /usr/local/fishlogin $USER– gloriphobia
May 10 '17 at 9:52
Just in case anyone is wondering, the mac equivalent of
usermod -s /usr/local/bin/fishlogin $USER is chsh -s /usr/local/fishlogin $USER– gloriphobia
May 10 '17 at 9:52
1
1
If you get
chsh: /usr/local/bin/fishlogin: non-standard shell need to add it to /etc/shells– Ben Marten
Jun 3 '17 at 22:06
If you get
chsh: /usr/local/bin/fishlogin: non-standard shell need to add it to /etc/shells– Ben Marten
Jun 3 '17 at 22:06
1
1
To fully imitate launching fish directly,
fish "$@" should be replaced with exec -l fish "$@". exec replaces the bash process with fish, while -l causes that argv[0] for fish is -fish, which signals that this is a login shell.– azag0
Feb 12 at 10:28
To fully imitate launching fish directly,
fish "$@" should be replaced with exec -l fish "$@". exec replaces the bash process with fish, while -l causes that argv[0] for fish is -fish, which signals that this is a login shell.– azag0
Feb 12 at 10:28
1
1
@Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
– Noé Rubinstein
Oct 3 at 11:12
@Sz. Well, nope. Fish does not support subshells in the first place. And even if it did, it would not do so by executing your login shell, so no Bash would be spawned then.
– Noé Rubinstein
Oct 3 at 11:12
|
show 2 more comments
up vote
14
down vote
accepted
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
    set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/1/")
    set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/2/")
    # remove surrounding quotes if existing
    set value (echo $value | sed -E "s/^"(.*)"$/1/")
    if test $var = "PATH"
        # replace ":" by spaces. this is how PATH looks for Fish
        set value (echo $value | sed -E "s/:/ /g")
        # use eval because we need to expand the value
        eval set -xg $var $value
        continue
    end
    # evaluate variables. we can use eval because we most likely just used "$var"
    set value (eval echo $value)
    set -xg $var $value
end
 
 
 3
 
 
 
 
 can you explain what this does?
 – max pleaner
 Jan 13 '17 at 18:00
 
 
 
 
 
 
 
 
 
 @maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
 – Jared Smith
 Oct 9 at 13:40
 
 
 
add a comment |
up vote
14
down vote
accepted
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
    set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/1/")
    set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/2/")
    # remove surrounding quotes if existing
    set value (echo $value | sed -E "s/^"(.*)"$/1/")
    if test $var = "PATH"
        # replace ":" by spaces. this is how PATH looks for Fish
        set value (echo $value | sed -E "s/:/ /g")
        # use eval because we need to expand the value
        eval set -xg $var $value
        continue
    end
    # evaluate variables. we can use eval because we most likely just used "$var"
    set value (eval echo $value)
    set -xg $var $value
end
 
 
 3
 
 
 
 
 can you explain what this does?
 – max pleaner
 Jan 13 '17 at 18:00
 
 
 
 
 
 
 
 
 
 @maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
 – Jared Smith
 Oct 9 at 13:40
 
 
 
add a comment |
up vote
14
down vote
accepted
up vote
14
down vote
accepted
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
    set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/1/")
    set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/2/")
    # remove surrounding quotes if existing
    set value (echo $value | sed -E "s/^"(.*)"$/1/")
    if test $var = "PATH"
        # replace ":" by spaces. this is how PATH looks for Fish
        set value (echo $value | sed -E "s/:/ /g")
        # use eval because we need to expand the value
        eval set -xg $var $value
        continue
    end
    # evaluate variables. we can use eval because we most likely just used "$var"
    set value (eval echo $value)
    set -xg $var $value
end
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
    set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/1/")
    set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)$/2/")
    # remove surrounding quotes if existing
    set value (echo $value | sed -E "s/^"(.*)"$/1/")
    if test $var = "PATH"
        # replace ":" by spaces. this is how PATH looks for Fish
        set value (echo $value | sed -E "s/:/ /g")
        # use eval because we need to expand the value
        eval set -xg $var $value
        continue
    end
    # evaluate variables. we can use eval because we most likely just used "$var"
    set value (eval echo $value)
    set -xg $var $value
end
answered Jul 11 '12 at 19:31
Albert
2,77963043
2,77963043
 
 
 3
 
 
 
 
 can you explain what this does?
 – max pleaner
 Jan 13 '17 at 18:00
 
 
 
 
 
 
 
 
 
 @maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
 – Jared Smith
 Oct 9 at 13:40
 
 
 
add a comment |
 
 
 3
 
 
 
 
 can you explain what this does?
 – max pleaner
 Jan 13 '17 at 18:00
 
 
 
 
 
 
 
 
 
 @maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
 – Jared Smith
 Oct 9 at 13:40
 
 
 
3
3
can you explain what this does?
– max pleaner
Jan 13 '17 at 18:00
can you explain what this does?
– max pleaner
Jan 13 '17 at 18:00
@maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
– Jared Smith
Oct 9 at 13:40
@maxpleaner AFAICT it looks through .profile for export statements and executes them as fish sets. It's kinda hacky, but clever.
– Jared Smith
Oct 9 at 13:40
add a comment |
up vote
7
down vote
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
 
 
 3
 
 
 
 
 This should be the accepted solution. You could elaborate (install omf)
 – Jules Randolph
 Apr 18 at 20:36
 
 
 
 
 
add a comment |
up vote
7
down vote
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
 
 
 3
 
 
 
 
 This should be the accepted solution. You could elaborate (install omf)
 – Jules Randolph
 Apr 18 at 20:36
 
 
 
 
 
add a comment |
up vote
7
down vote
up vote
7
down vote
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
answered Jan 2 '17 at 15:35
jgillich
4951719
4951719
 
 
 3
 
 
 
 
 This should be the accepted solution. You could elaborate (install omf)
 – Jules Randolph
 Apr 18 at 20:36
 
 
 
 
 
add a comment |
 
 
 3
 
 
 
 
 This should be the accepted solution. You could elaborate (install omf)
 – Jules Randolph
 Apr 18 at 20:36
 
 
 
 
 
3
3
This should be the accepted solution. You could elaborate (install omf)
– Jules Randolph
Apr 18 at 20:36
This should be the accepted solution. You could elaborate (install omf)
– Jules Randolph
Apr 18 at 20:36
add a comment |
up vote
3
down vote
I tried sourcing .profile on fish startup and it worked like a charm for me.
just do :
echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish
Restart terminal or iterm2, test an alias from .profile to test.
Note : Won't work with more complex .profile files that use syntax not available in fish - credit @erb
 
 
 
 
 
 
 Worked for me too! Running MacOSX.
 – Alexar
 Dec 6 '15 at 3:33
 
 
 
 
 
 
 
 
 
 Won't work with more complex- .profilefiles that use syntax not available in fish.
 – erb
 Oct 6 '16 at 10:12
 
 
 
 
 
 
 
 1
 
 
 
 
 @erb I agree with you, I added the caveat in the answer.
 – Eswar Rajesh Pinapala
 Oct 6 '16 at 22:54
 
 
 
 
 
add a comment |
up vote
3
down vote
I tried sourcing .profile on fish startup and it worked like a charm for me.
just do :
echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish
Restart terminal or iterm2, test an alias from .profile to test.
Note : Won't work with more complex .profile files that use syntax not available in fish - credit @erb
 
 
 
 
 
 
 Worked for me too! Running MacOSX.
 – Alexar
 Dec 6 '15 at 3:33
 
 
 
 
 
 
 
 
 
 Won't work with more complex- .profilefiles that use syntax not available in fish.
 – erb
 Oct 6 '16 at 10:12
 
 
 
 
 
 
 
 1
 
 
 
 
 @erb I agree with you, I added the caveat in the answer.
 – Eswar Rajesh Pinapala
 Oct 6 '16 at 22:54
 
 
 
 
 
add a comment |
up vote
3
down vote
up vote
3
down vote
I tried sourcing .profile on fish startup and it worked like a charm for me.
just do :
echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish
Restart terminal or iterm2, test an alias from .profile to test.
Note : Won't work with more complex .profile files that use syntax not available in fish - credit @erb
I tried sourcing .profile on fish startup and it worked like a charm for me.
just do :
echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish
Restart terminal or iterm2, test an alias from .profile to test.
Note : Won't work with more complex .profile files that use syntax not available in fish - credit @erb
edited Oct 6 '16 at 22:53
answered Oct 5 '15 at 5:47


Eswar Rajesh Pinapala
1614
1614
 
 
 
 
 
 
 Worked for me too! Running MacOSX.
 – Alexar
 Dec 6 '15 at 3:33
 
 
 
 
 
 
 
 
 
 Won't work with more complex- .profilefiles that use syntax not available in fish.
 – erb
 Oct 6 '16 at 10:12
 
 
 
 
 
 
 
 1
 
 
 
 
 @erb I agree with you, I added the caveat in the answer.
 – Eswar Rajesh Pinapala
 Oct 6 '16 at 22:54
 
 
 
 
 
add a comment |
 
 
 
 
 
 
 Worked for me too! Running MacOSX.
 – Alexar
 Dec 6 '15 at 3:33
 
 
 
 
 
 
 
 
 
 Won't work with more complex- .profilefiles that use syntax not available in fish.
 – erb
 Oct 6 '16 at 10:12
 
 
 
 
 
 
 
 1
 
 
 
 
 @erb I agree with you, I added the caveat in the answer.
 – Eswar Rajesh Pinapala
 Oct 6 '16 at 22:54
 
 
 
 
 
Worked for me too! Running MacOSX.
– Alexar
Dec 6 '15 at 3:33
Worked for me too! Running MacOSX.
– Alexar
Dec 6 '15 at 3:33
Won't work with more complex
.profile files that use syntax not available in fish.– erb
Oct 6 '16 at 10:12
Won't work with more complex
.profile files that use syntax not available in fish.– erb
Oct 6 '16 at 10:12
1
1
@erb I agree with you, I added the caveat in the answer.
– Eswar Rajesh Pinapala
Oct 6 '16 at 22:54
@erb I agree with you, I added the caveat in the answer.
– Eswar Rajesh Pinapala
Oct 6 '16 at 22:54
add a comment |
up vote
2
down vote
Install dash and add this line to your config.fish:
env -i HOME=$HOME dash -l -c 'export -p' | sed -e "/PATH/s/'//g;/PATH/s/:/ /g;s/=/ /;s/^export/set -x/" | source
add a comment |
up vote
2
down vote
Install dash and add this line to your config.fish:
env -i HOME=$HOME dash -l -c 'export -p' | sed -e "/PATH/s/'//g;/PATH/s/:/ /g;s/=/ /;s/^export/set -x/" | source
add a comment |
up vote
2
down vote
up vote
2
down vote
Install dash and add this line to your config.fish:
env -i HOME=$HOME dash -l -c 'export -p' | sed -e "/PATH/s/'//g;/PATH/s/:/ /g;s/=/ /;s/^export/set -x/" | source
Install dash and add this line to your config.fish:
env -i HOME=$HOME dash -l -c 'export -p' | sed -e "/PATH/s/'//g;/PATH/s/:/ /g;s/=/ /;s/^export/set -x/" | source
edited Sep 11 '15 at 9:24
answered Sep 5 '15 at 17:42
Yegorius
192
192
add a comment |
add a comment |
up vote
1
down vote
You can't. fish's syntax is too different from Bourne shell (/bin/sh) syntax. This is the same reason you can't use .profile with other non-Bourne-derived shells, such as csh and tcsh.
 
 
 
 
 
 
 I don't want to fully execute- .profile. I just want to get all- exports from there. One easy way would be to- egrep "^export"which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this- import_bash_settings.pyscript which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.
 – Albert
 Jul 11 '12 at 14:18
 
 
 
add a comment |
up vote
1
down vote
You can't. fish's syntax is too different from Bourne shell (/bin/sh) syntax. This is the same reason you can't use .profile with other non-Bourne-derived shells, such as csh and tcsh.
 
 
 
 
 
 
 I don't want to fully execute- .profile. I just want to get all- exports from there. One easy way would be to- egrep "^export"which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this- import_bash_settings.pyscript which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.
 – Albert
 Jul 11 '12 at 14:18
 
 
 
add a comment |
up vote
1
down vote
up vote
1
down vote
You can't. fish's syntax is too different from Bourne shell (/bin/sh) syntax. This is the same reason you can't use .profile with other non-Bourne-derived shells, such as csh and tcsh.
You can't. fish's syntax is too different from Bourne shell (/bin/sh) syntax. This is the same reason you can't use .profile with other non-Bourne-derived shells, such as csh and tcsh.
answered Jul 10 '12 at 6:58
Spiff
76.1k10116158
76.1k10116158
 
 
 
 
 
 
 I don't want to fully execute- .profile. I just want to get all- exports from there. One easy way would be to- egrep "^export"which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this- import_bash_settings.pyscript which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.
 – Albert
 Jul 11 '12 at 14:18
 
 
 
add a comment |
 
 
 
 
 
 
 I don't want to fully execute- .profile. I just want to get all- exports from there. One easy way would be to- egrep "^export"which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this- import_bash_settings.pyscript which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.
 – Albert
 Jul 11 '12 at 14:18
 
 
 
I don't want to fully execute
.profile. I just want to get all exports from there. One easy way would be to egrep "^export" which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this import_bash_settings.py script which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.– Albert
Jul 11 '12 at 14:18
I don't want to fully execute
.profile. I just want to get all exports from there. One easy way would be to egrep "^export" which would be good enough already for me. Another, more correct solution would be this. Also, I e.g. could run this import_bash_settings.py script which probably does something similar. So, there are obviously many ways to do this. With my question here, I was wondering how others have solved this.– Albert
Jul 11 '12 at 14:18
add a comment |
up vote
1
down vote
If your distribution uses PAM, you could set your environment variables in your  ~/.pam_environment file.
add a comment |
up vote
1
down vote
If your distribution uses PAM, you could set your environment variables in your  ~/.pam_environment file.
add a comment |
up vote
1
down vote
up vote
1
down vote
If your distribution uses PAM, you could set your environment variables in your  ~/.pam_environment file.
If your distribution uses PAM, you could set your environment variables in your  ~/.pam_environment file.
answered Jan 5 '15 at 4:55
kzh
2,20362231
2,20362231
add a comment |
add a comment |
up vote
1
down vote
You can start Fish from Bash. If you do that, Fish will inherit all environment variables (export FOO=bar) from Bash. At this point, Bash will have already read your .profile (or the like).
bash-3.2$ export TEST="test"
bash-3.2$ fish
cmey@MBP ~> echo $TEST
test
add a comment |
up vote
1
down vote
You can start Fish from Bash. If you do that, Fish will inherit all environment variables (export FOO=bar) from Bash. At this point, Bash will have already read your .profile (or the like).
bash-3.2$ export TEST="test"
bash-3.2$ fish
cmey@MBP ~> echo $TEST
test
add a comment |
up vote
1
down vote
up vote
1
down vote
You can start Fish from Bash. If you do that, Fish will inherit all environment variables (export FOO=bar) from Bash. At this point, Bash will have already read your .profile (or the like).
bash-3.2$ export TEST="test"
bash-3.2$ fish
cmey@MBP ~> echo $TEST
test
You can start Fish from Bash. If you do that, Fish will inherit all environment variables (export FOO=bar) from Bash. At this point, Bash will have already read your .profile (or the like).
bash-3.2$ export TEST="test"
bash-3.2$ fish
cmey@MBP ~> echo $TEST
test
answered Aug 28 '15 at 12:40
cmey
111
111
add a comment |
add a comment |
up vote
0
down vote
Why don't you just put in your config.fish this:
bass source ~/.profile
bass is a plugin to execute bash commands in fish.
add a comment |
up vote
0
down vote
Why don't you just put in your config.fish this:
bass source ~/.profile
bass is a plugin to execute bash commands in fish.
add a comment |
up vote
0
down vote
up vote
0
down vote
Why don't you just put in your config.fish this:
bass source ~/.profile
bass is a plugin to execute bash commands in fish.
Why don't you just put in your config.fish this:
bass source ~/.profile
bass is a plugin to execute bash commands in fish.
answered Nov 26 at 18:01
rsalmei
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f446925%2fre-use-profile-for-fish%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
U2e2B4qNfry0Nor36,mnYTSu,hl5Fxz,Pma7WukKVX 7DHoTQLmGTrP j2adeq2j,qcaY WdY6SVw7yhpNjyH9Qm83z,AP,5klbUrN