[BUG] A little help with aliases please?
Closed this issue · 16 comments
Describe the bug
No matter what I add to the file 10-aliases, I can't get my aliases to work, or even the other aliases that are listed in the files.
To Reproduce
Installed CachyOS, selecting hyprland as the window manager.
Installed ML4W via pacman, and ran the ml4w-hyprland-setup script.
Opened a shell via Super+Enter.
Try to run any alias listed.
Expected behavior*
Alias to work, i.e. typing "ls" and receiving the output of lsd(ls with icons)
Distribution (please complete the following information):
- Arch Linux
+Thank you for all the work you folks have put in on this project, the final product is AMAZING. Thank you! And sorry about reporting it as a "bug", just couldn't find a decent answer with google. Thanks in advance for any advice or tips I can get.
Hi.
First please check which shell is enabled. In my case it's zsh.
Then cd into .config/zshrc (cd into bashrc if you're using bash) and create a new file 26-aliases
Add the command
alias mytest="echo 'This is my test'"
Close all terminals. Open a terminal and enter mytest
You should see the output This is my test.
Please check the screenshot incl. all steps:
Can you rename 10-aliases to 25-aliases?
And close alacritty and start again.
OK, done. No change. Looking at 10-aliases(now 25-aliases), I do notice that some of the aliases are listed using single quotes after the =, others have the double quotes. I don't know if this effects anything or not?... the alias mytest does not work, however when I type "gs" (for the git status alias) the terminal reports that is is not a git repository. So it seems some aliases are actually working...
I just ran into this issue as well. It appears that oh-my-zsh adds some of its own aliases specifically in ~/.oh-my-zsh/lib/directories.zsh
. So if you want to overwrite these you will need to load the customization file from ~/.config/zshrc before the aliases file.
I accomplished this by changing the filenames to 10-customization
and 20-aliases
directories.zsh:alias -g ...='../..'
directories.zsh:alias -g ....='../../..'
directories.zsh:alias -g .....='../../../..'
directories.zsh:alias -g ......='../../../../..'
directories.zsh:alias -- -='cd -'
directories.zsh:alias 1='cd -1'
directories.zsh:alias 2='cd -2'
directories.zsh:alias 3='cd -3'
directories.zsh:alias 4='cd -4'
directories.zsh:alias 5='cd -5'
directories.zsh:alias 6='cd -6'
directories.zsh:alias 7='cd -7'
directories.zsh:alias 8='cd -8'
directories.zsh:alias 9='cd -9'
directories.zsh:alias md='mkdir -p'
directories.zsh:alias rd=rmdir
directories.zsh:alias lsa='ls -lah'
directories.zsh:alias l='ls -lah'
directories.zsh:alias ll='ls -lh'
directories.zsh:alias la='ls -lAh'
The same will be true if you load the git plugin but want to overwrite the supplied aliases for git with your own.
If I'm understanding you correctly prymallnstynct, I have renamed the files in the ~/.config/zshrc/ directory so that now there is 00-init, 10-customization, 20-aliases, and 30-autostart. Is that what you meant? Although after doing this the aliases still aren't working...
Another thing, here is the contents of 00-init.... Is yours similar? Any differences? It looks to me like its sourcing zshrc from the .oh-my-zsh with the line ZSH="$HOME/.oh-my-zsh". But I may be interpreting the command incorrectly? Thanks
00-init
-----------------------------------------------------
INIT
-----------------------------------------------------
-----------------------------------------------------
Exports
-----------------------------------------------------
export EDITOR=nvim
export PATH="/usr/lib/ccache/bin/:$PATH"
export ZSH="$HOME/.oh-my-zsh"
Yes, that is how I changed the files in the .config/zshrc
directory and also yes my 00-init
file looks the same.
The line export ZSH="$HOME/.oh-my-zsh"
is setting the variable ZSH
to equal $HOME/.oh-my-zsh
which is called later in 10-customization file to source $ZSH/oh-my-zsh.sh
which will load your whole config.
Out of curiosity can you check that ~/.oh-my-zsh/oh-my-zsh.sh
exists?
OK, just wasn't 100% sure about that. Thanks for clearing that up for me. I checked and yes, it does exist (and does contain stuff)
OK, so I' ve found a work-around! I placed the alias I wished to add to the file 30-autostart, which was "alias ls='lsd'". Then after popping a new terminal (alacritty) the alias worked!!! I'm thinking perhaps the autostart config is being ran but for some reason the others are not? Not really sure, but, hey, at least it works for now! Thanks for the ideas so far, and once again thanks to everyone who contributes to this project and the other users also. Really great. Thank you.
Glad you figured it out for your setup.
I will release 2.9.6.4 today. Can you please test again and reopen the issue if needed?
This is great. Thank you. Testing and sharing ideas is always more than welcome. I will ask for help from now on on the discussion section on GitHub.