Skip to content

Migrating from bash

Most of your bash knowledge carries over unchanged. This page covers what to move and what differs.

Terminal window
grfsh --check ~/.bashrc ~/bin/*.sh

--check parses each script without running it and lists syntax errors, bash features grfsh does not support, and commands it cannot find, with line numbers. A clean result means the script only uses features grfsh implements.

Scripts with #!/bin/bash keep running under bash whatever your login shell is, so you only need to port what you want grfsh itself to run.

bash grfsh
~/.bashrc ~/.grfshrc or ~/.config/grfsh/grfshrc
~/.bash_profile, ~/.profile ~/.grfsh_profile or ~/.config/grfsh/profile
~/.bash_history ~/.grfsh_history

Usually the quickest start is to copy the parts you care about:

Terminal window
grep -E '^(export|alias) ' ~/.bashrc >> ~/.grfshrc

then move functions over one by one and run grfsh --check ~/.grfshrc.

bash grfsh
PS1='\u@\h:\w\$ ' configure-prompt, or GRFSH_PROMPT='{user}@{host}:{cwd}$ '
PROMPT_COMMAND=fn precmd() { fn; }
bind '"\C-g": ...' bindkey '^G' action or bindkey -s '^G' 'text\n'
complete -F _func cmd complete -C 'command that prints words' cmd, complete -W 'a b c' cmd
let x=x+1 (( x++ )) or x=$((x + 1))
shopt -s extglob with !(*.txt) files | where name !~ '\.txt$' | get name, or a loop with case
declare -n ref=name ${!name} for reading, printf -v "$name" for writing
select choice in a b c read -p with a case
history -c history -c
fc !!, !n and history
  • Autosuggestions, highlighting and completion without bash-completion or ble.sh.
  • z for frecent directories and auto cd.
  • Typed tables: files, procs, search, git-status, load, where, sort-by, to json.
  • timeout on macOS, replace, write-file, explain and agent mode.

See Compatibility with bash for the full list.