Skip to content

Instantly share code, notes, and snippets.

@SimZhou
Last active April 22, 2023 16:19
Show Gist options
  • Save SimZhou/c3ba82f161cc05571494ed8d4c1379c7 to your computer and use it in GitHub Desktop.
Save SimZhou/c3ba82f161cc05571494ed8d4c1379c7 to your computer and use it in GitHub Desktop.
Some useful .bashrc settings
# sshcd, Useful when you are switching between hosts with shared file systems
# Example Usage:
# sshcd 172.168.2.32 $(pwd)
# sshpwd 172.168.2.32
sshcd () { ssh -t "$1" "cd \"$2\"; exec \$SHELL -l"; }
sshpwd() { ssh -t "$1" "cd \"$(pwd)\"; exec \$SHELL -l"; }
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=5000
HISTFILESIZE=8000
# KeyMap Settings
stty -ixon # UNBIND Ctrl-S with xon, see: https://unix.stackexchange.com/a/332793/525088
bind -r "\C-s" # UNBIND forward-search-history to Ctrl-S
bind "\C-t":forward-search-history # BIND forward-search-history TO Ctrl-T
bind -r "\C-a" # UNBIND beginning-of-line to Ctrl-A (I am binding it to tmux)
bind "\C-q":beginning-of-line # BIND beginning-of-line TO Ctrl-T
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-up "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-down "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-up "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-down "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ds='du -d 1 -h'
# avoid making mistakes
alias rm='rm -I'
alias mv='mv -i'
alias cp='cp -i'
# KeyMap Settings
stty -ixon # UNBIND Ctrl-S with xon, see: https://unix.stackexchange.com/a/332793/525088
bindkey -r "^S" # UNBIND forward-search-history to Ctrl-S
bindkey "^T" history-incremental-search-forward # BIND forward-search-history TO Ctrl-T
bindkey -r "^A" # UNBIND beginning-of-line to Ctrl-A (I am binding it to tmux)
bindkey -r "^Q" # UNBIND Ctrl-Q to push-line (i don't use it in zsh)
bindkey "^Q" beginning-of-line # BIND Ctrl-T to beginning-of-line
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-up "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-down "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-up "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-down "['']" # UNBIND CTRL-ALT-<UP>/<DOWN> & CTRL-SHIFT-ALT-<UP>/<DOWN>, which interferes with vscode moving line up/down
sshcd () { ssh -t "$1" "cd \"$2\"; exec \$SHELL -l"; }
sshpwd() { ssh -t "$1" "cd \"$(pwd)\"; exec \$SHELL -l"; }
Set-Alias subl "C:\Program Files\Sublime Text\subl.exe"
Set-Alias vim nvim
Set-Alias which Get-Command
Set-Alias realpath Resolve-Path
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
Set-PSReadLineKeyHandler -Chord Ctrl+u -Function BackwardKillLine
Set-PSReadLineKeyHandler -Chord Ctrl+k -Function ForwardDeleteLine
# For Windows Terminal
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command": "paste",
"keys": "ctrl+shift+v"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+shift+c"
},
{
"command": "unbound",
"keys": "ctrl+shift+up"
},
{
"command": "unbound",
"keys": "ctrl+shift+down"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"alwaysShowTabs": true,
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"disableAnimations": false,
"experimental.rendering.forceFullRepaint": false,
"experimental.rendering.software": false,
"focusFollowMouse": false,
"launchMode": "default",
"profiles":
{
"defaults":
{
"altGrAliasing": true,
"antialiasingMode": "grayscale",
"closeOnExit": "never",
"colorScheme": "Monokai Night",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Delugia Nerd Font",
"size": 10
},
"opacity": 75,
"useAcrylic": true
},
"list":
[
{
"backgroundImage": null,
"backgroundImageOpacity": 0.20999999999999999,
"colorScheme": "Monokai Night",
"cursorShape": "filledBox",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Delugia Nerd Font",
"size": 10,
"weight": "normal"
},
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"intenseTextStyle": "bright",
"name": "Windows PowerShell",
"opacity": 70,
"padding": "8",
"scrollbarState": "visible"
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "\u547d\u4ee4\u63d0\u793a\u7b26"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"colorScheme": "Monokai Night",
"cursorShape": "filledBox",
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
},
{
"antialiasingMode": "grayscale",
"colorScheme": "Campbell",
"experimental.retroTerminalEffect": false,
"guid": "{51855cb2-8cce-5362-8f54-464b92b32386}",
"hidden": false,
"name": "Ubuntu",
"source": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc",
"startingDirectory": null,
"suppressApplicationTitle": false
},
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell 7",
"source": "Windows.Terminal.PowershellCore"
}
]
},
"schemes":
[
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#262626",
"black": "#1B1D1E",
"blue": "#465457",
"brightBlack": "#505354",
"brightBlue": "#899CA1",
"brightCyan": "#8CEDFF",
"brightGreen": "#B6E354",
"brightPurple": "#9E6FFE",
"brightRed": "#FF5995",
"brightWhite": "#F8F8F2",
"brightYellow": "#FEED6C",
"cursorColor": "#FFFFFF",
"cyan": "#56C2D6",
"foreground": "#F8F8F2",
"green": "#82B414",
"name": "Monokai",
"purple": "#8C54FE",
"red": "#F92672",
"selectionBackground": "#FFFFFF",
"white": "#CCCCC6",
"yellow": "#FD971F"
},
{
"background": "#1F1F1F",
"black": "#1F1F1F",
"blue": "#6699DF",
"brightBlack": "#75715E",
"brightBlue": "#66D9EF",
"brightCyan": "#E69F66",
"brightGreen": "#A6E22E",
"brightPurple": "#AE81FF",
"brightRed": "#F92672",
"brightWhite": "#F8F8F2",
"brightYellow": "#E6DB74",
"cursorColor": "#FFFFFF",
"cyan": "#E69F66",
"foreground": "#F8F8F8",
"green": "#A6E22E",
"name": "Monokai Night",
"purple": "#AE81FF",
"red": "#F92672",
"selectionBackground": "#FFFFFF",
"white": "#F8F8F2",
"yellow": "#E6DB74"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#300A24",
"black": "#171421",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#08458F",
"brightCyan": "#2C9FB3",
"brightGreen": "#26A269",
"brightPurple": "#A347BA",
"brightRed": "#C01C28",
"brightWhite": "#F2F2F2",
"brightYellow": "#A2734C",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#FFFFFF",
"green": "#26A269",
"name": "Ubuntu-ColorScheme",
"purple": "#881798",
"red": "#C21A23",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#A2734C"
},
{
"background": "#300A24",
"black": "#171421",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#08458F",
"brightCyan": "#2C9FB3",
"brightGreen": "#26A269",
"brightPurple": "#A347BA",
"brightRed": "#C01C28",
"brightWhite": "#F2F2F2",
"brightYellow": "#A2734C",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#FFFFFF",
"green": "#26A269",
"name": "UbuntuColorScheme",
"purple": "#881798",
"red": "#C21A23",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#A2734C"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
],
"showTabsInTitlebar": true,
"tabSwitcherMode": "inOrder",
"tabWidthMode": "equal",
"theme": "system"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment