Shells

Carter Green
Carter Green

Hey, Sup Forums! Which shell do you use, and why? What do you like about it, compared to other shells? And most importantly, can you hear the ocean?

All urls found in this thread:
https://mywiki.wooledge.org/BashGuide
https://www.gnu.org/software/bash/manual/html_node/index.html
https://mywiki.wooledge.org/BashPitfalls
https://github.com/TidOS/gshell
https://static.rust-lang.org/rustup.sh
https://static.rust-lang.org/rustup.sh
http://wttr.in/brisbane'
http://wttr.in/
http://wttr.in/chengdu'
Charles Murphy
Charles Murphy

bash because it just werks

Isaiah Reyes
Isaiah Reyes

for interactive: default one on system (bash, ksh, ash based on machine)
for scripting: posix shell, rc

Ryan Ross
Ryan Ross

What's so good about rc?

Alexander Jenkins
Alexander Jenkins

bash because it's everywhere and Im not a special snowflake.

Juan Anderson
Juan Anderson

zsh because menu select completion

Grayson Jenkins
Grayson Jenkins

it's actually fast, saner arrays, comfier syntax, and I install plan9ports everywhere anyway

James Martinez
James Martinez

dash for scripting (it's currently the fastest shell out there)
bash for interactive use and scripting where dash isn't enough (because it's the standard)

Bentley Watson
Bentley Watson

GNU Bash.

Lucas Lewis
Lucas Lewis

Also bash because it's the only I've read the entire manual for and the one I've been using for the longest time.

There's nothing that I've seen in zsh/fish that's worth spending the time to learn a new shell. I'll use ksh on some systems.

You can do that in bash, although it's not as powerful. It doesn't highlight the current entry or seperate commands and aliases. It's very usable though.

Even if you don't use bash you might want to do this because it affects all readline applications(you can make specific to a single one if you want). In .inputrc:

set menu-complete-display-prefix on
set show-all-if-ambiguous on

Tab: menu-complete

I would also recommend in .inputrc:

set colored-completion-prefix on
set colored-stats on
set completion-ignore-case on
set completion-map-case on
set match-hidden-files on

Levi Gonzalez
Levi Gonzalez

I like discussing shells so I'll bump this thread with something else.

A zsh thing that's not in bash is spell checking, you can hack your own in bash. Install a spell checker(aspell) and make it use commands. Also you can do whatever you want in command_not_found(), like adding package manager search(pacman in this case).

