You are not logged in.
Pages: 1
Hi Archers!
I'm new here but I've been using Arch for some time, although I'm far from being a seasoned veteran. I tried to define a new alias in ~/.bashrc but it doesn't work. I tried restarting the terminal, then the whole computer and also tried issuing ". ~/.bashrc ", nothing works. By issueing alias, I get the default aliases but not my own. What am I doing wrong? I don't get it. I'm sitting here in my Arch T-shirt and Arch sweater and I'm starting to feel unworthy of them.
Btw, the alias I'm trying to create is the below one for playing a video file with Dolby Atmos passthrough:
alias atmos='mpv --audio-device='alsa/hdmi:CARD=NVidia,DEV=2' --audio-spdif=ac3,dts,dts-hd,eac3,truehd'
Thanks in advance for any help!
SOLUTION TLDR: Turns out, I was using zsh, not bash and had to add the alias in the .zshrc file.
Last edited by Archibard (2023-02-04 19:17:43)
Offline
I'd have a look at the quotation marks and maybe see whether nesting actually works if you also use the other type of quotes supported by bash.
Offline
See bash: invocation for the description of a quite convoluted way bash executes various files at startup. Verify, if “~/.bashrc” is executed at all.
I also look suspiciously at those quotation marks, but executing this on my machine worked.
Last edited by mpan (2023-02-04 10:32:40)
Paperclips in avatars?
NIST on password policies (PDF) — see §3.1.1.2
Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
but executing this on my machine worked.
Indeed, bash's smart enough.
tried issuing ". ~/.bashrc "
I tried to define a new alias in ~/.bashrc
Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855
In this case: especially post your .bashrc
Offline
Thank you for the quick responses. Yes, single quotes are working but I tried double quotes, too.
See bash: invocation for the description of a quite convoluted way bash executes various files at startup. Verify, if “~/.bashrc” is executed at all.
I read that but I don't see any problem. It says that .bash_profile is executed first and that contains:
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc
If I'm not mistaken, this checks the availability of the .bashrc file and loads it.
My .bashrc:
# colors
darkgrey="$(tput bold ; tput setaf 0)"
white="$(tput bold ; tput setaf 7)"
blue="$(tput bold; tput setaf 4)"
cyan="$(tput bold; tput setaf 6)"
nc="$(tput sgr0)"
# exports
export PATH="${HOME}/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:"
export PATH="${PATH}/usr/local/sbin:/opt/bin:/usr/bin/core_perl:/usr/games/bin:"
if [[ $EUID -eq 0 ]]; then
export PS1="\[$blue\][ \[$cyan\]\H \[$darkgrey\]\w\[$darkgrey\] \[$blue\]]\\[$darkgrey\]# \[$nc\]"
else
export PS1="\[$blue\][ \[$cyan\]\H \[$darkgrey\]\w\[$darkgrey\] \[$blue\]]\\[$cyan\]\$ \[$nc\]"
fi
export LD_PRELOAD=""
export EDITOR="vim"
# alias
alias ls="ls --color"
alias vi="vim"
alias shred="shred -zf"
alias wget="wget -U 'noleak'"
alias curl="curl --user-agent 'noleak'"
alias atmos='mpv --audio-device='alsa/hdmi:CARD=NVidia,DEV=2' --audio-spdif=ac3,dts,dts-hd,eac3,truehd'
alias sudo='sudo -v; sudo '
# source files
[ -r /usr/share/bash-completion/completions ] &&
. /usr/share/bash-completion/completions/*
Offline
Did you execute
source .bashrc
after adding your alias?
Offline
also tried issuing ". ~/.bashrc ", nothing works.
Sanity check:
echo $SHELL
alias atmos='mpv --audio-device='alsa/hdmi:CARD=NVidia,DEV=2' --audio-spdif=ac3,dts,dts-hd,eac3,truehd'
type atmos
atmos /path/to/some/file.mp3
Can you add other aliases to your bashrc
alias foo=bar
Offline
FWIW, the quotes "work" because they are irrelevant. The internal quotes are not needed at all as there are no spaces or other special characters in the inner-most quote. And bash is not smart enough to interpret these as nested quotes: there are four of them, so bash reads it as a one quoted string between the first two, one unqoted string before the next, and another quoted string until the last one, e.g., quoted in red:
alias atmos='mpv --audio-device='alsa/hdmi:CARD=NVidia,DEV=2' --audio-spdif=ac3,dts,dts-hd,eac3,truehd'
This *only* works because there are no spaces in the non-red non-quoted portion (which coincidentally is also why those are irrelevant in the first place). So while it's fine the way it is, it's fine due to some very unusual coincidences and could quite easily give a false sense of security leading to very likely breakage when the command is later modified (e.g., to add a space inside the "internal" quotes). So it'd be better to just remove the inner quotes entirely.
But this is tangential to the current issue of the alias not being available.
Last edited by Trilby (2023-02-04 16:33:11)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks Trilby, for the clarification.
Can you add other aliases to your bashrc
No, I can't, none of the aliases work in .bashrc.
Did you execute
source .bashrc
I did, but I forgot to mention what happened. When I execute it, I get this error and a crazy prompt:
>>> source .bashrc
/usr/share/bash-completion/completions/2to3:37: command not found: complete
\[\][ \[\]\H \[\]\w\[\] \[\]]\[\]$ \[\]
The last line is the actual prompt. If I restart Konsole, it goes back to normal.
Last edited by Archibard (2023-02-04 18:17:11)
Offline
seth wrote:Can you add other aliases to your bashrc
No, I can't, none of the aliases work in .bashrc.
Seriously? seth asked for a bunch of information, and you pick out probably the least important and ignore the rest?
Last edited by Scimmia (2023-02-04 18:21:55)
Online
^ It's possible the OP didn't recognise that the statement "sanity check" was a request for the output of those commands.
I think we also need to see
type "$0"
Jin, Jîyan, Azadî
Offline
>>> source .bashrc
For the prompt I'm gonna bet everyones elses right arm this is fish.
Offline
^ It's possible the OP didn't recognise that the statement "sanity check" was a request for the output of those commands.
I think we also need to see
type "$0"
Exactly.
So the outputs:
>>> echo $SHELL
/bin/zsh
>>> alias atmos='mpv --audio-device='alsa/hdmi:CARD=NVidia,DEV=2' --audio-spdif=ac3,dts,dts-hd,eac3,truehd'
>>> type atmos
atmos is an alias for mpv --audio-device=alsa/hdmi:CARD=NVidia,DEV=2 --audio-spdif=ac3,dts,dts-hd,eac3,truehd
>>> atmos video.mp4
(+) Video --vid=1 (*) (av1 460x238 29.970fps)
(+) Audio --aid=1 (*) (opus 2ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch s32
VO: [gpu] 460x238 yuv420p
AV: 00:00:08 / 00:01:35 (9%) A-V: 0.000
Track switched:
(+) Video --vid=1 (*) (av1 460x238 29.970fps)
Audio --aid=1 (*) (opus 2ch 48000Hz)
V: 00:00:11 / 00:01:35 (12%)
Track switched:
(+) Video --vid=1 (*) (av1 460x238 29.970fps)
(+) Audio --aid=1 (*) (opus 2ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch s32
AV: 00:00:24 / 00:01:35 (26%) A-V: -0.000
Exiting... (Quit)
>>> type "$0"
/bin/zsh is /bin/zsh
The video started, though there was no sound. But it's a different issue, there's no sound even if I start it from GUI.
Offline
Wait, is this the problem? That it's zsh? Whaaat?
Offline
zsh will not load .bashrc for obvious reasons.
Try ~/.zshrc
And remove the ugly fish-promt.
It cost a lot of fine people their right arms tonight
Offline
OK, yes, of course this was it. Sorry for the lame problem and thank you very much for the help, everyone!
Offline
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline
Wait, is this the problem? That it's zsh? Whaaat?
How did you install Arch?
Offline
Pages: 1