Skip to content

Commit

Permalink
remove std clip (#11131)
Browse files Browse the repository at this point in the history
follow up to
- #11097

related to
- nushell/nu_scripts#674

> **Important**
> wait for in between Nushell 0.88.0 and 0.89.0

# Description
this PR removes the `std clip` command after it's been deprecated in
#11097 😋

# User-Facing Changes
`std clip` will no longer be available.

# Tests + Formatting

# After Submitting
  • Loading branch information
amtoine committed Jan 8, 2024
1 parent 2ea5819 commit c74cff2
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions crates/nu-std/std/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -90,127 +90,6 @@ export def --env "path add" [
}
}

# print a command name as dimmed and italic
def pretty-command [] {
let command = $in
return $"(ansi default_dimmed)(ansi default_italic)($command)(ansi reset)"
}

# give a hint error when the clip command is not available on the system
def check-clipboard [
clipboard: string # the clipboard command name
--system: string # some information about the system running, for better error
] {
if (which $clipboard | is-empty) {
error make --unspanned {
msg: $"(ansi red)clipboard_not_found(ansi reset):
you are running ($system)
but
the ($clipboard | pretty-command) clipboard command was not found on your system."
}
}
}

# put the end of a pipe into the system clipboard.
#
# Dependencies:
# - xclip on linux x11
# - wl-copy on linux wayland
# - clip.exe on windows
# - termux-api on termux
#
# Examples:
# put a simple string to the clipboard, will be stripped to remove ANSI sequences
# >_ "my wonderful string" | clip
# my wonderful string
# saved to clipboard (stripped)
#
# put a whole table to the clipboard
# >_ ls *.toml | clip
# ╭───┬─────────────────────┬──────┬────────┬───────────────╮
# │ # │ name │ type │ size │ modified │
# ├───┼─────────────────────┼──────┼────────┼───────────────┤
# │ 0 │ Cargo.toml │ file │ 5.0 KB │ 3 minutes ago │
# │ 1 │ Cross.toml │ file │ 363 B │ 2 weeks ago │
# │ 2 │ rust-toolchain.toml │ file │ 1.1 KB │ 2 weeks ago │
# ╰───┴─────────────────────┴──────┴────────┴───────────────╯
#
# saved to clipboard
#
# put huge structured data in the clipboard, but silently
# >_ open Cargo.toml --raw | from toml | clip --silent
#
# when the clipboard system command is not installed
# >_ "mm this is fishy..." | clip
# Error:
# × clipboard_not_found:
# │ you are using xorg on linux
# │ but
# │ the xclip clipboard command was not found on your system.
export def clip [
--silent # do not print the content of the clipboard to the standard output
--no-notify # do not throw a notification (only on linux)
--no-strip # do not strip ANSI escape sequences from a string
--expand (-e) # auto-expand the data given as input
--codepage (-c): int # the id of the codepage to use (only on Windows), see https://en.wikipedia.org/wiki/Windows_code_page, e.g. 65001 is for UTF-8
] {
let input = $in

print $"Warning: (char -u 26a0) (ansi yellow_bold)deprecated_command(ansi reset)"
print "| the `std clip` command is deprecated and will be removed in Nushell 0.89"
print ""
print $"(ansi cyan)help(ansi reset): please use (ansi {fg: cyan, attr: du})[`modules/system clip`]\(https://github.com/nushell/nu_scripts/tree/main/modules#system\)(ansi reset)"

let input = $input
| if $expand { table --expand } else { table }
| into string
| if $no_strip {} else { ansi strip }

match $nu.os-info.name {
"linux" => {
if ($env.WAYLAND_DISPLAY? | is-empty) {
check-clipboard xclip --system $"('xorg' | pretty-command) on linux"
$input | xclip -sel clip
} else {
check-clipboard wl-copy --system $"('wayland' | pretty-command) on linux"
$input | wl-copy
}
},
"windows" => {
if $codepage != null {
chcp $codepage
}
check-clipboard clip.exe --system "Windows"
$input | clip.exe
},
"macos" => {
check-clipboard pbcopy --system "MacOS"
$input | pbcopy
},
"android" => {
check-clipboard termux-clipboard-set --system "Termux"
$input | termux-clipboard-set
},
_ => {
error make --unspanned {
msg: $"(ansi red)unknown_operating_system(ansi reset):
'($nu.os-info.name)' is not supported by the ('clip' | pretty-command) command.
please open a feature request in the [issue tracker](char lparen)https://github.com/nushell/nushell/issues/new/choose(char rparen) to add your operating system to the standard library."
}
},
}

if not $silent {
print $input
print $"(ansi white_italic)(ansi white_dimmed)saved to clipboard(ansi reset)"
}

if (not $no_notify) and ($nu.os-info.name == linux) {
notify-send "std clip" "saved to clipboard"
}
}

# convert an integer amount of nanoseconds to a real duration
def "from ns" [] {
[$in "ns"] | str join | into duration
Expand Down

0 comments on commit c74cff2

Please sign in to comment.