# based on pkgfile's /usr/share/doc/pkgfile/command-not-found.bash
_pacman_check() {
type pkgfile &>/dev/null || return

local pkgs
mapfile -t pkgs < <(pkgfile -bv -- "$1" 2>/dev/null)

(( ${#pkgs[*]} )) || return

printf "%s may be found in the following packages:\n" "$1"
printf " %s\n" "${pkgs[@]}"
}

_spell_check() {
[[ -f ${BASH_ASPELL_DICT} ]] || return
type aspell &>/dev/null || return

aspell -d "${BASH_ASPELL_DICT}" -a --sug-mode=fast <<< "$1" 2>&1 | \
sed -n 's/^&.*: /Did you mean: /p'
}

command_not_found_handle() {
echo "$(basename -- "${SHELL}"): command not found: $1" 1>&2
_pacman_check "[email protected]" && return
_spell_check "[email protected]" && return
}

BASH_ASPELL_DICT can be something like ~/.cache/bash-aspell-dict. You can generate the list with something like:

while read -d: dir; do
for file in "${dir}"/*; do
[[ -x ${file} ]] || continue
basename -- "${file}"
done
done <<<"${PATH}" | \
aspell --lang=en --dont-validate-words \
create master "${BASH_ASPELL_DICT}"

Example:

~ $ mksh
bash: command not found: mksh
mksh may be found in the following packages:
community/mksh 56.b-1 /usr/bin/mksh
~ $ bassh
bash: command not found: bassh
Did you mean: bash, bssh

Michael Rogers
Michael Rogers

I like zsh because of its autocompletion.

Jaxon Wright
Jaxon Wright

System Shell - dash
Interactive Shell - zsh

Joshua Barnes
Joshua Barnes

bash because when I do need to use it I have a qt girl(girl) guide me through using it.

John Cooper
John Cooper

Another interesting thing I don't seem to have anymore is that bash has HOSTFILE, so when readline sees that it needs to complete a hostname it can use those names to complete.

The way I had it rigged up was that I was using dnsmasq locally to cache DNS and I would periodically dump the cache to a file and use that as HOSTFILE. With it I could tab complete any domain I accessed recently.

I don't have it on this laptop but I should remake it.

Benjamin Rivera
Benjamin Rivera

That's really cool! I'm gonna give it a try.

Kayden Barnes
Kayden Barnes

fish because it just werks and muh autocompletion

Angel King
Angel King

Another thing, if you want, you could add to command_not_found_handle() is something that will run a file based on MIME type.

_mime_run() {
local prog

[[ -f "$1" ]] || return

case "$(file -b --mime-type -- "$1")" in
video/*|audio/*) prog=mpv ;;
image/*) prog=feh ;;
application/pdf) prog=mupdf ;;
text/*) prog="${PAGER}" ;;
# ...
*) return 1
esac

"${prog}" "[email protected]"
}

So you can do:

~ $ *.mkv
# instead of
~ $ mpv *.mkv

Not super useful but it's kind of neat.

Noah Torres
Noah Torres

This guys knows what's up.

Christian Young
Christian Young

Ignoring 'current state of g doesn't know bash'
I would really like to learn some bash while on my break, could you recommend some good starting learning resources?

David Clark
David Clark

Zsh because I'm used to it now, and I don't know any bashisms
I also enjoy floating point support, lets me actually use my shell as a calculator

Jose Baker
Jose Baker

Start with wooledge then read/reference the GNU bash manual. Depending on your system it's probably accessable through

info bash

If you don't know how to use GNU info, either `info info' or use the online HTML version.

https://mywiki.wooledge.org/BashGuide
https://www.gnu.org/software/bash/manual/html_node/index.html

current state of g doesn't know bash
It's not just Sup Forums, it's almost everybody who uses bash. They know how to type commands and use pipes but if you've ever seen the average shell script people shit out, it's obvious most of them don't know bash. It's also why wooledge has this page:

https://mywiki.wooledge.org/BashPitfalls

If you're wondering who Wooledge is, he's a kind autist who helps people with shell, kind of like what I'm trying to do but puts more effort in. He also does it on mailing lists instead of Sup Forums.

Owen Myers
Owen Myers

Best way to write hello world in bash?

Angel Torres
Angel Torres

Install the GNU hello program then simply run:

$ hello

Jason Sanders
Jason Sanders

No installing is allowed.

Oliver Johnson
Oliver Johnson

mksh is best shell, enjoy ur bloated zsh fags

Wyatt Adams
Wyatt Adams

zsh because it's like bash in that it just werks, but it's better

Alexander Wright
Alexander Wright

this guy knows what the fuck is up

the computer is meant to be customized by you to do stuff for you automatically, and the shell is the primary means of doing so.

Jace Sanders
Jace Sanders

csh

Colton Roberts
Colton Roberts

Why not /g/shell
https://github.com/TidOS/gshell

Jacob Howard
Jacob Howard

I put my aliases in a separate file called .aliases

here is a sample of my collection

alias showHiddenFiles='defaults write com.apple.finder AppleShowAllFiles YES && echo "shown"'
alias hideHiddenFiles='defaults write com.apple.finder AppleShowAllFiles NO && echo "hidden"'

alias shakeandbake='configure && make && sudo make install'

alias myip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '$"
alias myextip='curl ipinfo.io/ip'
alias ipinfo='ifconfig | grep inet'

alias brewup='brew update && brew upgrade && brew cleanup'
alias convertalltomp3='find ./ -name "*.wav" -execdir lame -V -q 0 {} \;'
alias httpserver='python -m http.server'

alias save='git add * && git commit -m quicksave'
alias debug='lldb'
alias eterm='vi ~/.zshrc'
alias refterm='source ~/.zshrc'
alias ls='ls -Gh'
alias updateRust='curl https://static.rust-lang.org/rustup.sh | sudo sh'
alias updateRustNightly='curl -sSf https://static.rust-lang.org/rustup.sh | sh $'

# Funny stuff
alias we='curl http://wttr.in/brisbane'
alias wea='curl --silent http://wttr.in/ | head -7'
alias chengdu='curl http://wttr.in/chengdu'
alias ayy='echo lmao'
alias hello="echo let\'s get cracking"

alias gitgud='git push -u origin master'
alias save='git add * && git commit -m quicksave'

# Windows/Bootcamp
alias win='Volumes/BOOTCAMP/Users/gamerx/Desktop'
alias windows='/usr/local/bin/windows'
alias killvm='killall "VMware Fusion Start Menu"'

alias forceEmptyTrash='sudo rm -rf ~/.Trash/*'

alias octave='octave-cli'
alias raspi='screen /dev/tty.usbserial-AI02CWTB 115200'
alias antivirus='~/.clamscan_daily.sh'
alias avscan='~/.clamscan_daily.sh'

echo "Aliases loaded. Shell ready. "

Jayden Gomez
Jayden Gomez

Whatever's in the distro because I don't do complicated enough shit for it to matter

Parker Ortiz
Parker Ortiz

zsh because it just werks even better than bash which sometimes doesn't just werk unless you read the RTFM and spend an hour configuring it

To be honest with you, I copied all my zsh-specific configs from other people. I tried with bash configs but they all sucked in comparison.

and I script in ksh so

using GNU

Ayden Taylor
Ayden Taylor

he doesn't script in bourne shell

Asher Richardson
Asher Richardson

echo "Aliases loaded. Shell ready. "
For what purpose?

Blake Cooper
Blake Cooper

autism

Elijah Ross
Elijah Ross

I put my aliases in a separate file called .aliases
Isn't the standard convention?
Like on every system I've ever installed there was always a .bash_aliases file

Michael Ross
Michael Ross

Someone save me :(

Brandon Walker
Brandon Walker

/thread

Gabriel Harris
Gabriel Harris

alias save='git add * && git commit -m quicksave'
Brainlet

Colton Adams
Colton Adams

cmd

Jace Hill
Jace Hill

Flandre Shell if you know what i mean :^)

Dominic Perry
Dominic Perry

But Flandre isn't a crab, baka yousei.

Disable AdBlock to view this page

Disable AdBlock to view this page