Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have this alias in my .zshrc:

alias grim='gvim --remote'

But this is not seen from ranger file manager, I believe that ranger runs a 'generic' shell skipping my .zshrc. I want to make this alias visible in every shell.

I added it to ~/.profile and to /etc/zsh/zshrc but no effect. To be specific a got this message:

/bin/sh: grim: not found
share|improve this question
Can you give details about your shell? – Bernhard Oct 21 '12 at 12:42
2  
Did you restart the shell or source the appropriate config? – m0nhawk Oct 21 '12 at 12:46
I use zsh. I have the alias in my .zshrc and it works. But this is not seen from ranger file manager, I believe that ranger runs a 'generic' shell skipping my .zshrc. To test my actions I open new terminal (by gnome-terminal), is it enough? – xliiv Oct 21 '12 at 13:01

3 Answers

up vote 2 down vote accepted

Only interactive shells read a file that may contain alias definitions. If you want to use a nickname for a command in shell snippets executed by applications, an alias is not the right tool. Instead, write a wrapper script like this:

#!/bin/sh
gvim --remote "$@"

Call it ~/bin/grim and make it executable. Make sure you have ~/bin in your PATH (you can put the script in any other directory that's in your PATH).

share|improve this answer
Works - thanks, thanks, thanks. :] – xliiv Oct 22 '12 at 7:05
Awesome way of doing !! – pradeepchhetri Oct 22 '12 at 20:57

You can create a file alias.sh in /etc/profile.d directory

Write the line

alias grim='gvim --remote'

inside that file alias.sh

This will create a system-wide customization.

Instead of alias.sh you can use any other filename ending with .sh

share|improve this answer
Any name for file in /etc/profile.d is acceptable? – xliiv Oct 21 '12 at 12:58
@xliiv: yes name will work. – pradeepchhetri Oct 21 '12 at 13:07
Alias from /etc/profile.d/name doensn't work either in bash or sh. :/ – xliiv Oct 21 '12 at 13:32

Did you do something like? :

source /path/to/.profile

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.